How to make the gate close? -
Fredden1993 - 12.12.2011
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);
Re: How to make the gate close? -
N0FeaR - 12.12.2011
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;
Re: How to make the gate close? -
Fredden1993 - 12.12.2011
Hm, interesting, thanks chap. ^^
Re: How to make the gate close? -
Phanto90 - 12.12.2011
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;
}
Re: How to make the gate close? -
PlayHard - 12.12.2011
Oh, thanks a lot, I just learned something new ^^.