automatic movement of an object - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: automatic movement of an object (
/showthread.php?tid=116113)
automatic movement of an object -
worms0 - 27.12.2009

Please help people, have long been trying to create an object that would, without a team, moving from one point to another, and then moved back to the beginning and repeat the cycle. Please write one example of who can ....
Re: automatic movement of an object -
Kurence - 27.12.2009
For example set a timer for some time..
or check the positions of object and end position using some function for example GetDistanceBetweenPoints or ST like that..
Re: automatic movement of an object -
worms0 - 27.12.2009
as an example can be? I'm all mixed up with them ....
Re: automatic movement of an object -
Kurence - 27.12.2009
pawn Код:
MoveObject(objectid, X, Y, Z, speed);
SetTimerEx("CheckTimer", 250, true, "ifff", objectid, X, Y, Z);
and timer
pawn Код:
public CheckTimer(objectid, Float:X, Float:Y, Float:Z)
{
new ox, oy, oz; //they are all float
GetObjectPos(objectid, ox ,oy, oz);
if(GetDistanceBetweenPoints(X, Y, Z, ox, oy, oz) < 4.0) MoveObject(objectid, otherX, otherY, otherZ
}
or ST like that
Re: automatic movement of an object -
Nero_3D - 27.12.2009
you dont need a timer for that
pawn Код:
//Somewhere you want to start the movement
MoveObject(THE_OBJECTID, Destination_X, Destination_Y, Destination_Z, speed);
pawn Код:
public OnObjectMoved(objectid)
{
static bool:O1_Position;
if((O1_Position = !O1_Position))
MoveObject(objectid, Start_X, Start_Y, Start_Z, speed);
else MoveObject(objectid, Destination_X, Destination_Y, Destination_Z, speed);
}
thats all
Re: automatic movement of an object -
Kurence - 27.12.2009
But for me OnObjectMoved didnt work. So I have to use timer. :P