SA-MP Forums Archive
How to set 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to set timer!? (/showthread.php?tid=82002)



How to set timer!? - Moustafa - 15.06.2009

Hey guys, ya know, last time, i asked for the KEY to be pressed by F or something like that.. well..,

Now i want like that, for example:

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys == KEY_SECONDARY_ATTACK )
    {
        if (PlayerToPoint(1, playerid,-2487.4114,-612.5793,132.5592)) // Place he needs to be so the gate can be opened
      {
          MoveObject(gate1, -2487.3696,-611.0781,132.7919); // Gate that will open
        return 1;
      }
I want to set timer after it, as when it passes, the gate closes automaticially.. how do i do that? if you know, please tell me.. thanks!

Coord's of closed gate:

pawn Код:
MoveObject(gate1, 2215.454833,-1147.475585,1025.796875); // Gate that will close after time passes



Re: How to set timer!? - Lewwy - 15.06.2009

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys == KEY_SECONDARY_ATTACK)
    {
        if (PlayerToPoint(1.0, playerid, -2487.4114, -612.5793, 132.5592))
        {
            MoveObject(gate1, -2487.3696, -611.0781, 132.7919); // move the gate to open position.
            SetTimerEx("CloseGate", 5000, false, "i", playerid);
            return 1;
        }
    }
    return 1;
}

// somewhere at the bottom of your script..
forward CloseGate(playerid);
public CloseGate(playerid)
{
    MoveObject(gate1, 2215.454833, -1147.475585, 1025.796875);     
    return 1;
}