Trying OnObjectMoved( to make one object move to different locations -
boelie - 29.06.2009
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);
}
Re: Trying OnObjectMoved( to make one object move to different locations -
dice7 - 29.06.2009
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
Re: Trying OnObjectMoved( to make one object move to different locations -
boelie - 30.06.2009
You mean not using getobjectpos at all ?
How can i use 'if' then? can you please give an example ?
Re: Trying OnObjectMoved( to make one object move to different locations -
dice7 - 30.06.2009
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);
}
Re: Trying OnObjectMoved( to make one object move to different locations -
Ignas1337 - 30.06.2009
when is exactly the callback called. On start of movement or after the movement is done?
Re: Trying OnObjectMoved( to make one object move to different locations -
dice7 - 30.06.2009
It's called when the object stops moving
Re: Trying OnObjectMoved( to make one object move to different locations -
Ignas1337 - 30.06.2009
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
}
Re: Trying OnObjectMoved( to make one object move to different locations -
boelie - 30.06.2009
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