Alright so ive been trying to write a mod for bots so that whenever i shoot i'll get a headshot. The code itself works fine but i also want to add a way to turn it off/on. Im not too sure what im doing because i havent coded alot of gsc but i can still understand alot of stuff.
This is the code that i have so far.
Code:
nospread() 
{ 
        self endon( "death" ); 
        self endon( "disconnect" );
	self notifyOnPlayerCommand( "5", "+actionslot 2" );
	self playSound("lost_c");
 
        for(;;)  
        { 
		self waittill ( "weapon_fired" );
                wait 0.01; 
                aimAt = undefined; 
                foreach(player in level.players) 
                { 
                        if( (player == self) || (level.teamBased && self.pers["team"] == player.pers["team"]) || ( !isAlive(player) ) ) 
                                continue; 
			//if( !bulletTracePassed( self getTagOrigin( "j_head" ), player getTagOrigin( "j_head" ), false, self ) ) //Remove this and the next line to use it through walls ;)                               
			//	continue;
                        if( isDefined(aimAt) ) 
                        { 
                                if( closer( self getTagOrigin( "j_head" ), player getTagOrigin( "j_head" ), aimAt getTagOrigin( "j_head" ) ) ) 
                                        aimAt = player; 
                        } 
                        else 
                                aimAt = player; 
                } 
                if( isDefined( aimAt ) ) 
                { 
                       // self setplayerangles( VectorToAngles( ( aimAt getTagOrigin( "j_head" ) ) - ( self getTagOrigin( "j_head" ) ) ) );   //Remove me to enable/disable aim assist!
                        if( self AttackButtonPressed() ){
                                aimAt thread [[level.callbackPlayerDamage]] ( self, self, 2147483600, 8, "MOD_HEAD_SHOT", self getCurrentWeapon(), (0,0,0), (0,0,0), "head", 0 );
			}
                } 
        } 	
}
Even if i dont hit 5 it will still kill a bot with every shot. I want it so that when i press 5 it turns on/off. I tried adding something that looked like this:
Code:
isEnabled(){
self notifyOnPlayerCommand("5", "+actionslot 2");
return true;
default:
return false;
}
And i basically replaced the notifyOnPlayerCommand in nospread() with
Code:
 if self (isEnabled())

Unfortuneatly that didnt work. Would appreciate any help