Timer example
#1

mind giving me a short stupid script if how timers work? I dont understand a thing about how to use them

Give me a example once you type /healme you wait 1 minute then you get healed.
Reply
#2

For the example you requested SetTimerEx is most suitable..

pawn Код:
#include <a_samp>

forward HealTimer(playerid);

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/healme", cmdtext, true, 10) == 0)
    {
        SetTimerEx("HealTimer", 60000, 0, "d", playerid);
        return 1;
    }
    return 0;
}

public HealTimer(playerid)
{
    SetPlayerHealth(playerid, 100.0);
}
I changed the scenario to show you how to use SetTimer, this time it's a gate close timer. When the player uses the command the gate opens, and 5 seconds later the timer closes it:

pawn Код:
#include <a_samp>
forward GateTimer();
new Gate;

public OnFilterScriptInit()
{
    Gate = CreateObject(976,-1571.597,665.725,6.349, 0.0, 0.0, 90.0);
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/opengate", cmdtext, true, 10) == 0)
    {
        MoveObject(Gate, -1571.597,656.572,6.349, 2.0);
        SetTimer("GateTimer", 5000, 0);
        return 1;
    }
    return 0;
}

public GateTimer()
{
    MoveObject(Gate, -1571.597,665.725,6.349, 2.0);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)