06.01.2014, 21:58
(
Last edited by Emmet_; 04/05/2015 at 08:15 PM.
)
Extended vehicle functions
Introduction
This is a useful set of vehicle functions that I've made recently. Some functions allow you to retrieve the offset of certain parts of a vehicle, and some are just for ordinary useful things.
Functions
A list of functions:
A list of callbacks:
List of types
These types are to be used with GetVehicleParams and SetVehicleParams.
How do I use it?
Simply download the include below and add it to your script.
An example of use:
An engine command without any variables:
Other resources
GetVehicleColor by RyDeR`
Extended Vehicle Information by Vince
Download
Pastebin
Introduction
This is a useful set of vehicle functions that I've made recently. Some functions allow you to retrieve the offset of certain parts of a vehicle, and some are just for ordinary useful things.
Functions
A list of functions:
pawn Code:
// Returns the specified vehicle parameter.
stock GetVehicleParams(vehicleid, type);
// Sets the specified vehicle parameter to the specified status.
stock SetVehicleParams(vehicleid, type, status, time = 0);
// Get the position of the vehicle's boot.
stock GetVehicleBoot(vehicleid, &Float:x, &Float:y, &Float:z);
// Get the position of the vehicle's hood.
stock GetVehicleHood(vehicleid, &Float:x, &Float:y, &Float:z);
// Get the position of the vehicle's roof.
stock GetVehicleRoof(vehicleid, &Float:x, &Float:y, &Float:z);
// Returns two random colors for the specified model ID. Based on data from carcols.dat.
stock GetVehicleRandomColors(modelid, &color1, &color2);
// Returns a vehicle's colors.
stock GetVehicleColor(vehicleid, &color1, &color2);
// Returns a vehicle's paintjob. Returns INVALID_PAINTJOB_ID if there isn't any paintjob set.
stock GetVehiclePaintjob(vehicleid);
// Returns the vehicle's interior ID.
stock GetVehicleInterior(vehicleid);
// Returns the nearest vehicle ID.
stock GetNearestVehicle(playerid);
// Returns the player ID of the driver.
stock GetVehicleDriver(vehicleid);
// Returns the vehicle's top speed.
stock Float:GetVehicleTopSpeed(vehicleid);
// Returns the next available seat (or INVALID_SEAT_ID if there's none).
stock GetVehicleNextSeat(vehicleid, passenger = 1);
// Returns the maximum amount of seats for the vehicle.
stock GetVehicleSeats(vehicleid);
// Returns the maximum amount of seats for the vehicle model.
stock GetVehicleModelSeats(modelid);
// Returns 1 if the specified seat is taken.
stock IsVehicleSeatOccupied(vehicleid, seatid);
A list of callbacks:
pawn Code:
public OnVehicleCreated(vehicleid)
{
return 1;
}
public OnVehicleDestroy(vehicleid)
{
// Returning 0 in this callback will not destroy the vehicle.
return 1;
}
public OnPlayerShootVehicle(playerid, vehicleid, weaponid)
{
return 1;
}
public OnTrailerHooked(playerid, vehicleid, trailerid)
{
return 1;
}
public OnTrailerUnhooked(playerid, vehicleid, trailerid)
{
return 1;
}
These types are to be used with GetVehicleParams and SetVehicleParams.
pawn Code:
enum e_ParamTypes {
VEHICLE_TYPE_ENGINE,
VEHICLE_TYPE_LIGHTS,
VEHICLE_TYPE_ALARM,
VEHICLE_TYPE_DOORS,
VEHICLE_TYPE_BONNET,
VEHICLE_TYPE_BOOT,
VEHICLE_TYPE_OBJECTIVE
};
Simply download the include below and add it to your script.
pawn Code:
#include <EVF>
An example of use:
pawn Code:
new
vehicleid = GetNearestVehicle(playerid),
Float:x,
Float:y,
Float:z;
if (IsValidVehicle(vehicleid))
{
GetVehicleBoot(vehicleid, x, y, z);
if (IsPlayerInRangeOfPoint(playerid, 3.0, x, y, z))
{
SendClientMessage(playerid, COLOR_WHITE, "You are standing near the trunk!");
}
return 1;
}
An engine command without any variables:
pawn Code:
CMD:engine(playerid, params[])
{
new
vehicleid = GetPlayerVehicleID(playerid);
if (!GetVehicleParams(vehicleid, VEHICLE_TYPE_ENGINE))
{
SetVehicleParams(vehicleid, VEHICLE_TYPE_ENGINE, true);
}
else
{
SetVehicleParams(vehicleid, VEHICLE_TYPE_ENGINE, false);
}
return 1;
}
GetVehicleColor by RyDeR`
Extended Vehicle Information by Vince
Download
Pastebin