[PROBLEM] Gates Script Help
#1

Hello, I need help with a gate script.. it compiles fine, no error... but when I go ingame and type the command nothing happens!
What's wrong with it?

pawn Код:
if(strcmp(cmd, "/go", true) == 0)
    {
            if(PlayerInfo[playerid][pFaction] != 255 && DynamicFactions[PlayerInfo[playerid][pFaction]][fType] == 1)
            {
                    if(IsPlayerInRangeOfPoint(playerid, 15,1544.6055,-1627.2274,13.3828))
                    {
                        if(lspdgate1 == 0)
                        {
                            MoveObject(lspdgate1,1544.5834960938, -1626.9783935547, 11.065950393677,0.8);
                            SendClientMessage(playerid,COLOR_LIGHTYELLOW2, "[GATE:] Gate is opening!");
                            lspdgate1 = 1;
                        }
                        else if(lspdgate1 == 1)
                        {
                            MoveObject(lspdgate1,1544.5834960938, -1626.9783935547, 13.051549911499,0.8);
                            SendClientMessage(playerid,COLOR_LIGHTYELLOW2, "[GATE:] Gate is closing!");
                            lspdgate1 = 0;
                        }
                    }
                    else if(IsPlayerInRangeOfPoint(playerid, 15,1588.2606,-1637.9075,13.4260))
                    {
                        if(lspdgate2 == 0)
                        {
                            MoveObject(lspdgate2,1544.5834960938, -1626.9783935547, 11.065950393677,0.8);
                            SendClientMessage(playerid,COLOR_LIGHTYELLOW2, "[GATE:] Gate is opening!");
                            lspdgate2 = 1;
                        }
                        else if(lspdgate2 == 1)
                        {
                            MoveObject(lspdgate2,1544.5834960938, -1626.9783935547, 13.051549911499,0.8);
                            SendClientMessage(playerid,COLOR_LIGHTYELLOW2, "[GATE:] Gate is closing!");
                            lspdgate2 = 0;
                        }
                    }
                    else
                    {
                        SendClientMessage(playerid,COLOR_LIGHTYELLOW2, "[ERROR:] You are not near a gate!");
                    }
            }
            else
            {
                SendClientMessage(playerid,COLOR_LIGHTYELLOW2, "[ERROR:] You are not a member of the required faction/type.");
            }
            return 1;
    }
Thanks..
Reply
#2

Well your code doesn't make any sense, you're moving "lspdgate1" variable, which contains either 1 or 0 by the looks of it, and not the actual object ID of the gate, so the script is moving object ID 1 or 0 depending on what state it's in. You need to store the ID of the object, and move that, for example:

pawn Код:
new gate1ID = CreateObject(blabla);
Then in the command you would use that as the objectID

pawn Код:
MoveObject(gate1ID,......);
Hope that example helps you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)