detecting if a vehicle is infront of a vehicle? - 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: detecting if a vehicle is infront of a vehicle? (
/showthread.php?tid=259484)
detecting if a vehicle is infront of a vehicle? -
Donya - 04.06.2011
pawn Код:
new cv = GetClosestVehicle(playerid, 8.0);
if(cv == INVALID_VEHICLE_ID) return 1;
new Float:x, Float:y, Float:z;
GetVehiclePos(id, x, y, z);
SendClientMessageFormatted(playerid, -1, "x: %f - y: %f", x, y);
GetXYInFrontOfVehicle(id, x, y, 4.0);
SendClientMessageFormatted(playerid, -1, "after - x: %f - y: %f", x, y);
if(GetVehicleDistanceToPoint(cv, x, y, z) < 4.0)
{
new Float:Health;
GetVehicleHealth(cv, Health);
SetVehicleHealth(cv, Health - 50.0);
}
i tried that, it doesn't really work good.
got any ideas?
Re: detecting if a vehicle is infront of a vehicle? -
Gamer_Z - 04.06.2011
your code should work, can you debug it with printf? (for us, the sa-mp users of course and yourself :P)
tip: try to print as many variables as possible then check if they are correct or not.
Also are you sure your functions work correctly?
Re: detecting if a vehicle is infront of a vehicle? -
Donya - 04.06.2011
yes but, i can't have health being lost in this case.
it would be even accurate if i could get getobjectpos to work after attachobjecttovehicle
[URL=http://imageshack.us/photo/my-images/402/samp041j.png/]