SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 11/08/2014, 11:01 AM   #1
JM_Millers
Big Clucker
 
JM_Millers's Avatar
 
Join Date: Feb 2012
Posts: 190
Reputation: 28
Default I need help

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.
JM_Millers is offline   Reply With Quote
Old 11/08/2014, 12:25 PM   #2
SKAzini
Huge Clucker
 
SKAzini's Avatar
 
Join Date: Jun 2012
Posts: 376
Reputation: 17
Default Re: I need help

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;
}
SKAzini is offline   Reply With Quote
Old 11/08/2014, 05:03 PM   #3
JM_Millers
Big Clucker
 
JM_Millers's Avatar
 
Join Date: Feb 2012
Posts: 190
Reputation: 28
Default Re: I need help

Quote:
Originally Posted by SKAzini View Post
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?
JM_Millers is offline   Reply With Quote
Old 12/08/2014, 10:52 AM   #4
JM_Millers
Big Clucker
 
JM_Millers's Avatar
 
Join Date: Feb 2012
Posts: 190
Reputation: 28
Default Re: I need help

up .
JM_Millers is offline   Reply With Quote
Old 14/08/2014, 09:24 AM   #5
JM_Millers
Big Clucker
 
JM_Millers's Avatar
 
Join Date: Feb 2012
Posts: 190
Reputation: 28
Default Re: I need help

up .
JM_Millers is offline   Reply With Quote
Old 14/08/2014, 09:41 AM   #6
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 10,067
Reputation: 2660
Default Re: I need help

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.
__________________
Vince is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 07:46 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.