View Single Post
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-23-2011 , 07:14   Re: Cvar Utilities
Reply With Quote #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 );
    
CvarHookChangehandleCvarStatus"Catch_Cvar" );
}
public 
Catch_Cvar( const handleCvar, const oldValue[], const newValue[], const cvarName[] )
{
    
Catch_Enable = ( newValue] == '1' );
    
client_print0print_chat"Catchmod is now %s"Catch_Enable "ON" "OFF" );
    
    
server_cmd"sv_restart 1" );

__________________

Last edited by Arkshine; 05-23-2011 at 07:17.
Arkshine is offline