Trying OnObjectMoved( to make one object move to different locations
#1

Hello,

I'm trying to make one object move to more locations then just one ( as seen in samp wiki )
when i try..it moves direct to the last point and keeps forgetting the other possitions.
I got no errors
maybe its just a } or { but i cant find it, please help

( o ye..i did float xk yk zk and xm ym zm )



Code:
public OnObjectMoved(objectid)
{

	GetObjectPos(obj, xk , yk , zk );

	if (obj == xk, yk, zk)
	{
	MoveObject(obj,273.3177,1888.3771,17.6406, 5.00);
	}




	GetObjectPos(obj, xl , yl , zl );

	if (obj == xl, yl, zl)
	{
	MoveObject(obj,264.5370,1888.0536,17.4770, 5.00);
	}
	

	

	GetObjectPos(obj, xm , ym , zm );

	if (obj == xm, ym, zm)
	{
	MoveObject(obj,264.3640,1879.8628,17.6406, 5.00);
	}
Reply
#2

It's because the code doesn't wait for your object to move to the first position, then second, etc.. It just executes. Try putting the final coords of each move into the if statement, rather then using GetObjectPosition
Reply
#3

You mean not using getobjectpos at all ?
How can i use 'if' then? can you please give an example ?
Reply
#4

This is just your code, but slightly edied
pawn Code:
public OnObjectMoved(objectid)
{

    if (obj == something happens)
    {
    MoveObject(obj,273.3177,1888.3771,17.6406, 5.00);
    }




    GetObjectPos(obj, xl , yl , zl );

    if (xl==273.3177 && yl == 1888.3771 && zl == 17.6406)
    {
    MoveObject(obj,264.5370,1888.0536,17.4770, 5.00);
    }
   

    ////same here

    GetObjectPos(obj, xm , ym , zm );

    if (264.5370,1888.0536,17.4770)
    {
    MoveObject(obj,264.3640,1879.8628,17.6406, 5.00);
    }
Reply
#5

when is exactly the callback called. On start of movement or after the movement is done?
Reply
#6

It's called when the object stops moving
Reply
#7

umm so you need it like this...
pawn Code:
// on top
new object;
//on init
object = CreateObject(...);
//on moved
if(objectid==object)
{
// do something here with the object
}
Reply
#8

LOL i was just wondering what to do with the 'if' (something happens) part
now it works!

Thanks very much both of you . I learned alot today
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)