SA-MP Forums Archive
Automatically moving 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)
+--- Thread: Automatically moving object (/showthread.php?tid=363014)



Automatically moving object - P<3TS - 26.07.2012

how can i make a object moving up and down continuosly without anyones presence or using cmds?
It should move randomly.
How to script? anyone plz help


Re: Automatically moving object - Matz - 26.07.2012

Use general timers.


Re: Automatically moving object - Alexis1999 - 26.07.2012

Do you want them to move up once a player is near them?

Here's a code so when you approach the gate it goes up so you can pass.

pawn Код:
new object; // Save here your object

public OnPlayerUpdate(playerid)
{

if(IsPlayerInRangeOfPoint(playerid, 2.0, object)
{
MoveObject(object, /*coordinates*/); // Coordinates for gate UP
}
else
{
MoveObject(object, /*coordinates*/); // Coordinates for gate DOWN
}

}



Re: Automatically moving object - P<3TS - 26.07.2012

Not like that as i told above i want it to move the objects without anyone's interference.Like moving up and down continuously.


Re: Automatically moving object - Stigg - 26.07.2012

Quote:
Originally Posted by P<3TS
Посмотреть сообщение
Not like that as i told above i want it to move the objects without anyone's interference.Like moving up and down continuously.
https://sampwiki.blast.hk/wiki/SetTimer
https://sampwiki.blast.hk/wiki/MoveObject


Re: Automatically moving object - P<3TS - 26.07.2012

But i dont know how to code that
can you show me an example code so that it is easy to study


Re: Automatically moving object - Vince - 26.07.2012

pawn Код:
// Top
new
    theObject;

// Gamemode Init
theObject = CreateObject(...);
MoveObject(theObject, ...);

// Anywhere else
forward @MoveObject(objectid, Float:X, Float:Y, Float:Z, Float:Speed);
@MoveObject(objectid, Float:X, Float:Y, Float:Z, Float:Speed) return MoveObject(objectid, X, Y, Z, Speed);

public OnObjectMoved(objectid)
{
    new rand = 1000 * random(10); // how many seconds between moving? (10)
    SetTimerEx("@MoveObject", rand, 0, "dffff", objectid, /* insert x, y, z */, 3.0);
    return 1;
}



Re: Automatically moving object - P<3TS - 26.07.2012

Vince i did something like you said

i want to move this object up and down
pawn Код:
CreateObject(3865, -2712.88, 583.54, 16.30,   0.00, 0.00, 270.01); //down

CreateObject(3865, -2712.88, 583.54, 34.95,   0.00, 0.00, 270.01);//up
But it is showing errors and all, can you please set those cords in the code which you given me?


Re: Automatically moving object - P<3TS - 26.07.2012

help please


Re: Automatically moving object - P<3TS - 27.07.2012

Anyone?