SA-MP Forums Archive
Timer problem [Giving rep] - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Timer problem [Giving rep] (/showthread.php?tid=310079)



Timer problem [Giving rep] - Twinki1993 - 10.01.2012

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.


Re: Timer problem [Giving rep] - Twinki1993 - 10.01.2012

::BUMP::