Timed Gate
#7

Why not setup a bool?

pawn Код:
new bool:IsGateOpen = false; // A new bool to check if the gate is open.

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/gate", cmdtext, true, 10) == 0)
    {
        if(IsGateOpen == false) // If the gate is closed then continue.
        {
            MoveObject(objectid,Float:x,Float:y,Float:z,Float:Speed); // Moves Object.
            IsGateOpen = true; // Sets the bool to true, so that the gate is open.
            SetTimer(GateTimer,3000,false); // Sets the timer of 3 seconds.
        }
        else if(IsGateOpen == true) return 1; // If the gate is open, then it won't process the command.
    }
    return 0;
}
forward GateTimer(); // When the 3 seconds is up, it will run this code.
{
    MoveObject(objectid,Float:x,Float:y,Float:z,Float:Speed); // Moves Object back to its original position
    IsGateOpen = false; // Sets the bool to false, and that the gate is now closed.
    return 1;
}
Reply


Messages In This Thread
Timed Gate - by Jack- - 01.03.2012, 17:22
Re: Timed Gate - by Jack- - 01.03.2012, 17:56
Re: Timed Gate - by Unknownich - 01.03.2012, 18:07
Re: Timed Gate - by niels44 - 01.03.2012, 18:13
Re: Timed Gate - by Unknownich - 01.03.2012, 18:14
Re: Timed Gate - by niels44 - 01.03.2012, 18:41
Re: Timed Gate - by Walsh - 01.03.2012, 22:34

Forum Jump:


Users browsing this thread: 1 Guest(s)