PDA

View Full Version : I need help


JM_Millers
11/08/2014, 11:01 AM
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.

SKAzini
11/08/2014, 12:25 PM
Get the highest coordinate for the vehicle position by using MapAndreas (http://forum.sa-mp.com/showthread.php?t=275492), 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.


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;
}

JM_Millers
11/08/2014, 05:03 PM
Get the highest coordinate for the vehicle position by using MapAndreas (http://forum.sa-mp.com/showthread.php?t=275492), 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?

JM_Millers
12/08/2014, 10:52 AM
up .

JM_Millers
14/08/2014, 09:24 AM
up .

Vince
14/08/2014, 09:41 AM
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.