Vehicle Synchronization
From SA-MP Wiki
vSync Include | |
---|---|
Author | RIDE2DAY |
Released | 23/09/2017 |
Latest Version | 0.03 (07/11/2017) |
Development Status | Active |
License | MPL |
Forum Topic |
Here you may find all the documentation related to the vSync include scripted by RIDE2DAY. If you find any bug, please, report it on the official topic.
New Functions
GetVehicleName
Description:
vehicleid | The ID of the vehicle to get the name of. |
name[] | An array into which to store the vehicle name, passed by reference. |
len | The length of the string that should be stored. Recommended to be MAX_VEHICLE_NAME. |
Return Values:
Example Usage:
new v_name[MAX_VEHICLE_NAME]; new vehicleid = GetPlayerVehicleID(playerid); GetVehicleName(vehicleid, v_name, MAX_VEHICLE_NAME); new string[128]; format(string, 128, "Vehicle's name is %s.", v_name); SendClientMessage(playerid, -1, string);
GetVehicleNumberPlate
Description:
vehicleid | The ID of the vehicle to get the number plate of. |
dest[] | An array into which to store the vehicle number plate, passed by reference. |
len | The length of the string that should be stored. Recommended to be MAX_VEHICLE_NUMBERPLATE. |
Return Values:
Example Usage:
new v_np[MAX_VEHICLE_NUMBERPLATE]; new vehicleid = GetPlayerVehicleID(playerid); GetVehicleName(vehicleid, v_name, MAX_VEHICLE_NUMBERPLATE); new string[128]; format(string, 128, "Vehicle's number plate is %s.", v_np); SendClientMessage(playerid, -1, string);
GetVehicleColor
Description:
vehicleid | The ID of the vehicle to get the colors of. |
&color1 | A variable in which to store vehicle's primary color ID, passed by reference. |
&color2 | A variable in which to store vehicle's secondary color ID, passed by reference. |
Return Values:
Example Usage:
new col1, col2; GetVehicleColor(GetPlayerVehicleID(playerid), col1, col2);
GetVehiclePaintjob
Description:
vehicleid | The ID of the vehicle to get the paintjob ID of. |
Return Values:
- The paintjob ID or INVALID_PAINTJOB_ID if the vehicle doesn't have a paintjob.
- -1 if the vehicle ID doesn't exist.
Example Usage:
new msg[128]; format(msg, 128, "The paintjob ID is %d.", GetVehiclePaintjob(GetPlayerVehicleID(playerid))); SendClientMessage(playerid, -1, msg);
GetVehicleSiren
Description:
vehicleid | The ID of the vehicle to get the siren state of. |
Return Values:
Example Usage:
new vehicleid = GetPlayerVehicleID(playerid); if(GetVehicleModel(vehicleid) == 411 && !GetVehicleSiren(vehicleid)) { SendClientMessage(playerid, -1, "Your Infernus doesn't have a siren."); }
GetVehicleInterior
Description:
vehicleid | The ID of the vehicle to get the interior of. |
Return Values:
Example Usage:
new vehicleid = GetPlayerVehicleID(playerid); LinkVehicleToInterior(vehicleid, 10); printf("The new interior is %d.", GetVehicleInterior(vehicleid));
GetVehicleSpeed
Description:
vehicleid | The vehicle ID to get the current speed of. |
Return Values:
Example Usage:
new vehicleid = GetPlayerVehicleID(playerid); printf("The current speed is %d km/h.", GetVehicleSpeed(vehicleid));
GetVehicleMaxSpeed
Description:
modelid | The vehicle model ID to get the max. speed of. |
Return Values:
Example Usage:
new msg[128]; new max_speed = GetVehicleMaxSpeed(411); format(msg, 128, "The Infernus has a max. speed of %d.", max_speed); SendClientMessage(playerid, -1, msg);
GetVehicleSeats
Description:
modelid | The vehicle model ID to get the seats of. |
Return Values:
Example Usage:
new modelid = GetVehicleModel( GetPlayerVehicleID(playerid) ); new msg[128]; format(msg, 128, "Your vehicle has %d seats, call some fellas.", GetVehicleSeats(modelid)); SendClientMessage(playerid, -1, msg);
GetVehicleWindows
Description:
modelid | The vehicle model ID to get the windows of. |
Return Values:
Example Usage:
new modelid = GetVehicleModel( GetPlayerVehicleID(playerid) ); new msg[128]; format(msg, 128, "Your vehicle has %d windows, break them!", GetVehicleWindows(modelid)); SendClientMessage(playerid, -1, msg);
GetVehicleMass
Description:
modelid | The vehicle model ID to get the mass of. |
Return Values:
Example Usage:
new Float:mass = GetVehicleMass(411); printf("The Infernus has a mass of %.1f kg.", mass); // %.1f for one decimal.
GetVehicleEngineType
Description:
modelid | The vehicle model ID to get the engine type of. |
Return Values:
- D if the vehicle uses diesel.
- P if the vehicle uses petrol.
- E if the vehicle is electric.
- H if the vehicle is a HPV (human-powered vehicle)
Example Usage:
new modelid = GetVehicleModel(GetPlayerVehicleID(playerid)); if(GetVehicleEngineType(modelid) != 'H') { SendClientMessage(playerid, -1, "You need a bike in order to start this mission."); } else { SendClientMessage(playerid, -1, "Seems you have a bike, good."); }
GetVehicleDriveType
Description:
modelid | The vehicle model ID to get the drive type of. |
Return Values:
- F if the vehicle is FWD (front-wheel drive).
- R if the vehicle is RWD (rear-wheel drive).
- 4 if the vehicle is 4WD (four-wheel drive).
Example Usage:
new modelid = GetVehicleModel(GetPlayerVehicleID(playerid)); if(GetVehicleDriveType(modelid) != '4') { SendClientMessage(playerid, -1, "You need a 4WD vehicle to start this race."); }
VehicleSupportsNeonLights
Description:
modelid | The vehicle model ID to check. |
Return Values:
Example Usage:
new modelid = GetVehicleModel(GetPlayerVehicleID(playerid)); if(!VehicleSupportsNeonLights(modelid)) { new msg[128]; new vname[MAX_VEHICLE_NAME]; GetVehicleName(newveh, vname, MAX_VEHICLE_NAME); format(msg, 128, "The %s has the neon lights {FF0000}disabled{FFFFFF}.", vname); SendClientMessage(playerid, -1, msg); }
SetVehicleNeonLights
Description:
vehicleid | The vehicle ID to set the neon lights to. |
bool:toggle | true to enable the neon lights and false to disable them. |
color | The object model for the neon lights, set to NEON_LIGHT_RED by default. |
Return Values:
Note |
|
Color Definition | Object Model |
---|---|
NEON_LIGHT_RED | 18647 |
NEON_LIGHT_BLUE | 18648 |
NEON_LIGHT_GREEN | 18649 |
NEON_LIGHT_YELLOW | 18650 |
NEON_LIGHT_PINK | 18651 |
NEON_LIGHT_WHITE | 18652 |
Example Usage:
new vehicleid = GetPlayerVehicleID(playerid); new modelid = GetVehicleModel(vehicleid); if(VehicleSupportsNeonLights(modelid)) { SetVehicleNeonLights(vehicleid, true, NEON_LIGHT_GREEN); SendClientMessage(playerid, -1, "Your car has {00FF00}green {FFFFFF}neon lights now."); }
GetVehicleNeonLightsState
Description:
vehicleid | The vehicle ID to get the neon lights state of. |
Return Values:
- 1 if the the neon lights are enabled.
- 0 if the the neon lights are disabled or if the vehicle ID doesn't exist.
Example Usage:
new vehicleid = GetPlayerVehicleID(playerid); if(GetVehicleNeonLightsState(vehicleid)) { SendClientMessage(playerid, -1, "You have neon lights, now you may join the Midnight Club!"); }
VehicleSupportsNitro
Description:
modelid | The vehicle model ID to check. |
Return Values:
Example Usage:
new vehicleid = GetPlayerVehicleID(playerid); new modelid = GetVehicleModel(vehicleid); if(VehicleSupportsNitro(modelid)) { new msg[128]; new vname[MAX_VEHICLE_NAME]; GetVehicleName(newveh, vname, MAX_VEHICLE_NAME); AddVehicleComponent(vehicleid, 1010); format(msg, 128, "Now your %s has nitro, enjoy!", vname); SendClientMessage(playerid, -1, msg); }
VehicleSupportsComponent
Description:
modelid | The vehicle model ID to check. |
componentid | The ID of the component you're going to check. |
Return Values:
Note | There are internal checks for OnVehicleMod and AddVehicleComponent, use this function wherever you need it. |
Example Usage:
new vehicleid = GetPlayerVehicleID(playerid); new modelid = GetVehicleModel(vehicleid); if(VehicleSupportsComponent(modelid, 1003)) { new msg[128]; new vname[MAX_VEHICLE_NAME]; GetVehicleName(newveh, vname, MAX_VEHICLE_NAME); AddVehicleComponent(vehicleid, 1003); format(msg, 128, "Alpha Spoiler added to your %s.", vname); SendClientMessage(playerid, -1, msg); }
Modified Functions
- There are two new component slots for GetVehicleComponentType and GetVehicleComponentInSlot:
- CARMODTYPE_FRONT_BULLBAR
- CARMODTYPE_REAR_BULLBAR
Component ID | Slot | Type | Car |
---|---|---|---|
1109 | CARMODTYPE_REAR_BULLBAR | Chrome | Slamvan |
1110 | CARMODTYPE_REAR_BULLBAR | Slamin | Slamvan |
1115 | CARMODTYPE_FRONT_BULLBAR | Chrome | Slamvan |
1116 | CARMODTYPE_FRONT_BULLBAR | Slamin | Slamvan |
1100 | CARMODTYPE_FRONT_BULLBAR | Chrome Grill | Remington |
1123 | CARMODTYPE_FRONT_BULLBAR | Bullbar Chrome Bars | Remington |
1125 | CARMODTYPE_FRONT_BULLBAR | Bullbar Chrome Lights | Remington |
New Callbacks
OnVehicleCreated
Description:
vehicleid | The ID of the vehicle which has been created. |
Return Values:
Example Usage:
public OnVehicleCreated(vehicleid) { SetVehicleNumberPlate(vehicleid, "{FF0000}RIDE2DAY"); return 1; }
OnVehicleChangePaintjob
Description:
playerid | The ID of the player that bought the paintjob. |
vehicleid | The ID of the vehicle which the paintjob was applied to. |
paintjobid | The ID of the new paintjob. |
Return Values:
Example Usage:
public OnVehicleChangePaintjob(playerid, vehicleid, paintjobid) { new msg[128]; format(msg, 128, "The ID of the paintjob you just bought is %d.", paintjobid); SendClientMessage(playerid, -1, msg); return 1; }
Notes
- You might use INVALID_PAINTJOB_ID with ChangeVehiclePaintjob to remove a paintjob.
- When a vehicle respawns it returns to its original colors (those which had when was created), that's how it works by default.
- When a vehicle respawns all its mods are removed, that's how it works by default.
- This scripts uses y_hooks or the ALS hooking method.
- Functions hooked:
- CreateVehicle
- DestroyVehicle
- AddStaticVehicle
- AddStaticVehicleEx
- SetVehicleNumberPlate
- LinkVehicleToInterior
- ChangeVehicleColor
- ChangeVehiclePaintjob
- GetVehicleComponentType
- GetVehicleComponentInSlot
- AddVehicleComponent
- RemoveVehicleComponent
- Callbacks hooked:
- OnPlayerConnect
- OnPlayerUpdate
- OnPlayerKeyStateChange
- OnEnterExitModShop
- OnVehiclePaintjob
- OnVehicleRespray
- OnVehicleSpawn
- OnVehicleMod
- Vehicles with NeonOffsetX = NeonOffsetY = NeonOffsetZ = 0.0 don't support neon lights, you're free to modify those offsets if you wish. Here you have list with those vehicles.
- Now AddVehicleComponent has internal checks, you don't have to check anymore if a component is valid when using this function.