Only "executed" when adding +/-?
#1

I've made this command here
pawn Код:
CMD:gate(playerid, params[])
{
        if(isnull(params)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /gate [pass]");
 
        for(new i = 0; i < sizeof(GateInfo); i++)
        {
            if(IsPlayerInRangeOfPoint(playerid, 15.0, GateInfo[i][gPosX], GateInfo[i][gPosY], GateInfo[i][gPosZ]))
            {
                if(strval(params) == GateInfo[i][gPassword])
                {
                        if(GateInfo[i][gStatus] == 0)
                        {
                        MoveObject(GateInfo[i][gObject], GateInfo[i][gPosXM], GateInfo[i][gPosYM], GateInfo[i][gPosZM], GateInfo[i][gSpeed]);
                        GateInfo[i][gStatus] = 1;
                                }
                                else
                                {
                                    MoveObject(GateInfo[i][gObject], GateInfo[i][gPosX], GateInfo[i][gPosY], GateInfo[i][gPosZ], GateInfo[i][gSpeed]);
                                GateInfo[i][gStatus] = 0;
                                }
                        }
                        else return SendClientMessage(playerid, COLOR_GREY, "Incorrect password.");
                }
        }
        return 1;
}
It works fine the first time I use it (first time opens it), but the second time it does nothing. If I add for example +1 to GateInfo[i][gPosZ], it goes 1 up, the same with gStatus.
Reply
#2

Because after you Open the gate you must close it too, just make a timer..
Reply
#3

The else statement is supposed to close it, also I don't see how a timer would help
Reply
#4

If someone would take the time to help me, it'd be really really great!
Reply
#5

Becouse ur loop runs in the sizeof GateInfo
Either break the loop once found the nearest point, or do the check outside
Reply
#6

OK, I tried breaking it, and still doesn't work.
pawn Код:
CMD:gate(playerid, params[])
{
    if(isnull(params)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /gate [password]");

    new gate = -1;
    for(new i = 0; i < sizeof(GateInfo); i++)
    if(strval(params) == GateInfo[i][gPassword])
    {
        gate = i; break;
    }
    if(gate != -1)
    {
        if(IsPlayerInRangeOfPoint(playerid, 15.0, GateInfo[gate][gPosX], GateInfo[gate][gPosY], GateInfo[gate][gPosZ]))
        {
                if(GateInfo[gate][gStatus] == 0)
                {
                    MoveObject(GateInfo[gate][gObject], GateInfo[gate][gPosXM], GateInfo[gate][gPosYM], GateInfo[gate][gPosZM], GateInfo[gate][gSpeed]);
                    GateInfo[gate][gStatus] = 1;
                }
                else
                {
                    MoveObject(GateInfo[gate][gObject], GateInfo[gate][gPosX], GateInfo[gate][gPosY], GateInfo[gate][gPosZ], GateInfo[gate][gSpeed]);
                    GateInfo[gate][gStatus] = 0;
                }
        }
    }
    else return SendClientMessage(playerid, COLOR_GREY, "Incorrect password.");
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)