![](images/misc/post_spacer.gif) |
AMX Mod X Plugin Approver
|
![Old](images/statusicon/post_old.svg)
05-23-2011
, 07:14
Re: Cvar Utilities
|
#22
|
I would suggest to use a bound to make sure value is either 0 or 1. Also, since you have one cvar, making a private function is not really needed.
For example :
PHP Code:
new Catch_Enable;
public plugin_init() { new handleCvarStatus = CvarRegister( "amx_catch_enable", "1", .hasMin = true, .minValue = 0.0, .hasMax = true, .maxValue = 1.0, .forceInterval = false ); CvarHookChange( handleCvarStatus, "Catch_Cvar" ); } public Catch_Cvar( const handleCvar, const oldValue[], const newValue[], const cvarName[] ) { Catch_Enable = ( newValue[ 0 ] == '1' ); client_print( 0, print_chat, "Catchmod is now %s", Catch_Enable ? "ON" : "OFF" ); server_cmd( "sv_restart 1" ); }
__________________
Last edited by Arkshine; 05-23-2011 at 07:17.
|
|
|
|