Movable Gates?
#2

First part:
Код:
public OnGameModeInit()
{
	new iGate[2],iGatePos; //Variables.
	iGate[0] = CreateObject(gatemodel,X,Y,Z,rX,rY,rZ,10) //Gate 1
	iGate[1] = CreateObject(gatemodel,X2,Y2,Z2,rX2,rY2,rZ2,10) //Gate 2
	iGatePos = 0; //Gate is closed.
	return 1;
}
Second part:
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/open", cmdtext, true, 10) == 0) //Open command
	{
		if(iGatePos == 0) { //Checking if the gate is actually closed.
		    MoveObject(iGate[0],toX,toY,toZ,2); //Moving
		    MoveObject(iGate[1],toX2,toY2,toZ2,2);
			SendClientMessage(playerid,-1,"The gate has been opened.");
			iGatePos = 1; //Gate is opened.
		} else {
		    SendClientMessage(playerid,-1,"The gate is already opened!");
		}
		return 1;
	}
	if (strcmp("/close", cmdtext, true, 10) == 0) //Close command
	{
		if(iGatePos == 1) { //Checking if the gate is actually closed.
		    MoveObject(iGate[0],X,Y,Z,2); //Moving
		    MoveObject(iGate[1],X2,Y2,Z2,2);
			SendClientMessage(playerid,-1,"The gate has been closed.");
			iGatePos = 0; //Gate is closed.
		} else {
		    SendClientMessage(playerid,-1,"The gate is already closed!");
		}
		return 1;
	}
	return 0;
}
Make sure to replace the X,Y,Z and stuff with coordinates of your gate.
Reply


Messages In This Thread
Movable Gates? - by Gooday - 27.12.2011, 19:56
Re: Movable Gates? - by Seven_of_Nine - 27.12.2011, 20:04
Re: Movable Gates? - by Gooday - 27.12.2011, 20:34
Re: Movable Gates? - by kizla - 27.12.2011, 20:39
Re: Movable Gates? - by Seven_of_Nine - 27.12.2011, 20:40
Re: Movable Gates? - by Gooday - 27.12.2011, 20:46

Forum Jump:


Users browsing this thread: 1 Guest(s)