Here you will find all the useful exports for this asset, please read each step and example carefully to better understand how it works, we do not recommend using these if you are not an experienced developer.
Obtain the plate natively
This is a simple copy and paste code to integrate it into your code to obtain the plate.
local model =GetDisplayNameFromVehicleModel(GetEntityModel(veh))local plate =GetVehicleNumberPlateText(veh)
GiveKeys
Export to give the keys of a specified vehicle.
-- plate: Vehicle plate-- model: Vehicle model-- bypassKeyCheck: (optional, default is false) If true, bypasses the key validation check before giving the keys.exports['qs-vehiclekeys']:GiveKeys(plate, model, true)
The automatic export is for situational use since you must be inside the vehicle for it to run.
Export to give the keys of the vehicle in which you are.
exports['qs-vehiclekeys']:GiveKeysAuto()
RemoveKeysAuto
The automatic export is for situational use since you must be inside the vehicle for it to run.
Export to remove the keys of the vehicle in which you are.
exports['qs-vehiclekeys']:RemoveKeysAuto()
GetKeyAuto
The automatic export is for situational use since you must be inside the vehicle for it to run.
This export checks if the player has keys to the vehicle he is in.
exports['qs-vehiclekeys']:GetKeyAuto()
DoorLogic
The DoorLogic system has the following parameters.
skipAnimation (optional, default is false): If true, skips the lock/unlock animation.
forcedDoorStatus (optional): If provided, forces the door status to the specified value.
skipNotification (optional, default is false): If true, skips displaying notifications.
skipSound (optional, default is false): If true, skips playing default vehicle door sounds.
skipFlickerLights (optional, default is false): If true, skips flickering lights.
The status values for the DoorLogic are as follows.
0: None (The doors are in an undefined or neutral state.)
1: Unlocked (Indicates that the doors are currently unlocked.)
2: Locked (Indicates that the doors are securely locked.)
-- vehicle: The vehicle entity for which the door logic will be applied.-- skipAnimation: (optional, default is false): If true, skips the lock/unlock animation.-- forcedDoorStatus: (optional): If provided, forces the door status to the specified value.-- skipNotification: (optional, default is false): If true, skips displaying notifications.-- skipSound: (optional, default is false): If true, skips playing default vehicle door sounds.-- skipFlickerLights: (optional, default is false): If true, skips flickering lights.exports["qs-vehiclekeys"]:DoorLogic(vehicle, skipAnimation, forceDoorStatus, skipNotification, skipSound, skipFlickerLights)
An example of using this system would be the following.
-- Function to get the closest vehiclefunctionGetClosestVehicle()local playerPed =GetPlayerPed(-1)local pos =GetEntityCoords(playerPed)local vehicles =GetGamePool('CVehicle')local closestVehicle =0local minDistance =-1for _, vehicle inipairs(vehicles) dolocal distance =#(pos -GetEntityCoords(vehicle))if minDistance ==-1or distance < minDistance then minDistance = distance closestVehicle = vehicleendendreturn closestVehicleend-- Function to test the DoorLogic exportfunctionTestDoorLogicExport()local closestVehicle =GetClosestVehicle()if closestVehicle ~=0thenlocal plate =GetVehicleNumberPlateText(closestVehicle)-- Check if the player has the key for the vehiclelocal hasKey = exports['qs-vehiclekeys']:GetKey(plate)if hasKey thenprint("Player has the key for vehicle with plate: " .. plate)-- Use DoorLogic export with default parameters exports["qs-vehiclekeys"]:DoorLogic(closestVehicle)-- Use DoorLogic export with custom parameters-- exports["qs-vehiclekeys"]:DoorLogic(closestVehicle, true, 1)print("DoorLogic export tested successfully.")elseprint("Player does not have the key for vehicle with plate: " .. plate)endelseprint("No vehicle found.")endend-- Trigger the test functionTestDoorLogicExport()
AddRentalPapers
These exports behave similarly to GiveKeys and RemoveKeys exports.
The function adds rental papers to the player's inventory based on the provided plate and model.
-- plate: The vehicle plate associated with the rental papers-- model: The vehicle model associated with the rental papersexports["qs-vehiclekeys"]:AddRentalPapers(plate, model)
RemoveRentalPapers
These exports behave similarly to GiveKeys and RemoveKeys exports.
The function removes rental papers from the player's inventory based on the provided plate and model.
-- plate: The vehicle plate associated with the rental papers-- model: The vehicle model associated with the rental papersexports["qs-vehiclekeys"]:RemoveRentalPapers(plate, model)
GetDoorState
Retrieve and print the door state of a vehicle.
An integer representing the door state of the vehicle. The possible values are as follows: