Timed Gate
#1

How do I make the second gate open 5 seconds after the first?

pawn Код:
if (strcmp("/opengate", cmdtext, true, 10) == 0)
    {
      MoveObject(Mygate,X,Y,Z,S);
      MoveObject(Mygate1,X,Y,Z,S); // how do I make this one open lets say 5 seconds after the first?

        return 1;
    }
    return 0;
Reply
#2

Can anyone help? / Tell me if this is possible?
Reply
#3

pawn Код:
if (strcmp("/opengate", cmdtext, true, 10) == 0)
    {
        MoveObject(Mygate,X,Y,Z,S);
    SetTimerEx("OGate",5000,0,"s",":P");
        return 1;
    }
    return 0;
}
forward OGate();
public OGate()
{
      MoveObject(Mygate1,X,Y,Z,S);
return 1;
}
Reply
#4

i think he means the first object is open and second is close... so eehm jack place the mygate1 in the public Ogate only.. so not the mygate, the mygate has to be in the cmd /opengate
Reply
#5

Quote:
Originally Posted by niels44
Посмотреть сообщение
i think he means the first object is open and second is close... so eehm jack place the mygate1 in the public Ogate only.. so not the mygate, the mygate has to be in the cmd /opengate
I just fixed that
Reply
#6

ah i see
Reply
#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


Forum Jump:


Users browsing this thread: 1 Guest(s)