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
#Give Key
Give the player a key to the specified vehicle.
Example:
lua---@param identifier string | number -- Plate, VIN, or entity handle ---@return boolean local success = exports["zyke_garages"]:GiveKey(identifier)
#Has Key
Check if you have access to a specific vehicle.
Example:
lua---@param identifier string | number -- Plate, VIN, or entity handle ---@return boolean local hasKey = exports["zyke_garages"]:HasKey(identifier)
#Remove Key
Remove the key for a specific vehicle from a player.
Example:
lua---@param identifier string | number -- Plate, VIN, or entity handle ---@return boolean local success = exports["zyke_garages"]:RemoveKey(identifier)
#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:
lua---@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:
lua---@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:
lua---@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:
lua---@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:
luaexports["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:
lua---@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)
#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:
luaexports["zyke_garages"]:OpenImpounderMenu()
#Set Lock State
Using this export you can set the current door lock status for vehicles with a vin number.
Example:
lua---@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:
lua---@param vin string ---@param state boolean ---@return boolean, string? @Success, reason for failure exports["zyke_garages"]:SetEngineState(vin, state)
#Open Garage
Open a garage via an export.
Example:
lua---@param garageId string ---@param usedMenu? boolean exports["zyke_garages"]:OpenGarage(garageId, usedMenu)Example:
Grab the garage id from the section you are currently standing in, to open the garage. The example approach targets both normal garages & impounds.
lua-- EXPLICIT local _, currGarageId = exports["zyke_garages"]:IsInGarageSection() local _, currImpoundId = exports["zyke_garages"]:IsInImpoundSection() local id = currGarageId or currImpoundId if (id) then exports["zyke_garages"]:OpenGarage(id, true) end -- QUICK METHOD local _, id = exports["zyke_garages"]:IsInAnySection() if (id) then exports["zyke_garages"]:OpenGarage(id, true) end
#Is In Garage Section
Check if you are currently standing inside of a garage section. The garage id for the section you are in is returned as the second parameter, or nil.
Example:
lua---@return boolean, string? exports["zyke_garages"]:IsInGarageSection()
#Is In Impound Section
Check if you are currently standing inside of an impound section. The garage id for the section you are in is returned as the second parameter, or nil.
Example:
lua---@return boolean, string? exports["zyke_garages"]:IsInImpoundSection()
#Is In Any Section
Performs the #is-in-garage-section & #is-in-impound-section exports automatically to grab an id for easier integration of just one export.
Example:
lua---@return boolean, string? exports["zyke_garages"]:IsInAnySection()
#Safe Delete Vehicle
Safely delete a vehicle from the game world. This export handles vehicle lookup, configurable safety checks, and server-side persistence (saving vehicle properties before removal).
The export uses a concurrency guard to prevent multiple simultaneous deletions. All safety requirements are opt-in. If you pass no
reqstable, the vehicle will be deleted with no additional checks.Example:
lua---@param identifier string | integer -- Plate or vehicle entity handle ---@param showNotification? boolean -- Show built-in notifications on failure ---@param reqs? DeletionRequirements -- Opt-in safety checks ---@return boolean, string? @Success, reason for failure local success, reason = exports["zyke_garages"]:SafeDeleteVehicle(identifier, showNotification, reqs)DeletionRequirements:
entityOwner-boolean?- Iftrue, the player must be the network entity owner of the vehicle.
vehicleEmpty-boolean?- Iftrue, the vehicle must have no other players seated in it (ignores caller).
maxDistance-number?- Maximum allowed distance between the player and the vehicle. Checked on both client and server.Fail reasons:
"alreadyDeleting"- A deletion is already in progress.
"noVehicleFound"- No vehicle matched the identifier.
"notOwner"- Player is not the entity owner.
"vehicleNotEmpty"- Other players are seated in the vehicle.
"tooFar"- Player exceeded the max distance.
"noVinSpecified"- Server-side: vehicle has no VIN.
"unknownError"- Server callback failed or timed out.Example with all requirements:
lualocal veh = GetVehiclePedIsIn(PlayerPedId(), false) local success, reason = exports["zyke_garages"]:SafeDeleteVehicle(veh, true, { entityOwner = true, vehicleEmpty = true, maxDistance = 10.0, }) if (not success) then print("Deletion denied:", reason) end
#Server Sided Exports
#Transfer Ownership
This is a shorthand for transfering vehicle ownership with less arguments than SetNewOwner.
Click here to read more about it.
#Give Key
Give the player a key to the specified vehicle.
Example:
lua---@param plyId integer ---@param identifier string | number -- Plate, VIN, or entity handle ---@return boolean local success = exports["zyke_garages"]:GiveKey(plyId, identifier)
#Has Key
Check if a player has access to a specific vehicle.
Example:
lua---@param plyId integer ---@param identifier string | number -- Plate, VIN, or entity handle ---@return boolean local hasKey = exports["zyke_garages"]:HasKey(plyId, identifier)
#Remove Key
Remove the key for a specific vehicle from a player.
Example:
lua---@param plyId integer ---@param identifier string | number -- Plate, VIN, or entity handle ---@return boolean local success = exports["zyke_garages"]:RemoveKey(plyId, identifier)
#Set New Owner
If you want to set owners for vehicles through other resources, you can easily do so via our exports.
Example:
lua---@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:
lua---@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:
lua---@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.
NOTE that this is already automatically handled if you give a key for that vehicle.
Example:
lua---@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:
lua---@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:
lua---@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:
lua---@param vin string ---@return vector3 | nil exports["zyke_garages"]:GetVehiclePosition(vin)
#Set Waypoint To Vehicle
Set a basic waypoint to the vehicle provided.
Example:
lua---@param vin string ---@return boolean @Success exports["zyke_garages"]:SetWaypointToVehicle(vin)
#Give Vehicle (Basic)
Give a parked vehicle to a player from a model name or model hash.
This is the simplest export for rewards from other server resources, such as wheel spin prizes. It creates the vehicle ownership, generates a VIN and plate when needed, places the vehicle in a garage, and prepares the saved vehicle so the winner can grab it from their garage.
Example:
lua---@param model string | integer @ Vehicle model name or hash ---@param winner integer | string @ Player server ID or character identifier ---@param options? table @ Optional settings ---@return boolean success ---@return table | string vehicleAward @ Created vehicle data or failure reason local success, vehicleAward = exports["zyke_garages"]:GiveVehicle(model, winner, options)Basic usage:
lualocal winner = source local success, vehicleAward = exports["zyke_garages"]:GiveVehicle("adder", winner) if (not success) then print("Failed giving vehicle:", vehicleAward) return end print("Vehicle given:", vehicleAward.vin, vehicleAward.plate, vehicleAward.garage)Options table usage:
lualocal success, vehicleAward = exports["zyke_garages"]:GiveVehicle({ model = "adder", winner = source, garageId = "legionsquare", plate = "WINNER01", }) if (not success) then print("Failed giving vehicle:", vehicleAward) return end print("Vehicle given:", vehicleAward.vin, vehicleAward.plate, vehicleAward.garage)Options:
model-string | integer- Vehicle model name or hash. Only needed when using the options table as the first argument.
winner-integer | string- Winner player server ID or character identifier. Only needed when using the options table as the first argument.
targetPlayerId-integer?- Alias forwinnerwhen giving to an online player.
ownerIdentifier-string?- Alias forwinnerwhen giving to a character identifier directly.
plate-string?- Custom plate. If not provided, a unique plate is generated.
garageId-string?- Garage to place the vehicle in. If not provided, the winner's default garage is used.
vehicleType-string?- Vehicle type used when choosing a default garage. Defaults to automobile.
modelLabel-string?- Display label saved for the vehicle.
mods-table?- Vehicle properties to save with the vehicle.
fuel-number?- Fuel level. Defaults to 100.
engine-number?- Engine health. Defaults to 1000.
body-number?- Body health. Defaults to 1000.
license-string?- Account license for offline inserts when the framework cannot resolve it automatically.
transferer-integer | string?- Log handler. Defaults toserver.
professionType-"job" | "gang"?- Required when giving the vehicle to a profession and the profession type cannot be inferred.
disableLogging-boolean?- Prevents the ownership log.Returned vehicle data:
vin- Created vehicle VIN.
plate- Created vehicle plate.
garage- Garage where the vehicle was placed.
ownerIdentifier- Character identifier that received the vehicle.
model- Vehicle model name or hash that was passed to the export.If the export fails, it returns
falseand a failure reason string.
#Shared Exports
#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:
lua---@param vin string | integer @Also possible to pass in the vehicle handle exports["zyke_garages"]:RemoveAsPersistent(vin)
