Repeat moved object?
#5

pawn Код:
new ufo;
pawn Код:
public OnFilterScriptInit()
{
    ufo = CreateObject(13607, -2058.7773, -198.6086, 98.033844, 0.0000, 0.0000, 0.0000);
    MoveObject(ufo, -2058.7773, 1320.0000, 98.033844, 2.5000);
}
This would be a way
pawn Код:
public OnObjectMoved(objectid)
{
    if(objectid == ufo)
    {
        MoveObject(ufo, -2058.7773, -198.6086, 98.033844, 2.5000);
        ufo += MAX_OBJECTS;
    }
    else if(objectid == (ufo - MAX_OBJECTS))
    {
        ufo -= MAX_OBJECTS;
        MoveObject(ufo, -2058.7773, 1320.0000, 98.033844, 2.5000);
    }
}
Or the one you already had
pawn Код:
forward Move();
public Move()
{
    MoveObject(ufo, -2058.7773, 1320.0000, 98.033844, 2.5000);
}
pawn Код:
public OnObjectMoved(objectid)
{
    if(objectid == ufo)
    {
        SetTimer("Move", (MoveObject(ufo, -2058.7773, -198.6086, 98.033844, 2.5000) - 10), false);
        //MoveObject returns the time it will take for the object to move in milliseconds
        //And the - 10 because if it completely moved it will call OnObjectMoved to move again to the same cords
        //So we call the object 10 ms before back (we could do + 10 but then the OnObjectMoved code gets unused executed)
    }
}
Reply


Messages In This Thread
Repeat moved object? - by bajskorv123 - 20.02.2010, 21:45
Re: Repeat moved object? - by Torran - 20.02.2010, 21:47
Re: Repeat moved object? - by bajskorv123 - 20.02.2010, 22:22
Re: Repeat moved object? - by Torran - 21.02.2010, 14:41
Re: Repeat moved object? - by Nero_3D - 21.02.2010, 15:08

Forum Jump:


Users browsing this thread: 1 Guest(s)