21.05.2013, 14:13
(
Последний раз редактировалось Vince; 23.02.2016 в 16:04.
Причина: Moved to GitHub.
)
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. Version 1.0.1
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 Код:
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");
}
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 Код:
#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 Код:
if(GetVehicleModelInfoAsInt(400, "TransmissionData_nEngineType") == 'P') { /* ... */ }
Код:
> 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, ®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
pawn Код:
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_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FLAG_UNUSED_FLAG, // Unused in data files. Required for continuity. Do not remove.
HFLAG_SWINGING_CHASSIS
}