[Include] Simple Vehicle Functions
#1

Introductions
This script is mainly focused on begginer scripters as it gives you only small advantage and thats is time you would need to do this stuff.
I never planned to release this on SA:MP forums but since I seen some people struggle with getting vehicle parameters and such, I have decided to release it



Functions
PHP Code:
//Engines
ToggleVehicleEngine(vehiclestatus); //Set STATUS to 1 to turn it on or 0 to turn it off
GetVehicleEngineStatusString(vehicle); //returns string such as "On" or "Off" depending on engine status
GetVehicleEngineStatus(vehicle);  //Same as GetVehicleEngineStatusString but returns intergrer
AutomaticEngineSwitch(vehicle); //It will automaticly switch car engine on/off
//lights
ToggleVehicleLights(vehiclestatus); //Set STATUS to 1 to turn it on or 0 to turn it off
GetVehicleLightsStatusString(vehicle); //returns string such as "On" or "Off" depending on light status
GetVehicleLightsStatus(vehicle); //Same as GetVehicleLightsStatusString but returns intergrer
AutomaticLightSwitch(vehicle); //It will automaticly switch car lights on/off
//Trunks
ToggleVehicleTrunk(vehiclestatus); //Set STATUS to 1 to open it on or 0 to close it
GetVehicleTrunkStatusString(vehicle//returns string such as "Open" or "Closed" depending on trunk status
GetVehicleTrunkStatus(vehicle); //Same as GetVehicleTrunkStatusString but returns intergrer
ToggleNearestPlayerTrunk(playerid,status); //Set STATUS to 1 to open or 0 to close. It will open/close nearest vehicle trunk thats in range of 10 meters
ToggleAutomaticNearestTrunk(playerid); //It will automaticly open/close nearest vehicles trunk thats in range of 10 meters.
//Locks
ToggleVehicleLock(vehicle,status); //Set STATUS to 1 to lock car or 0 to unlock
GetVehicleLockStatusString(vehicle//returns string such as "Locked" or "Unlocked" depending on trunk status
GetVehicleLockStatus(vehicle//Same as GetVehicleLockStatusString but returns intergrer
ToggleNarestVehicleLock(playerid//this will lock/unlock narest player vehicle automaticly
GetNearCarLockString(playerid//this will get status of vehicle locks that is nearest to the player (10 meters) and return in a string "Locked" or "Unlocked"
GetNearCarLock(playerid//this will get status of vehicle lock that is nearest to the player (10 meters) and return it as an int. 0 as unlocked, 1 as locked 

Callbacks
PHP Code:
public OnVehicleStart(vehicleid)
public 
OnVehicleStop(vehicleid)
public 
OnVehicleLock(vehicleid)
public 
OnVehicleUnlock(vehicleid
Example script
Example MANUAL scripts. These are commands that require of player to type in for example /engine on to start it etc.
ZCMD + SSCANF (Manual system with ON and OFF) http://pastebin.com/udbZggS2

Example AUTOMATIC script. These commands are the ones that dont require any sort of player parameter setting. Automatic engine etc.
ZCMD http://pastebin.com/t9hbvh1w



Credits
Special credits to SA:MP dev team
Special credits & thanks to Xalphox for teaching me how to script
Special credits to ***** for SSCANF https://sampforum.blast.hk/showthread.php?tid=570927
Special credits to Zeex for ZCMD https://sampforum.blast.hk/showthread.php?tid=91354
Special credits to Jeff for getting closest vehicle
Special credits to Crayder for all the help and support



Download
v.1.1 http://pastebin.com/BMAbCgv6
v.1.0 http://pastebin.com/U8Qz1D4U



Bugs
None found yet



Updates
v.1.1
  • Added callback public OnVehicleStart(vehicleid)
  • Added callback public OnVehicleStop(vehicleid)
  • Added lock functionality
  • Example code for v1.1: http://pastebin.com/zLyibUuE
  • Added if defined (Thanks to Crayder) so there wont be any errors or warnings with this


v.1.0 http://pastebin.com/U8Qz1D4U



Plan
This is not 100% finished, im still working on some parts for it. For now its just a basic include but I plan to expand it a lot more for better vehicle detection




NOTE
FOR SOME PARTS OF THIS CODE TO WORK MAKE SURE YOU HAVE ManualVehicleEngineAndLights(); SET ONGAMEMODEINIT !!
Reply


Messages In This Thread
Simple Vehicle Functions - by TwinkiDaBoss - 25.01.2016, 17:46
Re: Simple Vehicle Functions - by Crayder - 25.01.2016, 18:10
Re: Simple Vehicle Functions - by TwinkiDaBoss - 25.01.2016, 18:15
Re: Simple Vehicle Functions - by PT - 25.01.2016, 21:03
Re: Simple Vehicle Functions - by TwinkiDaBoss - 25.01.2016, 21:05
Re: Simple Vehicle Functions - by Spydah - 18.02.2016, 16:56
Re: Simple Vehicle Functions - by Crayder - 18.02.2016, 20:19

Forum Jump:


Users browsing this thread: 1 Guest(s)