What am I doing wrong :O?
#1

Got this:

pawn Код:
forward MoveLift();
public MoveLift()
{
    if(IsUp == 1)
    {
        for( new i = 0; i < sizeof(lift); i ++ )
        {
            new Float:x,Float:y,Float:z;
            GetDynamicObjectPos(i,x,y,z);
            MoveDynamicObject(i, x,y, z-37, 2);
        }

        IsUp = 0;
    }
    else if(IsUp == 0)
    {
        for( new i = 0; i < sizeof(lift); i ++ )
        {
           new Float:x,Float:y,Float:z;
           GetDynamicObjectPos(lift[i],x,y,z);
           MoveDynamicObject(lift[i], x,y, z+37, 2);
       }

        IsUp = 1;
    }
}
Problem is, it's going always +37, and not -37. So the lift is going up all the time, and not going down. I want that one time it goes down, other time up.
Reply
#2

IsUp = 0; makes your code always execute the "else if(IsUp==0)" block. (i think)
Reply
#3

Quote:
Originally Posted by iggy1
Посмотреть сообщение
IsUp = 0; makes your code always execute the "else if(IsUp==0)" block. (i think)
So you mean this is correct:
pawn Код:
forward MoveLift();
public MoveLift()
{
    if(IsUp == 1)
    {
        for( new i = 0; i < sizeof(lift); i ++ )
        {
            new Float:x,Float:y,Float:z;
            GetDynamicObjectPos(i,x,y,z);
            MoveDynamicObject(i, x,y, z-37, 2);
        }

        return IsUp = 0;
    }
   
    if(IsUp == 0)
    {
        for( new i = 0; i < sizeof(lift); i ++ )
        {
            new Float:x,Float:y,Float:z;
            GetDynamicObjectPos(lift[i],x,y,z);
            MoveDynamicObject(lift[i], x,y, z+37, 2);
        }

        return IsUp = 1;
    }
    return 1;
}
Didn't work btw :<
Reply
#4

try this
pawn Код:
public MoveLift()
{
    if(IsUp == 1)
    {
        for( new i = 0; i < sizeof(lift); i ++ )
        {
            new Float:x,Float:y,Float:z;
            GetDynamicObjectPos(i,x,y,z);
            MoveDynamicObject(i, x,y, z-37, 2);
        }
        IsUp = 0;
        return 1;//to stop further execution
    }
    else if(IsUp == 0)
    {
        for( new i = 0; i < sizeof(lift); i ++ )
        {
           new Float:x,Float:y,Float:z;
           GetDynamicObjectPos(lift[i],x,y,z);
           MoveDynamicObject(lift[i], x,y, z+37, 2);
       }
       IsUp = 1;
       return 1;
    }
Reply
#5

Didn't work iggy
Reply
#6

Sorry thought i spotted your problem.
Reply
#7

FIXED -.-
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)