MoveObject keeps on going for all eternity
#1

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.
Reply
#2

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;
}
Reply
#3

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)