Quake3World.com
https://www.quake3world.com/forum/

how do you detect what team a player is on that threw a gren
https://www.quake3world.com/forum/viewtopic.php?f=16&t=46300
Page 1 of 1

Author:  bludshot [ 09-03-2011 10:41 PM ]
Post subject:  how do you detect what team a player is on that threw a gren

(This seems very basic to me, but I haven't been able to find it in lots of searching)

In CG_Missile() in cg_ents.c, my mod has smoke grenades that you can throw. I need to do:

switch ( PlayerTeam ) {
case TEAM_RED:
etc...

But I don't know how to get the player's team? I tried to get clientnum and check from that but it seems to be the number of the grenade itself not the player.

I want the smoke to be blue when the player who threw the smoke grenade is on the blue team, and red when he's on the red team, and the only part I haven't figured out about that is knowing which team they are on.

Author:  Eraser [ 09-04-2011 01:16 AM ]
Post subject:  Re: how do you detect what team a player is on that threw a gren

ent->client->sess.sessionTeam

this gives you an int which matches any value in the team_t enum:
Code:
typedef enum {
   TEAM_FREE,
   TEAM_RED,
   TEAM_BLUE,
   TEAM_SPECTATOR,

   TEAM_NUM_TEAMS
} team_t;


A player's team is TEAM_FREE in non-team games.

Author:  MdQvack [ 09-06-2011 10:41 AM ]
Post subject:  Re: how do you detect what team a player is on that threw a gren

I think this is what you're looking for:

1) In G_missile.c
At the end of *fire_grenade (right before 'return bolt;') add:
Code:
if (self->client)
    bolt->s.generic1 = self->client->sess.sessionTeam;


2) In CG_ents.c
In function CG_missile (for example after 'ent.renderfx = weapon->missileRenderfx | RF_NOSHADOW;') add:
Code:
if( s1->generic1 == TEAM_BLUE ) {
   ent.customShader = cgs.media.grenadeShaderBlueSmoke; //Or something...
} else {
   ....and something   
}

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/