Movable Gates?
#1

How i can make a command who move the gates from a pos to another?
like /open and a gate open
and /close....
I cant do by watching tutorials!
Reply
#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
#3

please can u make on example with ma coords (sorry i am a noob at script :P )

gate open : CreateObject(11416, 664.70001220703, 1824, 11, 0, 0, 349.99694824219);

gate closed: CreateObject(11416, 664.79998779297, 1824, 7.0999999046326, 0, 0, 349.99145507813);


Thanks i'll give u rep!
Reply
#4

read this

https://sampwiki.blast.hk/wiki/MoveObject
Reply
#5

Only one gate?
pawn Код:
public OnGameModeInit()
{
    new iGate,iGatePos; //Variables.
    iGate = CreateObject(11416,664.79998779297,1824,7.0999999046326,0,0,349.99145507813,10);
    iGatePos = 0; //Gate is closed.
    return 1;
}

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,664.70001220703,1824,11,2,0,0,349.99694824219); //Moving
            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,664.79998779297,1824,7.0999999046326,2,0,0,349.99145507813); //Moving
            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;
}
Then there you go.

EDIT: Corrected.
Reply
#6

Quote:

C:\Users\Luca\Desktop\base.pwn(1185) : error 001: expected token: ";", but found "-identifier-"
C:\Users\Luca\Desktop\base.pwn(2100) : error 055: start of function body without function header
C:\Users\Luca\Desktop\base.pwn(2101) : error 010: invalid function or declaration
C:\Users\Luca\Desktop\base.pwn(2103) : error 010: invalid function or declaration
C:\Users\Luca\Desktop\base.pwn(2107) : error 010: invalid function or declaration
C:\Users\Luca\Desktop\base.pwn(2110) : error 010: invalid function or declaration
C:\Users\Luca\Desktop\base.pwn(2112) : error 010: invalid function or declaration
C:\Users\Luca\Desktop\base.pwn(2114) : error 010: invalid function or declaration
C:\Users\Luca\Desktop\base.pwn(211 : error 010: invalid function or declaration
C:\Users\Luca\Desktop\base.pwn(2121) : error 010: invalid function or declaration
C:\Users\Luca\Desktop\base.pwn(2123) : error 010: invalid function or declaration
C:\Users\Luca\Desktop\base.pwn(1185) : warning 204: symbol is assigned a value that is never used: "iGate"
C:\Users\Luca\Desktop\base.pwn(1185) : warning 204: symbol is assigned a value that is never used: "iGatePos"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


11 Errors.

ERRORS
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)