SA-MP Forums Archive
Timer - 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 (/showthread.php?tid=345595)



Timer - HighPitchedVoice - 25.05.2012

Hello there, how can I add a timer to this command?

pawn Код:
if (strcmp("/af", cmdtext, true, 10) == 0)
    {
        new pName[MAX_PLAYER_NAME],str[100];
        GetPlayerName(playerid,pName,sizeof(pName));
        format(str,sizeof(str),"{FF7F00} %s went to the Abonded Airfield (/af).",pName);
        SetPlayerPos(playerid, 431.0490,2503.5349,16.4844);
        SendClientMessageToAll(-1,str);
        return 1;
    }



Re: Timer - Ballu Miaa - 25.05.2012

Timer to do what?


Re: Timer - HighPitchedVoice - 25.05.2012

To make the player not teleport on 5 seconds and if the player is taking damage it would cancel it.


Re: Timer - milanosie - 25.05.2012

At OnPlayerUpdate

Make it so that if the players health is lower then the start of the timer, KillTimer


Re: Timer - HighPitchedVoice - 25.05.2012

Code please? :P


Re: Timer - milanosie - 25.05.2012

Just set a standard timer, and before setting the timer store the health in a Float Variable,

At onplayerupdate check if GetPlayerHealth(playerid) < the float variable.

IF that is true KillTimer



Did I give enough information?


Re: Timer - HighPitchedVoice - 25.05.2012

I don't got a "OnPlayerUpdate" :P


Re: Timer - Saad_ - 25.05.2012

Well then add it :P https://sampwiki.blast.hk/wiki/OnPlayerUpdate


Re: Timer - IceCube! - 25.05.2012

Just give the dude what he wants I'm going to give you the timer and you work out how to implement it, okay?

pawn Код:
SetTimerEx("Teleport", 5000, 0, "iffff", playerid, health, float:x, float:y, float:z);

forward Teleport(playerid, float:health, float:x, float:y, float:z);
public Teleport(playerid, float:health, float:x, float:y, float:z)
{
     if(health == GetPlayerHealth(playerid))
     {
             SetPlayerPos(x, y, z);
     }
     else
     {
          //code
      }
      return 1;
}
WARNING: Untested.

EDIT: YOu could do it the OnPlayerUpdate way although I didn't think thats what you wanted, if you did want that I will makeit for if you say so.


Re: Timer - HighPitchedVoice - 25.05.2012

Thank you for your help all of you, but as I read on the wiki it could take more CPU usage and could cause lag.