27.04.2013, 16:41
How can I create a command to open and close a gate?
// You should have some variable which creates the gate. I have given a sample as Gate1
new Gate1 = CreateObject(objectid, X, Y, Z); // Variable Gate1 has given value of creating a gate.
if (strcmp("/opengate", cmdtext, true, 10) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 15.0, X, Y, Z)) // the range till where player can use this command.
{
MoveObject(Gate1, X, Y, Z, Speed); // Move the object to where it looks it's opened.
SendClientMessage(playerid, 0xFAFAFAAA, "Gate opened");
return 1;
}
}
if (strcmp("/closegate", cmdtext, true, 10) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, X, Y, Z))
{
MoveObject(Gate1,X, Y, Z, Speed); //You will need to paste same coords as you make for Gate1 value.
SendClientMessage(playerid, COLOR_GREEN, "Gate closed");
return 1;
}
return 1;
}