How to make the gate close?
#1

How do I make this gate close by using the same command? For example, I walk up to the gate, I type /gate and it will open, when I use the /gate command again it should close.

pawn Код:
if(strcmp(cmd, "/gate", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(gPlayerLogged[playerid] == 0)
            {
                SendClientMessage(playerid, COLOR_GREY, "   You are not logged in yet.");
                return 1;
            }
            MoveObject(pdgate, 2338.68, 2450.26, 8.33, 2.00);
            PlayerPlaySound(playerid, 1153, 0.0, 0.0, 0.0);
            return 1;
        }
        return 1;
    }
Here is the code for the closed gate:

pawn Код:
pdgate = CreateObject(971, 2335.14, 2444.29, 8.33,   0.00, 0.00, 60.44);
Reply
#2

here ec that command i make

Код:
    }
	if(!strcmp(cmdtext, "/impound", true)) // By N0FeaR
	{
  		if(IsACop(playerid) || PlayerInfo[playerid][pAdmin] >= 6)
	    {
	        if(IsPlayerInRangeOfPoint(playerid, 100,-137.6803, 1137.0013, 20.4000))
			{
			    if(chak1 == 0)
			    {
		      		MoveDynamicObject(chakgate1, -137.6803, 1137.0013, 20.4000, 1.7500);
		      		SendClientMessage(playerid, COLOR_BLUE,"Gate is open");
		      		GetPlayerName(playerid, sendername, sizeof(sendername));
		      		format(string, sizeof(string), "* %s takes his/her remote control and opens the Gate.", sendername);
		      		ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
		      		chak1 = 1;
				}
				else
				{
		      		MoveDynamicObject(chakgate1, -145.9000,1137.2000,20.4000, 3.0000);
		      		SendClientMessage(playerid, COLOR_BLUE,"Gate is closed");
		      		GetPlayerName(playerid, sendername, sizeof(sendername));
		      		format(string, sizeof(string), "* %s takes his/her remote control and closes the Gate.", sendername);
		      		ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
		      		chak1 = 0;
		      		
				}
			}
		}
		return 1;
Reply
#3

Hm, interesting, thanks chap. ^^
Reply
#4

Don't follow that, just copy & paste. Useless.
Do as follow instead:

Create a global variable.
Код:
new bool:gate_state;
Код:
if(strcmp(cmd, "/gate", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(gPlayerLogged[playerid] == 0)
            {
                SendClientMessage(playerid, COLOR_GREY, "   You are not logged in yet.");
                return 1;
            }
            switch(gate_state)
            {
            case false:MoveObject(pdgate, 2338.68, 2450.26, 8.33, 2.00), gate_state=true;
            case true:MoveObject(pdgate, 2335.14, 2444.29, 8.33, 2.00), gate_state=false;
            }
            PlayerPlaySound(playerid, 1153, 0.0, 0.0, 0.0);
            return 1;
        }
        return 1;
    }
Reply
#5

Oh, thanks a lot, I just learned something new ^^.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)