Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds

Members Online

»
0 Active | 10 Guests
Online:

LATEST FORUM THREADS

»
warfare
CoD4 Map + Mod Releases
Voting menu on maps
CoD+UO General
Hauling 911
CoDBO3 General

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Soldier of Fortune
Category: SoFII Mapping
Mapping, modeling, scripting, skinning and all forms of editing for the game Soldier of Fortune II
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked
Page
Next Page
subscribe
Author Topic: Team ESP
MaTrIx1516~rb
General Member
Since: Dec 23, 2006
Posts: 58
Last: Dec 23, 2006
[view latest posts]
Level 3
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 = &cent->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.
Share |
sweatingbullets~rb
General Member
Since: Dec 23, 2006
Posts: 79
Last: Dec 23, 2006
[view latest posts]
Level 3
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  :p.

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.
Share |
MaTrIx1516~rb
General Member
Since: Dec 23, 2006
Posts: 58
Last: Dec 23, 2006
[view latest posts]
Level 3
Category: SoFII Mapping
Posted: Saturday, Nov. 25, 2006 06:52 pm
Could I use cg.screenYScale and cg.screenXScale?
Share |
sweatingbullets~rb
General Member
Since: Dec 23, 2006
Posts: 79
Last: Dec 23, 2006
[view latest posts]
Level 3
Category: SoFII Mapping
Posted: Saturday, Nov. 25, 2006 07:24 pm
All resolutions are based off 640x480 and then scaled from there.

Just use the SCREEN_WIDTH/SCREEN_HEIGHT DEFINES.

if(y < 0 || y >= SCREEN_HEIGHT)
 continue;
if(x < 0 || x > SCREEN_WIDTH)
 continue;
Share |
MaTrIx1516~rb
General Member
Since: Dec 23, 2006
Posts: 58
Last: Dec 23, 2006
[view latest posts]
Level 3
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?  :s6:
Share |
sweatingbullets~rb
General Member
Since: Dec 23, 2006
Posts: 79
Last: Dec 23, 2006
[view latest posts]
Level 3
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);

}
}
}
Share |
MaTrIx1516~rb
General Member
Since: Dec 23, 2006
Posts: 58
Last: Dec 23, 2006
[view latest posts]
Level 3
Category: SoFII Mapping
Posted: Sunday, Nov. 26, 2006 04:45 am
Alright, thanks man i'll give it a shot and let you know soon. My motherboard fried, and I can't get back on my system, so i'll have to download the source code on this computer, and test it out until newegg can send me a replacement.  :(
Share |
MaTrIx1516~rb
General Member
Since: Dec 23, 2006
Posts: 58
Last: Dec 23, 2006
[view latest posts]
Level 3
Category: SoFII Mapping
Posted: Sunday, Nov. 26, 2006 07:27 am
Sorry for the doublepost. I compiled it and all went well, but nothing drew still on screen or on players. No text. Any suggestions. Thanks man.  :D
Share |
sweatingbullets~rb
General Member
Since: Dec 23, 2006
Posts: 79
Last: Dec 23, 2006
[view latest posts]
Level 3
Category: SoFII Mapping
Posted: Sunday, Nov. 26, 2006 08:43 am
Make sure you are calling your CG_Matrix function.

Add it to the end of the CG_Draw2D function and it should work.
Share |
MaTrIx1516~rb
General Member
Since: Dec 23, 2006
Posts: 58
Last: Dec 23, 2006
[view latest posts]
Level 3
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();
}
Share |
Restricted Access Topic is Locked
Page
Next Page
subscribe
MODSonline.com Forums : Soldier of Fortune : SoFII Mapping

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»