SA-MP Forums Archive
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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Moving object (/showthread.php?tid=138029)



Moving object - Onyx09 - 31.03.2010

well just a question to see wich is the best and eaasiest way to make thos a moving object
lets say i created a object and i want this object to allways [fly|move] around and get the closest player to it
for example a shark object that will float at certaint speed and get the closest player to it?
i havent done anything like this but might tomorrow or soon so yeah any tips or ways to do it?


Re: Moving object - V1ceC1ty - 31.03.2010

Sorry for what looks like bad indentation but basically, this is how to do it.
Meh actually its not that bad.

pawn Код:
new object;
public OnGameModeInit()
{
  SetTimer("ObjectCheck", 500, true);
  object = CreateObject(3092, -1118.052368, -978.442566, 129.008102, 0.0000, 0.0000, 282.8144);
}

forward ObjectCheck();
public ObjectCheck()
{
  new Float:x, Float:y, Float:z;
    GetObjectPos(object, x, y, z);
    for(new i=0; i<MAX_PLAYERS; i++)
    {
      if(IsPlayerInRangeOfPoint(i, 5, x, y, z))
      {
        new Float:a, Float:b, Float:c;
        GetPlayerPos(i, a, b, c);
        MoveObject(object, a, b, c, 2.0);

      }
    }
}



Re: Moving object - Onyx09 - 31.03.2010

thanks yeah i thouhgt something like this will work and can you help me on how to set a camera in spectating mod behind this object?
i dont have idea about this one tried and failed lol