SA-MP Forums Archive
Need Help With Setting a Timer For /Stuck [fixed] - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Need Help With Setting a Timer For /Stuck [fixed] (/showthread.php?tid=122306)



Need Help With Setting a Timer For /Stuck [fixed] - Marouane - 21.01.2010

Hello ,
Because Of The Abusing Of /Stuck in my server , I Want To Put A Timer For it

Код:
 	if(strcmp(cmd, "/stuck", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
		{
			new Float:slx, Float:sly, Float:slz;
			GetPlayerPos(playerid, slx, sly, slz);
			SetPlayerPos(playerid, slx, sly, slz+2);
			TogglePlayerControllable(playerid, 1);
			return 1;
		}
Could you help me how to make it please ?
Thanks


Re: Need Help With Setting a Timer For /Stuck - akis_tze - 21.01.2010

i dont understand what want to do but i can help with timer

example
Код:
if(strcmp(cmd, "/stuck", true) == 0)
{
   if(IsPlayerConnected(playerid))
   {
   SetTimerEx("stucktime", 15000, false, "d", playerid);//15000 = 15 sec
   }
   return 1;
}
add this at the end of your script
Код:
forward stucktime();
public stucktime()
{
new Float:slx, Float:sly, Float:slz;
GetPlayerPos(playerid, slx, sly, slz);
SetPlayerPos(playerid, slx, sly, slz+2);
TogglePlayerControllable(playerid, 1);
return 1;
}



Re: Need Help With Setting a Timer For /Stuck - Vetle - 21.01.2010

i think he wants a cooldown timer not a delay timer


Re: Need Help With Setting a Timer For /Stuck - Marouane - 21.01.2010

Thanks For The Delaytimer ,
But I Need A Cool Downtimer . Could you help me with that please ?
Thanks .


Re: Need Help With Setting a Timer For /Stuck - MadeMan - 21.01.2010

Put this in the beginning of the script

pawn Код:
new StuckDelay[MAX_PLAYERS];
and then the command

pawn Код:
if(strcmp(cmd, "/stuck", true) == 0)
    {
        if(GetTickCount() - StuckDelay[playerid] > 10000) // 10000 is 10 seconds in milliseconds
        {
            new Float:slx, Float:sly, Float:slz;
            GetPlayerPos(playerid, slx, sly, slz);
            SetPlayerPos(playerid, slx, sly, slz+2);
            TogglePlayerControllable(playerid, 1);
            StuckDelay[playerid] = GetTickCount();
        }
        else
        {
            SendClientMessage(playerid, 0xFFFFFFFF, "Don't spam!");
        }
        return 1;
    }
You don't need IsPlayerConnected check there.


Re: Need Help With Setting a Timer For /Stuck - Marouane - 21.01.2010

Thanks So Much