Client Exports

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)

RemoveKeys

Export to remove the keys of a specified vehicle.

-- plate: Vehicle plate
-- model: Vehicle model
exports['qs-vehiclekeys']:RemoveKeys(plate, model)

GetKey

Export to know if the player is in the specified vehicle.

-- plate: Vehicle plate
exports['qs-vehiclekeys']:GetKey(plate)

GiveKeysAuto

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 vehicle
function GetClosestVehicle()
    local playerPed = GetPlayerPed(-1)
    local pos = GetEntityCoords(playerPed)
    local vehicles = GetGamePool('CVehicle')
    local closestVehicle = 0
    local minDistance = -1

    for _, vehicle in ipairs(vehicles) do
        local distance = #(pos - GetEntityCoords(vehicle))

        if minDistance == -1 or distance < minDistance then
            minDistance = distance
            closestVehicle = vehicle
        end
    end

    return closestVehicle
end

-- Function to test the DoorLogic export
function TestDoorLogicExport()
    local closestVehicle = GetClosestVehicle()

    if closestVehicle ~= 0 then
        local plate = GetVehicleNumberPlateText(closestVehicle)

        -- Check if the player has the key for the vehicle
        local hasKey = exports['qs-vehiclekeys']:GetKey(plate)

        if hasKey then
            print("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.")
        else
            print("Player does not have the key for vehicle with plate: " .. plate)
        end
    else
        print("No vehicle found.")
    end
end

-- Trigger the test function
TestDoorLogicExport()

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 papers
exports["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 papers
exports["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:

  • 0: None

  • 1: Unlocked

  • 2: Locked

  • 3: LockedForPlayer

  • 4: StickPlayerInside

  • 7: CanBeBrokenInto

  • 8: CanBeBrokenIntoPersist

  • 10: CannotBeTriedToEnter

  • Other values: Unknown Status

local vehicle = GetVehiclePedIsIn(PlayerId(), false)
local doorState = exports["qs-vehiclekeys"]:GetDoorState(vehicle)
print("Door State: " .. doorState)

Last updated