recombinant Posted January 21, 2003 Share Posted January 21, 2003 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! Link to comment Share on other sites More sharing options...
Code Posted January 21, 2003 Share Posted January 21, 2003 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 More sharing options...
recombinant Posted January 21, 2003 Author Share Posted January 21, 2003 Originally posted by Code would that do it ? looks like it hope this helps Thanks, Code! I will try it out and get back to you on my success/failure. Thanks again for your assistance! Link to comment Share on other sites More sharing options...
Wudan Posted January 25, 2003 Share Posted January 25, 2003 Maybe ... if ( sv_cheats.integer ) { bCheatsEnabled = qtrue; } else if ( !sv_cheats.integer ) { bCheatsEnabled = qfalse; } ? Link to comment Share on other sites More sharing options...
razorace Posted January 26, 2003 Share Posted January 26, 2003 Both Code and Wudan's suggestions seem correct. However it would be easier to ensure you always have a value bCheatsEnabled if you just define it by using... qboolean bCheatsEnabled = qfalse; Link to comment Share on other sites More sharing options...
recombinant Posted January 27, 2003 Author Share Posted January 27, 2003 Oops. Forgot to give an update here! 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... Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.