SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 06/01/2014, 10:58 PM   #1
Emmet_
Guest
 
Posts: n/a
Default Extended vehicle functions

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:

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

List of types
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
};

How do I use it?
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;
}

Other resources
GetVehicleColor by RyDeR`
Extended Vehicle Information by Vince

Download
Pastebin

Last edited by Emmet_; 04/05/2015 at 09:15 PM.
  Reply With Quote
Old 06/01/2014, 11:30 PM   #2
Swedky
Banned
 
Join Date: Jun 2013
Location: Argentina.
Posts: 2,042
Reputation: 827
Default Respuesta: Extended vehicle functions

Woooaah .

Good work my shaggy friend.


PS: Pastebin.
Swedky is offline   Reply With Quote
Old 07/01/2014, 01:47 AM   #3
Emmet_
Guest
 
Posts: n/a
Default Re: Respuesta: Extended vehicle functions

Quote:
Originally Posted by EnzoMetlc View Post
Woooaah .

Good work my shaggy friend.


PS: Pastebin.
I almost forgot!

http://pastebin.com/bapPNrnT
  Reply With Quote
Old 07/01/2014, 02:08 AM   #4
Lordzy
High-roller
 
Lordzy's Avatar
 
Join Date: Mar 2012
Location: NetherRealm
Posts: 2,703
Reputation: 1176
Default Re: Extended vehicle functions

Another good release. But, what about camera positions? I don't know if it's released earlier or not, but would improve the include much more in case if there's GetVehicleRimPos(modelid, &Float:X, &Float:Y, &Float:Z) and so using it as camera positions. Like on NFS, when we're tuning, we could focus on the rims. (In case if tuning without the gta sa's default garages).
__________________
Currently inactive - I don't play at any SA-MP servers nor work on anything in PAWN for now. The projects that I've done so far in PAWN, which requires updates will be taking some time.
Lordzy is offline   Reply With Quote
Old 07/01/2014, 02:21 AM   #5
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 4,851
Reputation: 1312
Default Re: Extended vehicle functions

I'm going to suggest implementing GetVehicleTopSpeed(vehicleid) so speedometers can be dynamically scaled you can read all about that here.

http://gtaforums.com/topic/216347-gt.../#entry3209126
Pottus is offline   Reply With Quote
Old 07/01/2014, 02:27 AM   #6
EiresJason
Gangsta
 
Join Date: Mar 2013
Location: Dublin.
Posts: 685
Reputation: 76
Default Re: Extended vehicle functions

Nice man.
EiresJason is offline   Reply With Quote
Old 07/01/2014, 02:28 AM   #7
Emmet_
Guest
 
Posts: n/a
Default Re: Extended vehicle functions

Quote:
Originally Posted by [uL]Pottus View Post
I'm going to suggest implementing GetVehicleTopSpeed(vehicleid) so speedometers can be dynamically scaled you can read all about that here.

http://gtaforums.com/topic/216347-gt.../#entry3209126
Thanks a bunch!

I was thinking about a "kmh" parameter too. When false, it'll return the mph speed.
  Reply With Quote
Old 07/01/2014, 08:15 AM   #8
iZN
High-roller
 
Join Date: Jun 2010
Posts: 2,378
Reputation: 569
Default Re: Extended vehicle functions

Looks nice, good work.
__________________
iZN is offline   Reply With Quote
Old 07/01/2014, 10:58 AM   #9
RenSoprano
Huge Clucker
 
Join Date: Oct 2011
Location: Bansko, Bulgaria
Posts: 437
Reputation: 44
Default Re: Extended vehicle functions

Suggestion: Add engine to start/stop with timer
__________________
RenSoprano is offline   Reply With Quote
Old 07/01/2014, 04:01 PM   #10
PT
Godfather
 
PT's Avatar
 
Join Date: Nov 2012
Location: Europe
Posts: 7,168
Reputation: 801
Default Re: Extended vehicle functions

This is very usefull thanks
PT 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] Extended Vehicle Information Vince Includes 26 24/09/2017 08:03 PM
[Include] FCNPC Extended Functions Pottus Includes 3 27/05/2014 04:37 AM
[Include] exobjects - Extended object functions kristo Includes 2 11/12/2013 07:01 PM
[Include] FileEx (Extended file functions controlling and debugging script) BigETI Includes 4 28/08/2013 12:47 PM
[FilterScript] [FS] Vehicle Functions aircombat Filterscripts 19 25/08/2010 01:41 AM


All times are GMT. The time now is 06:46 PM.


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