Timer problem [Giving rep]
#1

Hello guys, well I have timer problem. I have a cooldown timer which will prevent someone from spamming the command every second and it's not working. It should work like this:

When player presses a Crouch button there should be a object spawned or if he types /(s)ignal (Working)
After 5 seconds object will dissapear (Not working)
If you try to use the command again it should say that you cannot do that again. You must wait one more minute (Not working)

Код:
//top of the script
new Cooldown[MAX_PLAYERS];

//bellow on game mode init
SetTimer("CooldownTimer",1000,true);

//command
if (strcmp("/signal", cmdtext, true) == 0 || strcmp("/s", cmdtext, true) == 0)
	{
 		if(Cooldown[playerid] == 1) return SendClientMessage(playerid,COLOR_RED,"<!>Please Wait Before Using This Command Again!");
  		{
	    	new Float:x, Float:y, Float:z, SignalObj;
		    GetPlayerPos(playerid, x, y, z);
		    SetTimerEx( "Signal", 5000, false, "i", SignalObj );
		    SignalObj = CreateObject(18714,x,y,z, 0.0, 0.0, 96.0);
		    GameTextForPlayer(playerid, "Signal started", 1, 1);
		    SendClientMessage(playerid, COLOR_LIGHTBLUE, "<!>You can also press 'Crouch' button to activate this!");
		}
  		return 1;
	}

//On Key Press
    if (PRESSED(KEY_CROUCH))
    {
        if(Cooldown[playerid] == 1) return SendClientMessage(playerid,COLOR_RED,"<!>Please Wait Before Using This Command Again!");
  		{
	    	new Float:x, Float:y, Float:z, SignalObj;
		    GetPlayerPos(playerid, x, y, z);
		    SetTimerEx( "Signal", 5000, false, "i", SignalObj );
		    SignalObj = CreateObject(18714,x,y,z, 0.0, 0.0, 96.0);
		    GameTextForPlayer(playerid, "Signal started", 1, 1);
		}
		return 1;
	}
	return 1;
}

//forwards
forward CooldownTimer();

forward Signal( objectid );
public Signal( objectid )
{
    DestroyObject( objectid );
    return 1;
}
Just a thing to add that when I compile this I am not receiving any errors. Just it's not working in game.
Reply
#2

::BUMP::
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)