Adding a function to svcmds
Posted: Fri Jul 25, 2008 1:51 pm
I have been following this excellent tutorial thats been provided here on how to cloak oneself in quake. What I would like to do however is make this feature available to admins only. I changed it around a bit as detailed below but when I go on the server and issue 'rcon cloak' it causes a buffer overflow and crashes all clients connected to server. Anyone know why this might be happening?
g_svcmds.c
g_svcmds.c
Code: Select all
/*
=================
Svcmd_Cloak_f
=================
*/
void Svcmd_Cloak_f( gentity_t *ent ) {
char *msg; // message to player
ent->flags ^= FL_CLOAK;
if (!(ent->flags & FL_CLOAK)) {
msg = "Cloaking OFF\n";
ent->client->ps.powerups[PW_INVIS] = level.time;
// Removes the invisible powerup from the player
}
else {
msg = "Cloaking ON\n";
ent->client->ps.powerups[PW_INVIS] = level.time + 1000000000;
// Gives the invisible powerup to the player
}
trap_SendServerCommand( ent-g_entities, va("print \"%s\"", msg));
}
// Console commands down at bottom
if ( Q_stricmp (cmd, "cloak") == 0 ) {
Svcmd_Cloak_f( ent );
return qtrue;
}