SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 21/05/2013, 03:13 PM   #1
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 10,086
Reputation: 2655
Default Extended Vehicle Information

Extended Vehicle Information (EVI)
Version 1.0.1

This script allows you to retrieve all vehicle related information. All information that is present in the handling.cfg data file has been converted - with the necessary difficulty - into an SQLite database. You are now able to retrieve a vehicle's top speed, its mass, its cost, its gears, its acceleration and much, much more.

Even more interesting is that you can also read a vehicle's model and handling flags. Apart from being able to tell its type, you can also tell if a vehicle is a low rider or a street racer, you can tell if the vehicle has a normal exhaust, double exhausts or no exhausts at all. There are 60 flags that you can check!

Please note: all values use the metric system. This is how they appear in the data file. It is not my choice (although I prefer metric over imperial any time).
Note 2: No input escaping is done whatsoever! I tried to implement it, but crashdetect went mad and everything broke. Then again, these functions aren't meant to be used with end user input.


Example Usage
pawn Code:
new vehicle_cost = GetVehicleModelInfoAsInt(411, "nMonetaryValue"); // infernus
printf("model 411 costs $%d", vehicle_cost);

new Float:vehicle_weight = GetVehicleModelInfoAsFloat(402, "fMass"); // buffalo
printf("model 402 weighs %f kilograms", vehicle_weight);

if(GetVehicleModelFlag(425, MFLAG_IS_HELI)) // hunter
{
    printf("model 425 is a helicopter");
}
else
{
    printf("model 425 is not a helicopter");
}

if(GetVehicleHandlingFlag(567, HFLAG_LOW_RIDER)) // savanna
{
    printf("model 567 is a lowrider");
}
else
{
    printf("model 567 is not a lowrider");
}

Installation Instructions

Download the zip file from the GitHub repository. Extract the contents in your server directory. All files should automatically go to their respective directories. If that doesn't work: manually place handling.db into the /scriptfiles folder and evi.inc into the /pawno/include folder.

Use this in any script in which you'd like to use these functions:
pawn Code:
#include <evi>


Technical Information

To be used with GetVehicleModelInfoAsInt and GetVehicleModelInfoAsFloat. DriveType and EngineType should also be retrieved with the integer function. However, they return characters. These can be validated as follows:
pawn Code:
if(GetVehicleModelInfoAsInt(400, "TransmissionData_nEngineType") == 'P') { /* ... */ }
Code:
	> UNITS <
	---------
	Vehicle identifier 14 characters max
	Dimensions in metres
	Mass in Kg
	Velocity in Km/h
	Acceleration/deceleration in ms-2
	Multipliers x1.0 is default
	Angles in degrees
	Levels :- (L)ow, (M)edium, (H)igh
	Buoyancy = percent submerged (> 100% vehicle sinks)
	Engine type :- (P)etrol, (D)iesel, (E)lectric
	Engine drive :- (F)ront, (R)ear, (4)-wheel drive
	
	> FIELD DESCRIPTIONS <
	----------------------
	[id] int  NOT NULL,
	[name] VARCHAR(14)  NOT NULL,
	[fMass] float  NOT NULL,
	[fTurnMass] float  NOT NULL,
	[fDragMult] float  NOT NULL,
	[fCentreOfMass_x] float  NOT NULL,
	[fCentreOfMass_y] float  NOT NULL,
	[fCentreOfMass_z] float  NOT NULL,
	[nPercentSubmerged] int  NOT NULL,
	[fTractionMultiplier] float  NOT NULL,
	[fTractionLoss] float  NOT NULL,
	[fTractionBias] float  NOT NULL,
	[TransmissionData_nNumberOfGears] int  NOT NULL,
	[TransmissionData_fMaxVelocity] float  NOT NULL,
	[TransmissionData_fEngineAcceleration] float  NOT NULL,
	[TransmissionData_fEngineInertia] float  NOT NULL,
	[TransmissionData_nDriveType] VARCHAR(2)  NOT NULL,
	[TransmissionData_nEngineType] VARCHAR(2)  NOT NULL,
	[fBrakeDeceleration] float  NOT NULL,
	[fBrakeBias] float  NOT NULL,
	[bABS] boolean  NOT NULL,
	[fSteeringLock] float  NOT NULL,
	[fSuspensionForceLevel] float  NOT NULL,
	[fSuspensionDampingLevel] float  NOT NULL,
	[fSuspensionHighSpdComDamp] float  NOT NULL,
	[fSuspensionUpperLimit] float  NOT NULL,
	[fSuspensionLowerLimit] float  NOT NULL,
	[fSuspensionBias] float  NOT NULL,
	[fSuspensionMult] float  NOT NULL,
	[fSeatOffsetDistance] float  NOT NULL,
	[fCollisionDamageMultiplier] float  NOT NULL,
	[nMonetaryValue] int  NOT NULL,
	[nModelFlags] int  NOT NULL,
	[nHandlingFlags] int  NOT NULL,
	[nFrontLights] int  NOT NULL,
	[nRearLights] int  NOT NULL,
	[nVehicleAnimGroup] int  NOT NULL

To be used with GetVehicleModelFlag.
pawn Code:
enum modelFlags (<<= 1)
{
    MFLAG_IS_VAN = 1,
    MFLAG_IS_BUS,
    MFLAG_IS_LOW,
    MFLAG_IS_BIG,
    MFLAG_REVERSE_BONNET,
    MFLAG_HANGING_BOOT,
    MFLAG_TAILGATE_BOOT,
    MFLAG_NOSWING_BOOT,
    MFLAG_NO_DOORS,
    MFLAG_TANDEM_SEATS,
    MFLAG_SIT_IN_BOAT,
    MFLAG_CONVERTIBLE,
    MFLAG_NO_EXHAUST,
    MFLAG_DOUBLE_EXHAUST,
    MFLAG_NO1FPS_LOOK_BEHIND,
    MFLAG_FORCE_DOOR_CHECK,
    MFLAG_AXLE_F_NOTILT,
    MFLAG_AXLE_F_SOLID,
    MFLAG_AXLE_F_MCPHERSON,
    MFLAG_AXLE_F_REVERSE,
    MFLAG_AXLE_R_NOTILT,
    MFLAG_AXLE_R_SOLID,
    MFLAG_AXLE_R_MCPHERSON,
    MFLAG_AXLE_R_REVERSE,
    MFLAG_IS_BIKE,
    MFLAG_IS_HELI,
    MFLAG_IS_PLANE,
    MFLAG_IS_BOAT,
    MFLAG_BOUNCE_PANELS,
    MFLAG_DOUBLE_RWHEELS,
    MFLAG_FORCE_GROUND_CLEARANCE,
    MFLAG_IS_HATCHBACK
};

To be used with GetVehicleHandlingFlag.
pawn Code:
enum handlingFlags (<<= 1)
{
    HFLAG_1G_BOOST = 1,
    HFLAG_2G_BOOST,
    HFLAG_NPC_ANTI_ROLL,
    HFLAG_NPC_NEUTRAL_HANDL,
    HFLAG_NO_HANDBRAKE,
    HFLAG_STEER_REARWHEELS,
    HFLAG_HB_REARWHEEL_STEER,
    HFLAG_ALT_STEER_OPT,
    HFLAG_WHEEL_F_NARROW2,
    HFLAG_WHEEL_F_NARROW,
    HFLAG_WHEEL_F_WIDE,
    HFLAG_WHEEL_F_WIDE2,
    HFLAG_WHEEL_R_NARROW2,
    HFLAG_WHEEL_R_NARROW,
    HFLAG_WHEEL_R_WIDE,
    HFLAG_WHEEL_R_WIDE2,
    HFLAG_HYDRAULIC_GEOM,
    HFLAG_HYDRAULIC_INST,
    HFLAG_HYDRAULIC_NONE,
    HFLAG_NOS_INST,
    HFLAG_OFFROAD_ABILITY,
    HFLAG_OFFROAD_ABILITY2,
    HFLAG_HALOGEN_LIGHTS,
    HFLAG_PROC_REARWHEEL_1ST,
    HFLAG_USE_MAXSP_LIMIT,
    HFLAG_LOW_RIDER,
    HFLAG_STREET_RACER,
    HFLAG_UNUSED_FLAG, // Unused in data files. Required for continuity. Do not remove.
    HFLAG_SWINGING_CHASSIS
}
__________________

Last edited by Vince; 23/02/2016 at 05:04 PM. Reason: Moved to GitHub.
Vince is offline   Reply With Quote
Old 21/05/2013, 03:15 PM   #2
Kyle
High-roller
 
Kyle's Avatar
 
Join Date: Mar 2009
Location: United Kingdom
Posts: 2,263
Reputation: 330
Default Re: Extended Vehicle Information

perfect.

Was waiting for another one of your releases or tutorials!
__________________
Kyle is offline   Reply With Quote
Old 21/05/2013, 04:41 PM   #3
RajatPawar
High-roller
 
RajatPawar's Avatar
 
Join Date: Aug 2011
Location: ヽ༼ຈل͜ຈ༽ノ
Posts: 2,180
Reputation: 311
Default Re: Extended Vehicle Information

Huge, a lot of work, really nice. Personally, I hate working with SQLite. However, you said costs - what kind of vehicle costs? If you mean the 'money' cost, shouldn't that be dependent on personal opinion? Or is it another kind of 'cost'?
RajatPawar is offline   Reply With Quote
Old 21/05/2013, 04:47 PM   #4
Littlehelper
Gangsta
 
Littlehelper's Avatar
 
Join Date: Nov 2011
Location: 420
Posts: 946
Reputation: 178
Default Re: Extended Vehicle Information

Very nice!
Littlehelper is offline   Reply With Quote
Old 21/05/2013, 04:52 PM   #5
DaRk_RaiN
Gangsta
 
DaRk_RaiN's Avatar
 
Join Date: Sep 2012
Posts: 973
Reputation: 207
Default Re: Extended Vehicle Information

I love it, good job!
DaRk_RaiN is offline   Reply With Quote
Old 21/05/2013, 04:56 PM   #6
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 10,086
Reputation: 2655
Default Re: Extended Vehicle Information

Quote:
Originally Posted by Rajat_Pawar View Post
Huge, a lot of work, really nice. Personally, I hate working with SQLite. However, you said costs - what kind of vehicle costs? If you mean the 'money' cost, shouldn't that be dependent on personal opinion? Or is it another kind of 'cost'?
Those are the prices that the game uses internally for the export mission in single player. They were in that file so I figured I might as well add them.
__________________
Vince is offline   Reply With Quote
Old 21/05/2013, 08:27 PM   #7
Kreatyve
Big Clucker
 
Kreatyve's Avatar
 
Join Date: Oct 2012
Posts: 103
Reputation: 26
Default Re: Extended Vehicle Information

Useful, thank you very much =]
Kreatyve is offline   Reply With Quote
Old 21/05/2013, 08:53 PM   #8
MP2
Godfather
 
MP2's Avatar
 
Join Date: Jan 2011
Location: England
Posts: 6,230
Reputation: 993
Default Re: Extended Vehicle Information

Not sure how most of this is beneficial tbh. When would one need the handling information of a vehicle? The only data I can see a partial use for is the monetary values (the value of the vehicles) - though they aren't great ($95,000 for an Infernus and $45,000 for a Hydra..?).

Good work all the same.
__________________
Click banner above for more info. View trailers here.
Enter referral code SAMPFORUM after registering for a $5000 starting bonus!
MP2 is offline   Reply With Quote
Old 21/05/2013, 09:05 PM   #9
RedCrossER
Huge Clucker
 
Join Date: Nov 2012
Posts: 274
Reputation: 8
Default Re: Extended Vehicle Information

woah Perfect , Good Include...
RedCrossER is offline   Reply With Quote
Old 21/05/2013, 10:21 PM   #10
Bicentric
Big Clucker
 
Join Date: Sep 2012
Posts: 143
Reputation: 36
Default Re: Extended Vehicle Information

Wow! This is perfect Vince, I can see many uses for this. Thank you such much for such a useful release! Rep++
Bicentric 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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Include] FCNPC Extended Functions Pottus Includes 3 27/05/2014 04:37 AM
Mass Effect 3 (Extended Cut) toXioneer Everything and Nothing 2 07/08/2012 09:59 AM
[Map] Extended Fort Carson [RP] Namaco Maps 21 14/06/2011 11:02 PM
Attaching objects to vehicle [need information] BuLLeT[LTU] Help Archive 5 01/03/2011 12:52 PM


All times are GMT. The time now is 03:20 AM.


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