MoveObject keeps on going for all eternity - 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: MoveObject keeps on going for all eternity (
/showthread.php?tid=416560)
MoveObject keeps on going for all eternity -
reckst4r - 17.02.2013
pawn Код:
CMD:gate(playerid, params[])
{
if(isnull(params)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /gate [password]");
new string[128];
new iName[24], gate = -1;
GetPlayerName(playerid, iName, 24);
for(new i = 0; i != MAX_GATES; i++ )
if(GateInfo[i][gCreated] == 1)
if(strval(params) == GateInfo[i][gPassword])
{
gate = i; break;
}
if(gate != -1)
{
if(IsPlayerInRangeOfPoint(playerid, 15.0, GateInfo[gate][gX], GateInfo[gate][gY], GateInfo[gate][gZ]))
{
if(GateInfo[gate][gStatus] == GATE_CLOSED)
{
MoveObject(GateInfo[gate][gObject], GateInfo[gate][gXM], GateInfo[gate][gYM], GateInfo[gate][gZM], GateInfo[gate][gSpeed]);
format(string, sizeof(string), "* %s uses their remote control to open the gate.", iName);
ProxDetector(30.0, playerid, string, COLOR_PURPLE);
}
else
{
MoveObject(GateInfo[gate][gObject], GateInfo[gate][gX], GateInfo[gate][gY], GateInfo[gate][gZ], GateInfo[gate][gSpeed]);
format(string, sizeof(string), "* %s uses their remote control to close the gate.", iName);
ProxDetector(30.0, playerid, string, COLOR_PURPLE);
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You are not near any gate!");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "Incorrect password!");
return 1;
}
return 1;
}
The object keeps moving when I use the command, and I've tried placing returns inside the gStatus brackets, and alot of other things, but nothing seems to be fixing it.
Re: MoveObject keeps on going for all eternity -
Backwardsman97 - 17.02.2013
Not sure what you mean by keeps moving but I notice that you never change the gStatus to closed or opened.
pawn Код:
if(GateInfo[gate][gStatus] == GATE_CLOSED)
{
MoveObject(GateInfo[gate][gObject], GateInfo[gate][gXM], GateInfo[gate][gYM], GateInfo[gate][gZM], GateInfo[gate][gSpeed]);
format(string, sizeof(string), "* %s uses their remote control to open the gate.", iName);
ProxDetector(30.0, playerid, string, COLOR_PURPLE);
GateInfo[gate][gStatus] = GATE_OPENED;
}
else
{
MoveObject(GateInfo[gate][gObject], GateInfo[gate][gX], GateInfo[gate][gY], GateInfo[gate][gZ], GateInfo[gate][gSpeed]);
format(string, sizeof(string), "* %s uses their remote control to close the gate.", iName);
ProxDetector(30.0, playerid, string, COLOR_PURPLE);
GateInfo[gate][gStatus] = GATE_CLOSED;
}
Re: MoveObject keeps on going for all eternity -
reckst4r - 17.02.2013
Well, by keep moving I mean that it doesn't stop when it's supposed to stop. It never stops moving
Also, "GateInfo[gate][gStatus] = GATE_OPEN;" doesn't change anything.