#1

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;
    }
Reply
#2

Timer to do what?
Reply
#3

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

At OnPlayerUpdate

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

Code please? :P
Reply
#6

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?
Reply
#7

I don't got a "OnPlayerUpdate" :P
Reply
#8

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

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.
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)