| Author |
Topic: Team ESP |
| MaTrIx1516~rb |
General Member Since: Dec 23, 2006 Posts: 58 Last: Dec 23, 2006 [view latest posts] |
|
|
|
Category: SoFII Mapping Posted: Friday, Nov. 24, 2006 03:16 am |
 |
Alright, well I would like to make a little code for drawing the names of players on my team. Not the enemy, only for team. Instead of when you move your crosshair over them, it always shows their name. The problem is I don't know what i'm doing wrong. Here's the code. Code: #define FONTSCALE 0.45f
char *info_getname (int index); int info_getteam (int index);
char *Info_ValueForKey (const char *s, const char *key);
const char * CONFSTR (int index) { gameState_t *gs; extern gameState_t gstemp; return cgs.gameState.stringData + cgs.gameState.stringOffsets[ index ]; }
char *info_getname (int index) { return Info_ValueForKey (CONFSTR (CS_PLAYERS + index), "n"); }
int info_getteam (int index) { return atoi (Info_ValueForKey (CONFSTR (CS_PLAYERS + index), "t")); }
qhandle_t font = 0; int fontheight = 0;
void CG_MatrixEsp( playerState_t *ps, centity_t *cent ) { entityState_t *es = ¢->currentState; vec4_t red = { 1.0f, 0.0f, 0.0f, 1.0f }; vec4_t green = { 0.0f, 1.0f, 0.0f, 1.0f }; float *color; int x, y; char *s, *s2; int w; entityState_t *ent;
if (!font) { font = cgs.media.hudFont; fontheight = trap_R_GetTextHeight ("|", font, FONTSCALE, 0); }
if (!CG_WorldCoordToScreenCoord (cent->lerpOrigin, &x, &y)) return;
if ( cgs.gametypeData->teams && cg_teamCheck.integer > 0 ) { if (cg_teamCheck.integer == 1) { if (info_getteam (cent->currentState.number) == info_getteam (ps->clientNum)) color = (float *) &green; // friendly } if (cg_matrixEsp.integer == 1 || cg_matrixEsp.integer == 3) { s = info_getname (cent->currentState.number); CG_DrawText ((x - trap_R_GetTextWidth (s, font, FONTSCALE, 0) / 2), y - fontheight, font, FONTSCALE, color, s, 0, 0); } CODE]
The problem is, nothing even draws. No text. Any help would be great. |
 |
|
|
| sweatingbullets~rb |
General Member Since: Dec 23, 2006 Posts: 79 Last: Dec 23, 2006 [view latest posts] |
|
|
|
Category: SoFII Mapping Posted: Friday, Nov. 24, 2006 09:30 am |
 |
I made a huge reply lastnight then came back just now and read it. It didnt even make sense to me  . Basically, you are doing A LOT more then you need to be doing. You can get the player name and team via cgs.clientinfo. Also the worldcoornates will work, just make sure its only drawing it if its in the bounds of the virtual screen (480x640). Lastly, make sure its ran every frame for each client, that way the text can be seen by human eyes. It would probably be better to check each client in one call using a loop statement. |
 |
|
|
| MaTrIx1516~rb |
General Member Since: Dec 23, 2006 Posts: 58 Last: Dec 23, 2006 [view latest posts] |
|
|
|
|
| sweatingbullets~rb |
General Member Since: Dec 23, 2006 Posts: 79 Last: Dec 23, 2006 [view latest posts] |
|
|
|
|
| MaTrIx1516~rb |
General Member Since: Dec 23, 2006 Posts: 58 Last: Dec 23, 2006 [view latest posts] |
|
|
|
Category: SoFII Mapping Posted: Saturday, Nov. 25, 2006 09:35 pm |
 |
Thanks for the reply. So how about this? vec4_t green = { 0.0f, 1.0f, 0.0f, 1.0f }; float *color; int x,y; char *name; if(y < 0 || y >= SCREEN_HEIGHT) continue; if(x < 0 || x > SCREEN_WIDTH) continue; { if (!CG_WorldCoordToScreenCoord (cent->lerpOrigin, &x, &y)) return; } if ( cgs.gametypeData->teams) { if (ci->team == cgs.clientinfo .team) color = (float *) &green; // friendly } if (cg_Esp.integer == 1) { name = cgs.clientinfo.name; I don't know if this is right. How would I draw text after this?  |
 |
|
|
| sweatingbullets~rb |
General Member Since: Dec 23, 2006 Posts: 79 Last: Dec 23, 2006 [view latest posts] |
|
|
|
Category: SoFII Mapping Posted: Sunday, Nov. 26, 2006 04:27 am |
 |
Try something like this. I added some extra stuff, like distance checks, dead/respawing checks, etc.. | Code Sample | void CG_Matrix (void) { int i, x, y; int width; centity_t* cent; vec3_t dirPlayer; float distance;
if ( !cgs.gametypeData->teams ) return;
for ( i = 0; i < cgs.maxclients; i ++ ) {
if ( cgs.clientinfo[i].team != cgs.clientinfo[cg.snap->ps.clientNum].team ) continue; cent = CG_GetEntity (i);
if(cg.snap->ps.clientNum == cent->currentState.clientNum) continue; if(cent->currentState.eFlags & EF_DEAD) continue; if(cgs.clientinfo[i].health <= 0) continue;
if (CG_WorldCoordToScreenCoord (cent->lerpOrigin, &x, &y)) { if(y < 0 || y >= SCREEN_HEIGHT) continue; if(x < 0 || x > SCREEN_WIDTH) continue;
VectorSubtract ( cg.predictedPlayerState.origin, cent->lerpOrigin, dirPlayer ); dirPlayer[2] = 0; distance = VectorNormalize ( dirPlayer ); if ( distance > 1800) continue; if ( distance < 200) continue;
width = trap_R_GetTextWidth (cgs.clientinfo[i].name, cgs.media.hudFont, 0.38f / (distance / 300 ), 0); CG_DrawText ((x - (width/2)), y - (150 / (distance / 150 )), cgs.media.hudFont, 0.38f / (distance / 300 ), colorGreen, cgs.clientinfo[i].name, 0, 0); } } } |
|
 |
|
|
| MaTrIx1516~rb |
General Member Since: Dec 23, 2006 Posts: 58 Last: Dec 23, 2006 [view latest posts] |
|
|
|
|
| MaTrIx1516~rb |
General Member Since: Dec 23, 2006 Posts: 58 Last: Dec 23, 2006 [view latest posts] |
|
|
|
|
| sweatingbullets~rb |
General Member Since: Dec 23, 2006 Posts: 79 Last: Dec 23, 2006 [view latest posts] |
|
|
|
|
| MaTrIx1516~rb |
General Member Since: Dec 23, 2006 Posts: 58 Last: Dec 23, 2006 [view latest posts] |
|
|
|
Category: SoFII Mapping Posted: Sunday, Nov. 26, 2006 09:46 am |
 |
Hmm. Weird. I have called the matrix function.
teamesp ===================== */ void CG_Matrix (void) { int i, x, y; int width; centity_t* cent; vec3_t dirPlayer; float distance;
if ( !cgs.gametypeData->teams ) return;
for ( i = 0; i < cgs.maxclients; i ++ ) {
if ( cgs.clientinfo.team != cgs.clientinfo[cg.snap->ps.clientNum].team ) continue; cent = CG_GetEntity (i);
if(cg.snap->ps.clientNum == cent->currentState.clientNum) continue;
if(cent->currentState.eFlags & EF_DEAD) continue; if(cgs.clientinfo.health <= 0) continue;
if (CG_WorldCoordToScreenCoord (cent->lerpOrigin, &x, &y)) { if(y < 0 || y >= SCREEN_HEIGHT) continue; if(x < 0 || x > SCREEN_WIDTH) continue;
VectorSubtract ( cg.predictedPlayerState.origin, cent->lerpOrigin, dirPlayer ); dirPlayer[2] = 0; distance = VectorNormalize ( dirPlayer );
if ( distance > 1800) continue; if ( distance < 200) continue;
width = trap_R_GetTextWidth (cgs.clientinfo.name, cgs.media.hudFont, 0.38f / (distance / 300 ), 0); CG_DrawText ((x - (width/2)), y - (150 / (distance / 150 )), cgs.media.hudFont, 0.38f / (distance / 300 ), colorGreen, cgs.clientinfo.name, 0, 0);
} } }
Then under 2d
if ( cg.snap->ps.pm_type == PM_SPECTATOR || cg.snap->ps.persistant[PERS_TEAM] == TEAM_SPECTATOR ) { CG_DrawSpectator(); CG_DrawCrosshair(); CG_DrawCrosshairNames(); CG_DrawHUDIcons(); CG_Matrix(); } |
 |
|
|
|
|
mp_TempleCall of Duty: Mods: Multiplayer (624.12Kb)
|