PDA

View Full Version : css cvars and cmds



sp0rky
02-07-2005, 11:36 PM
ConVar spinhack( "spinhack", "1", CVAR_FLAGS, "Turn spinhack on or off." );
ConVar norecoil( "norecoil", "1", CVAR_FLAGS, "Turn norecoil on or off." );
ConVar bhop( "bhop", "1", CVAR_FLAGS, "Turn bunnyhopping on or off." );

// Here we link in all cvars to the engine list
void LinkCvars( void )
{
// You must SetNext(0) or it will not link to the engine list
spinhack.SetNext(0);
norecoil.SetNext(0);
bhop.SetNext(0);

// Here we link in each cvar
cvar->RegisterConCommandBase(&spinhack);
cvar->RegisterConCommandBase(&norecoil);
cvar->RegisterConCommandBase(&bhop);
}



Credits: Source SDK

This may not appear elsewhere without permission, but may be linked to.

Milan
02-08-2005, 02:56 AM
:evolved: nice one, thanks

juxtapose
02-08-2005, 04:57 AM
is it just me or Tetsuo is feeling very really generious!? :knocked_o but yeah, ty for all the nice tutorials :cool(2):

sp0rky
02-11-2005, 04:59 PM
If you want to make callbacks for when a ConVar changes it's easy.



ConVar esp_font( "esp_font", "Silkscreen", CVAR_FLAGS, "Font name for player esp.", Esp_FontChange );
ConVar esp_fontsize( "esp_fontsize", "8", CVAR_FLAGS, "Size of the font for player esp.", Esp_FontSizeChange );


When the value changes the callback function is called. If you're using vgui esp, you will need to adjust the class a little bit.



void Esp_FontSizeChange( ConVar *pVar, const char *szOldStr )
{
esp->ReInitializeFont();
}

void Esp_FontChange( ConVar *pVar, const char *szOldStr )
{
esp->ReInitializeFont();
}


Yes I know both functions do the same thing, but this is an example for you all.

Credits: Xen, el pat0!!!!11111

This may not appear elsewhere without permission, but may be linked to.

sp0rky
02-12-2005, 08:49 PM
Use this to make it easier to add a lot of cvars and help keep your src neater.



FORCEINLINE void Link( ConCommandBase &var )
{
var.SetNext(0); // must SetNext(0) or it wont link to the engine list
cvar->RegisterConCommandBase(&var); // link to the engine list
}

goozeman
02-14-2005, 10:43 PM
nice job Tetsuo :square-ey