MoveObject Issue
#1

Basically I made a command so only a certain faction can open a door. Now, the thing is; the doors do not move whatsoever...
pawn Код:
command(door, playerid, params[])
{
    new gate1status;
    new gate2status;
    if(Player[playerid][Group] == 1)
    {
        if(IsPlayerInRangeOfPoint(playerid, 3, 238.8503,117.7204,1003.2188))
        {
            if(gate1status == 0)
            {
                MoveObject(sddoor1, 239.61, 116.06, 1002.21, 0.75, 0.00, 0.00, 91.00);
                MoveObject(sddoor2, 239.56, 119.77, 1002.21, 0.75, 0.00, 0.00, 271.00);
                gate1status = 1;
            }
            if(gate1status == 1)
            {
                MoveObject(sddoor1, 239.61, 116.06, 1002.21, 0.75, 0.00, 0.00, 91.00);
                MoveObject(sddoor2, 239.56, 119.05, 1002.21, 0.75, 0.00, 0.00, 271.00);
                gate1status = 0;
            }
        }
    }
    return 1;
}
I cannot seem to find the issue, I looked at the syntax for this many times...
Reply
#2

Initialize your gatestatus variables with static instead of new, for one. Though I believe the doors DO move. You just don't notice it because there is a logic error in your code: when the gatestatus is 0, the variable is set to 1 and the door opens. However, the next block of code is also executed because that same variable is now set to 1. Thus the doors instantly closes again. Use this for a quick fix:
pawn Код:
else if(gate1status == 1)
Reply
#3

I have edited my script according. I have yet to test it, however it does not matter whether it works or not as I cannot deny that you have completely earned my respect due to your effective time and even more importantly; your explanation. (Fancy way to say good work, you deserve a reputation point. Keep it up.)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)