CMD:opengate(playerid, params[])
{
MoveObject(gate, -1538.53125, 679.52631, 3.31538, 2.0);
SendClientMessage(playerid, COLOR_YELLOW, "Gate is Open.");
return 1;
}
CMD:closegate(playerid, params[])
{
MoveObject(gate, -1538.53125, 679.52631, 8.99330, 2.0);
SendClientMessage(playerid, COLOR_YELLOW, "Gate is Closed.");
return 1;
}
Use a boolean, and set it to true when opening the gate, and false when closing it.
Thereby you can use a switch to detect if it's set to false(closed), you should open the gate, and if it's set to true(opened), you should close the gate. |
if(GateStatus[objectid] == true)
{
// code
}
else
{
// code
}
new Gate[MAX_PLAYERS]; CMD:gate(playerid, params[]) { if(Gate[playerid]==0) { MoveObject(gate, -1538.53125, 679.52631, 3.31538, 2.0); SendClientMessage(playerid, COLOR_YELLOW, "Gate is Open."); Gate[playerid]=1; return 1; } else if(Gate[playerid]==1) { MoveObject(gate, -1538.53125, 679.52631, 8.99330, 2.0); SendClientMessage(playerid, COLOR_YELLOW, "Gate is Closed."); Gate[playerid]=0; return 1; } return 1; }
Код:
new Gate[MAX_PLAYERS]; CMD:gate(playerid, params[]) { if(Gate[playerid]==0) { MoveObject(gate, -1538.53125, 679.52631, 3.31538, 2.0); SendClientMessage(playerid, COLOR_YELLOW, "Gate is Open."); Gate[playerid]=1; return 1; } else if(Gate[playerid]==1) { MoveObject(gate, -1538.53125, 679.52631, 8.99330, 2.0); SendClientMessage(playerid, COLOR_YELLOW, "Gate is Closed."); Gate[playerid]=0; return 1; } return 1; } |