SA-MP Forums Archive
IsPlayerAimingAtVehicle function? - 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: IsPlayerAimingAtVehicle function? (/showthread.php?tid=472015)



IsPlayerAimingAtVehicle function? - kristo - 26.10.2013

I'm currently creating an advanced empty vehicle damage system and i'm almost finished but i'd need a IsPlayerAimingAtVehicle function. To make it more accurate, it should use GetVehicleModelInfo. Could someone create this for me?


Re: IsPlayerAimingAtVehicle function? - kristo - 27.10.2013

Bump.


Re: IsPlayerAimingAtVehicle function? - Konstantinos - 27.10.2013

https://sampforum.blast.hk/showthread.php?tid=140765

Use IsPlayerAimingAt and get the coordinates of the vehicle.


Re: IsPlayerAimingAtVehicle function? - kristo - 27.10.2013

It checks if player is aiming inside a sphere but vehicles (usually ) aren't sphere-shaped and are all different-sized.



This drawing shows, which area should be aimed to get the positive result. My drawing skills are really bad, just like my english.


Re: IsPlayerAimingAtVehicle function? - kristo - 28.10.2013

Bump.


Re: IsPlayerAimingAtVehicle function? - HyDrAtIc - 28.10.2013

Bumping wont help you anyways.

Here:- https://sampwiki.blast.hk/wiki/OnVehicleDamageStatusUpdate


Re: IsPlayerAimingAtVehicle function? - Pottus - 28.10.2013

That is going to be difficult to do because you would need to compensate for the position of the collision box in relation of the angle of the vehicle. Just use a sphere


Re: IsPlayerAimingAtVehicle function? - kristo - 28.10.2013

Quote:
Originally Posted by HyDrAtIc
Посмотреть сообщение
It wouldn't get called because an empty vehicle's damage status doesn't update when it's getting shot at.

I'll test the sphere again.


Re: IsPlayerAimingAtVehicle function? - kristo - 28.10.2013

It isn't possible to make it accurate enough.


Re: IsPlayerAimingAtVehicle function? - Azazelo - 28.10.2013

You may try to do it like this:
(Warning: This is just my mumbling about stuff)

You know size of vehicle box(xyz), position of car is center of box (o).
You know angle of car box in degrees.
You know distance(d) between player and center of car box.
You know angle of player camera so you can calculate exact point(xyz) where player aiming,to be accurate you may use Map Andreas Plugin for z of ground at xy of POV .

Now you have point in 3D space(xyz).This place where you bullet(hit) while pass.
BOX OF CAR: Have center point at car coordinate and half + and - size of Vehicle_Model_Info for each X,Y,Z plane in appropriate angle of car.
Now you must test is this point belong to any of BOX OF CAR(plane).
And if you have a hit else you not.

This is actuate.
http://tutorial.math.lamar.edu/Class.../3DCoords.aspx