Moving gates not closing! - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Moving gates not closing! (
/showthread.php?tid=382280)
Moving gates not closing! -
NewerthRoleplay - 02.10.2012
Hey I'm creating moving gates for my LSPD faction and while it opens the gate properly, it does not close. To test whether or not it is working I added a client message in the code to close the gate however this does not appear in chat after the timer is finished here is the "gate" command:
pawn Код:
CMD:gate(playerid, params[])
{
if(IsPlayerInRangeOfPoint(playerid, 5.0, 1540.59, -1627.57, 14.95))
{
if(PlayerInfo[playerid][Faction] == 1)
{
if(GateOpen == 0)
{
MoveObject(LSPDGate, 1540.59, -1607.57, 14.95, 2.0);
GateOpen = 1;
SetTimerEx("gateclose",10000,false,"i",playerid);
}
return 1;
}
else
{
SendClientMessage(playerid, COLOR_LIGHTRED, "You are not a member of the LSPD.");
}
}
return 1;
}
And here is the timer:
pawn Код:
public gateclose(playerid)
{
if(IsPlayerInRangeOfPoint(playerid, 5.0, 1540.59, -1627.57, 14.95))
{
MoveObject(LSPDGate, 1540.59, -1627.57, 14.95, 2.0);
SendClientMessage(playerid, COLOR_LIGHTGREEN, "The gate is now closing!");
GateOpen = 0;
}
return 1;
}
Re: Moving gates not closing! -
CmZxC - 02.10.2012
SetTimerEx("gateclose",10000,false,"i",playerid); to
SetTimer("gateclose",10000,false);
pawn Код:
public gateclose(playerid)
{
MoveObject(LSPDGate, 1540.59, -1627.57, 14.95, 2.0);
GateOpen = 0;
}
If you want to send a message to nearby players, you can still do this after GateOpen = 0;
pawn Код:
for(new i=0;i<GetMaxPlayers();i++)
{
if(IsPlayerInRangeOfPoint(i, 5.0, 1540.59, -1627.57, 14.95))
{
SendClientMessage(i, COLOR_LIGHTGREEN, "The gate is now closing!");
}
}
Re: Moving gates not closing! -
NewerthRoleplay - 02.10.2012
I'll give it a try and I'll tell you what happens