-
First:
I can't figure out a way to print a message to all players without getting an error.
This works:
Code:
int UTIL_TakeDamage( edict_t *pEdict, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType )
{
if ( pEdict->v.health <= 0 )
{
CLIENT_PRINTF( pEdict, print_console, UTIL_VarArgs( "%s was killed by an %s\n",
STRING( pEdict->v.netname ),
STRING( pevAttacker->classname ) ) );
}
}
But I need it to print to all players.
This one just crashing the server with
SZ_GetSpace: Tried to write to an uninitialized sizebuf_t: ??? when I or anyone else gets killed:
Code:
int UTIL_TakeDamage( edict_t *pEdict, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType )
{
if ( pEdict->v.health <= 0 )
{
for (int i = 1; i <= gpGlobals->maxClients; i++)
{
edict_t *pPlayer = INDEXENT(i);
if( !pPlayer )
{
continue;
}
CLIENT_PRINTF( pPlayer, print_console, UTIL_VarArgs( "%s was killed by an %s\n",
STRING( pEdict->v.netname ),
STRING( pevAttacker->classname ) ) );
}
}
}
-
Second:
Need some help with this to get a player's index and authid.
My (user)ID is
15 always, which is wrong. It's
1 as you can see yourself on the first line. And I have no idea what's happening with the authid.
Code:
int UTIL_TakeDamage( edict_t *pEdict, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType )
{
if ( pEdict->v.health <= 0 )
{
UTIL_LogPrintf( "\"%s\" killed \"%s<%i><%s>\"\n",
STRING( pevAttacker->classname ),
STRING( pEdict->v.netname ) ),
GETPLAYERUSERID( pEdict ),
GETPLAYERAUTHID( pEdict );
}
}
Also, I'm pretty sure CS don't use
pev->team for team assignment so I need one for both CS and other mods which use
pev->team which I have no clue about how to do.