I need help - 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: I need help (
/showthread.php?tid=531160)
I need help -
JM_Millers - 11.08.2014
How can I get that the car is on the ground.
There is a function in MTA (isVehicleOnGround), but I didn't find anything like that in SA-MP.
I hope you'll help me.
Re: I need help -
SKAzini - 11.08.2014
Get the highest coordinate for the vehicle position by using
MapAndreas, if the current vehicle position equals (maybe use like .5 offset if they're not the same) the MapAndreas Z value, it's on the ground.
pawn Code:
public OnGameModeInit()
{
MapAndreas_Init(MAP_ANDREAS_MODE_FULL);
}
forward IsVehicleOnGround(vehicleid);
public IsVehicleOnGround(vehicleid)
{
new Float:vehpos[3];
if(!GetVehiclePos(vehicleid, vehpos[0], vehpos[1], vehpos[2])) return 0;
new Float:groundpos;
MapAndreas_FindAverageZ(vehpos[0], vehpos[1], groundpos);
if(vehpos[2] >= groundpos && vehpos[2] <= groundpos+0.2) return 1;
return 1;
}
Re: I need help -
JM_Millers - 11.08.2014
Quote:
Originally Posted by SKAzini
Get the highest coordinate for the vehicle position by using MapAndreas, if the current vehicle position equals (maybe use like .5 offset if they're not the same) the MapAndreas Z value, it's on the ground.
[/pawn]
|
Thanks.
But is there another way to get it?
Re: I need help -
JM_Millers - 12.08.2014
up .
Re: I need help -
JM_Millers - 14.08.2014
up .
Re: I need help -
Vince - 14.08.2014
If a car isn't on the ground it is falling. So in order to detect that falling movement, you use GetVehicleVelocity. The displacement over the z (up-down) axis, more specifically. For more accurate results you could also mix in GetVehicleRotationQuat. Convert it to Euler and then compare pitch and roll.