Jump to content

Home

Determining if Cheats are Enabled in cgame


recombinant

Recommended Posts

I'm using the following bit of code to determine if cheats are enabled in cgame:

 

qboolean	bCheatsEnabled;

//-------------------------------------------
// See if cheats are enabled
//-------------------------------------------
bCheatsEnabled = qfalse;
s = Info_ValueForKey( sysInfo, "sv_cheats" );
if ( s[0] == '1' ) {
bCheatsEnabled = qtrue;
}
//-------------------------------------------

 

It's not working quite the way I expected it to (i.e. it's not working ;) ), so does anyone else have a method for checking if cheats are enabled when working in cgame?

 

In the game code it looks straigtforward (just use CheatsOk()), but on the client side I couldn't find any other examples other than the bit I recycled above.

 

Any help will be appreciated.

 

Thanks!

 

:D

Link to comment
Share on other sites

qboolean	bCheatsEnabled;

//-------------------------------------------
// See if cheats are enabled
//-------------------------------------------
char var[MAX_TOKEN_CHARS];
bCheatsEnabled = qfalse;
trap_Cvar_VariableStringBuffer( "sv_cheats", var, sizeof( var ) );
if ( atoi(var) == 1) { bCheatsEnabled = qtrue; }

 

would that do it ? looks like it :) hope this helps

Link to comment
Share on other sites

Oops. Forgot to give an update here! :rolleyes:

 

Per a discussion thread on Quake3World.com forums, I modified the cgs_t structure in cg_local.h, adding a new flag called, ironically, "sv_cheats." ;)

typedef struct {

// ( snipped code... )

// jodfmod - sv_cheats flag
int  sv_cheats;

} cgs_t;

 

This flag gets set in CG_DrawInformation() in cg_info.c, where the check for cheats already existed. This way, I don't mess around too much with existing code, and I can use this flag wherever I want on the client side. ;)

 

Ultimately, however, what I ended up doing was making this modification on the server side anyway, in the ClientSpawn() function. It works pretty well, because now if cheats are enabled they get the saber, otherwise the player gets the stun baton.

 

I left my flag modification in there, just in case I need it somewhere in the client-side code. It just might come in handy... :D

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...