SA-MP Forums Archive
Detecting when moving object is touching static GTA objects or vehicle with player inside - 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: Detecting when moving object is touching static GTA objects or vehicle with player inside (/showthread.php?tid=522528)



Detecting when moving object is touching static GTA objects or vehicle with player inside - Jefff - 27.06.2014

How to detect an obstruction encountered by a moving object? vehicles with players or static GTA objects?


Re: Detecting when moving object is touching static GTA objects or vehicle with player inside - Vanter - 28.06.2014

when creating the object
pawn Код:
new OBJ = CreateObject..............
then create a timer for one second, if you don't have one CREATE ONE
then add this in it
pawn Код:
new Float:x, Float:y, Float:z;
new Float:px, Float:py, Float:pz;
GetObjectPos(OBJ, x, y, z);
GetPlayerPos(playerid, px, py, pz);
if( x == px && y == py)
{
     //add what u want to do here..
     //I suggest u stop it soo...
     MoveObject(OBJ, px+5, py+5, pz, 30.0); //+5 depending on object size
     return 1;
}
hope this helps


Re: Detecting when moving object is touching static GTA objects or vehicle with player inside - Jefff - 28.06.2014

Yes i know i can do that but 1 sec is to long for this [ame]http://www.youtube.com/watch?v=YRo4rq6ln7k[/ame] and what about static GTA objects?


Re: Detecting when moving object is touching static GTA objects or vehicle with player inside - Vanter - 28.06.2014

Static GTA Objects, idk..
but you can reduce the timer to milliseconds if you want, but I guess it lags your gamemode..


Re: Detecting when moving object is touching static GTA objects or vehicle with player inside - Jefff - 28.06.2014

That's why I do not want very quick timer for that


Re: Detecting when moving object is touching static GTA objects or vehicle with player inside - Jefff - 28.06.2014

Halo?


Re: Detecting when moving object is touching static GTA objects or vehicle with player inside - AroseKhanNiazi - 28.06.2014

well jefff once i asked the same but you can not do anything about the GTA objects


Re: Detecting when moving object is touching static GTA objects or vehicle with player inside - Jefff - 28.06.2014

Yes you can, i saw on some servers that trick


Re: Detecting when moving object is touching static GTA objects or vehicle with player inside - icra - 28.06.2014

You should use "Peppe" physics include.
This allows you to create invisible "walls", so object can't go over them.
Link:
https://sampforum.blast.hk/showthread.php?tid=446286
Hope it helps


Re: Detecting when moving object is touching static GTA objects or vehicle with player inside - Jefff - 28.06.2014

Looks ok but its huge .inc and timer 20ms :/ i need study this xd and maybe other ideas?