📋Exports & Events

All exports and events available to integrate this resource into others.

Types / Classes

All types / classes can be found in shared/unlocked/types.lua.

Suggestions?

If you wish to have any exports and or events added, please head over to our Discord and create a suggestion post. We are happy to allow for easier integration within other resources.

Client Sided Exports

Save Vehicle

If you want to save a vehicle to the database that is in the world, run this export. This is the same function that gets ran with you use the /savevehicle command, which can be found here. Example:

---@param vin string
---@return boolean, string? @Success, reason for failure
exports["zyke_garages"]:SaveVehicle(vin)

Is Vehicle A Temporary Vehicle

Returns if the vehicle is a temporary vehicle or not. Example:

---@param vehicle integer @Vehicle handler
---@return boolean, boolean | nil @Is temp, has temp been initialized
exports["zyke_garages"]:IsVehicleATempVehicle(vehicle)

Pay Impound

Pay an impound for a vehicle. Example:

---@param vin string
---@param notifications boolean @Enable notifications when failed
---@return boolean, string? @Success, reason for failure
exports["zyke_garages"]:PayImpound(vin, notifications)

Set New Owner

If you want to set owners for vehicles through other resources, you can easily do so via our exports. Example:

---@param vin string?
---@param identifier string @Target identifier
---@param passedVehicleData table? @Set to the vehicle's properties if ownedVehicle is not true
---@param transferer string? @Simply used for logging purposes, set to the identifier of the transferer
---@param garageId string? @If provided, the vehicle will be set to this garage
exports["zyke_garages"]:SetNewOwner(vin, identifier, passedVehicleData, transferer, garageId)

Open Garage Settings

Opens the garage settings menu, which can also be opened with a command found here. Example:

exports["zyke_garages"]:OpenGarageSettings()

Set Fake Plate

This export allows you to swap the plate of a vehicle temporarily. Note that unless you set "performRealisticSwap" to true, it will not perform any animations, check if you're close to the vehicle etc. Example:

---@param identifier string | integer @Vin number or entity handler
---@param fakePlate string @New fake plate
---@param setAsOwner boolean @Set the fake plate as the owner of the vehicle
---@param performRealisticSwap boolean? @Animations & position checking
exports["zyke_garages"]:SetFakePlate(identifier, fakePlate, setAsOwner, notification, performRealisticSwap)

Give Temporary Keys

Temporary "temp" keys are used to temporarily give someone access to a vehicle. This allows you to manage it in the vehicle menu as your own. This functionality is by default implemented to give keys if you steal an NPC vehicle, or a vehicle spawned by a script that is not owned by anyone. This can easily be implemented into other resources such as vehicle renter scripts to temporarily give you full access to the vehicle. Example:

---@param vehicle integer? @Vehicle handler, if left empty it will use the player's current vehicle
---@param ignoreStolenCheck boolean @If true, it will ignore the stolen key check and give the keys regardless
exports["zyke_garages"]:GiveTempKeys(vehicle)

Open Impounder Menu

This export allows you to open the impounder menu just like the existing command. The export checks your job and performs all necessary actions to work. Example:

exports["zyke_garages"]:OpenImpounderMenu()

Set Lock State

Using this export you can set the current door lock status for vehicles with a vin number. Example:

---@param vin string
---@param state boolean
---@param lockpick boolean? @If you used this function because of a lockpick
---@return boolean, string? @Success, reason for failure
exports["zyke_garages"]:SetLockState(vin, state, lockpick)

Set Engine State

Using this export, you can set the current engine state for vehicles with a vin number. Example:

---@param vin string
---@param state boolean
---@return boolean, string? @Success, reason for failure
exports["zyke_garages"]:SetEngineState(vin, state)

Has Key

Check if the player has access to the vin number provided. Example:

---@param vin string
---@return boolean
exports["zyke_garages"]:HasKeys(vin)

Server Sided Exports

Set New Owner

If you want to set owners for vehicles through other resources, you can easily do so via our exports. Example:

---@param vin string? @VIN of the vehicle, not required if the vehicle is not owned by anyone
---@param newOwner string @Static identifier for the new owner, has to be citizenid for QBCore and identifier for ESX
---@param vehicleData table @Set to the vehicle's properties if vehicle is not owned
---@param financeData table? @Set to the vehicle's finance data if vehicle is not owned
---@param extras table? @Set to the vehicle's extras if vehicle is not owned
---@param transferer string @Simply used for logging purposes, set to the string of the transferer
---@param garageId string? @If provided, the vehicle will be set to this garage
exports["zyke_garages"]:SetNewOwner(vin, newOwner, vehicleData, financeData, extras, transferer, garageId)

Set Garage

Set a new garage for a vehicle. Example:

---@param vin string
---@param garage string
---@return boolean, string? @Success, failure reason
exports["zyke_garages"]:SetGarage(vin, garage)

Can Transfer Ownership

Check if you can transfer ownership of your vehicle or not. The conditions can be modified in zyke_garages/server/unlocked/functions.lua. Example:

---@param vin string
---@return boolean, string? @Success, failure reason
exports["zyke_garages"]:CanTransferOwnership(vin)

Initialize Vehicle

Initialize a spawned vehicle, ensuring it has all the required values to operate properly. Trigger this whenever another script handles the spawning of your vehicle. Example:

---@param vin string
---@param veh number
---@param setAsTemp boolean? @If the vehicle should be set as temporary, mainly used for persistent vehicles
---@return integer @Net id
exports["zyke_garages"]:InitializeVehicle(vin, veh, setAsTemp)

Shared Exports

Get Vin From Vehicle

This export returns the vin from a vehicle. If the vehicle doesn't have a vin it will ensure it and give it one, unless you specify it not to. Example:

---@param vehicle number @Vehicle number / vehicle handler
---@param copy boolean | nil @Copy the vin number that is returned
---@param disableEnsuring? boolean @Prevent a vin number from being created if the entity does not have one
---@return string | nil, boolean @Vin number, has ensured
exports["zyke_garages"]:GetVinFromVehicle(vehicle, copy, disableEnsuring)

Ensure Vehicle Vin

If you want to manually ensure a vehicle's vin number, you can do it with this export. Example:

---@param vehicle integer @Vehicle handler
---@param lockpick string? @Lockpick item, nil if not lockpicking
---@return string @VIN number
exports["zyke_garages"]:EnsureVehicleVin(vehicle, lockpick)

Get Vehicle Position

Returns the vehicle position if it has been taken out of the garage and exists. Example:

---@param vin string
---@return vector3 | nil
exports["zyke_garages"]:GetVehiclePosition(vin)

Set Waypoint To Vehicle

Set a basic waypoint to the vehicle provided. Example:

---@param vin string
---@return boolean @Success
exports["zyke_garages"]:SetWaypointToVehicle(vin)

Shared Events

Handle Vehicle Purchase

There's multiple ways to use this event, please refer to Setup for in-depth examples. If you are new to development, we recommend you use Handle Vehicle Purchase With Plate. This is the more performant version, since you have the values directly and don't need to find them, but more difficult to use. Example:

-- From client
---@param netId integer
---@param plate string
TriggerEvent("zyke_garages:HandleVehiclePurchase", netId, plate)

-- From server
---@param source integer @Source / player id
---@param netId integer
---@param plate string
TriggerClientEvent("zyke_garages:HandleVehiclePurchase", source, netId, plate)

Handle Vehicle Purchase With Plate

This command is similar to Handle Vehicle Purchase. This event performs a scan of nearby vehicles attempting to find the correct vehicle with the plate provided. If you can't run Handle Vehicle Purchase, run this. Example:

-- From client
---@param plate string
TriggerEvent("zyke_garages:HandleVehiclePurchaseWithPlate", plate)

-- From server
---@param source integer @Source / player id
---@param plate string
TriggerClientEvent("zyke_garages:HandleVehiclePurchaseWithPlate", source, plate)

Remove As Persistent

With this export you can deregister a vehicle as persistent. Unless this is executed, the vehicle will always respawn when removed. This has to be used whenever you want to remove a vehicle. Note that if you pass in the vehicle handle, you have to execute the export before the vehicle is removed. Example:

---@param vin string | integer @Also possible to pass in the vehicle handle
exports["zyke_garages"]:RemoveAsPersistent(vin)

Last updated