WARNING: Upon the first run of the script, all vehicles will be placed in a garage. If you're using custom garages, remove all vehicles from various impound lots (putting them in a garage) and deactivate any impound functions present in your custom garage. Then, you'll need to use my impound. If you delete some vehicles from my database, the same logic will apply, returning them to the pre-set garage in your garage table.
Our Garage
(true in clConfig.GarageEnable): If you wish to utilize our garage system, all vehicles are initially placed in a random garage registered in the garagesConfig. This process only occurs the first time you use the script, or if you delete some vehicles from my database, in which case they will be reinserted into a random garage. Afterwards, you can freely move your vehicles, and everything will function smoothly.
No Garage
(false in clConfig.GarageEnable): If you're not using any garage system initially, we recommend starting with "true" to enable our garage. This allows users to remove their vehicles from the garage. Afterwards, you can disable the garage system to give vehicles a designated position to stay.
3. Configuration
You can modify many aspects of our script according to your framework and some scripts you use.
All in the folder /editable
Explentation /editable/Config.lua
svConfig = { Framework ="QBCORE", -- ESX/QBCORE/CUSTOM Blip = { ---- GPS enabled =true, style =227, display =2, scale =0.6, color =0 }}if svConfig.Framework =="ESX" then svConfig.ColumnPropName = 'vehicle' -- the name of the column with the prop of the vehicle (vehicleshoptable)
svConfig.ColumnOwnerName ='owner' -- the name of the column with the owner (vehicleshoptable) svConfig.ColumnPlateName ='plate' -- the name of the column with the plate (vehicleshoptable) svConfig.Tablename = 'owned_vehicles' -- the name of the table where you find plate and prop of the vehicle (vehicleshoptable)
elseif svConfig.Framework =="QBCORE" then svConfig.ColumnPropName ='mods' -- the name of the column with the prop of the vehicle (vehicleshoptable) svConfig.ColumnOwnerName ='license' -- the name of the column with the owner (vehicleshoptable) svConfig.ColumnPlateName ='plate' -- the name of the column with the plate (vehicleshoptable) svConfig.Tablename = 'player_vehicles' -- the name of the table where you find plate and prop of the vehicle (vehicleshoptable)
else svConfig.ColumnPropName ='' -- the name of the column with the prop of the vehicle (vehicleshoptable) svConfig.ColumnOwnerName ='' -- the name of the column with the owner (vehicleshoptable) svConfig.ColumnPlateName ='' -- the name of the column with the plate (vehicleshoptable) svConfig.Tablename ='' -- the name of the table where you find plate and prop of the vehicle (vehicleshoptable)endclConfig = { vehiclespawnheading =229.14476013184, impoundcoords=vec3(409.874176, -1623.357788, 29.291956), impoundHeading =0, impoundGarageCamera = { coords =vec3(405.473663, -1630.699585, 32.693623), rotation =vec3(0.000000, -0.000000, -159.408722) }, vehiclespawncoords =vec3(408.299194, -1638.614502, 29.291956), impoundprice =0, currency ="$", openmenukey =51, blip = { enable =true, sprite =50, color =0, display =2, size =1.0, }, Locale = { impound ="Impound", impoundm ="Impound Menu", wait ="Wait 5 second...", vehiclenotfound ="Vehicle not found!", emptyarea ="Area not empty!", press ="Press ~INPUT_PICKUP~ to open impound menu", noemptyvehicle ="Vehicle isn't empty!", loading ="Loading assets", }, EnableDeformation =true, --- BETA GarageEnable =true, }GarageLocale = { SettingChanged ="Settings Changed!", CarSpawned ="Car spawned!", NearEntity ="There's some vehicle near the spawn point", VehicleDespawned ="Vehicle Despawned!", NotYourVehicle ="This vehicle isn't yours", LeaveYourVehicle ="Press ~INPUT_PICKUP~ to park your vehicle in the garage", OpenMenu ="Press ~INPUT_PICKUP~ to open the garage menu",}garagesConfig = { ['centralpark'] = { Title ="Garage Central", MarkerCoords =vec3(224.93, -791.1, 30.7), CameraCoords = { coords =vec3(236.169662, -803.035767, 30.177063), rotation =vec3(0.000000, -0.000000, 111.114067) }, SpawnCoords = { coords =vec3(229.404892, -807.967102, 30.497652), heading =160.34858703613 } }, ['2-teatro'] = { Title ="Garage Teatro", MarkerCoords =vec3(643.849060, 619.011353, 128.911057), CameraCoords = { coords =vec3(647.941833, 615.945557, 128.911057), rotation =vec3(-0.000000, -0.000000, -53.180214) }, SpawnCoords = { coords =vec3(653.667664, 620.077576, 128.911057), heading =333.35238647461 } }, ['police'] = { Title ="Garage Police Station", MarkerCoords =vec3(643.849060, 619.011353, 128.911057), CameraCoords = { coords =vec3(647.941833, 615.945557, 128.911057), rotation =vec3(-0.000000, -0.000000, -53.180214) }, SpawnCoords = { coords =vec3(653.667664, 620.077576, 128.911057), heading =333.35238647461 } }, ['police'] = { Title ="Garage Police Station", MarkerCoords =vec3(428.119598, -1016.908508, 28.959061), CameraCoords = { coords =vec3(435.770416, -1026.576782, 28.836340), rotation =vec3(0.000000, 0.000000, 58.624420) }, SpawnCoords = { coords =vec3(430.405365, -1021.759033, 28.825375), heading =88.94441986084 } }, ['paleto'] = { Title ="Garage Paleto", MarkerCoords =vec3(-445.828430, 6047.094727, 31.340557), CameraCoords = { coords =vec3(-449.024414, 6045.612793, 31.340553), rotation =vec3(0.000000, -0.000000, -122.982864) }, SpawnCoords = { coords =vec3(-439.675751, 6039.982422, 31.340557), heading =285.19836425781 } }}
svConfig:
Framework: Specifies the framework being used (ESX, QBCORE, or CUSTOM).
Blip:
enabled: Indicates whether the GPS blip feature is enabled .
Depending on the framework specified, different configurations are set:
ColumnPropName: Name of the column storing vehicle properties.
ColumnOwnerName: Name of the column storing vehicle owner information.
ColumnPlateName: Name of the column storing vehicle plate information.
Tablename: Name of the table containing vehicle data.
clConfig:
vehiclespawnheading: Heading angle for vehicle spawning.
impoundcoords: Coordinates for impound location.
impoundHeading: Heading angle for impound location.
impoundGarageCamera: Coordinates and rotation for the impound garage camera.
vehiclespawncoords: Coordinates for vehicle spawn point.
impoundprice: Impound price.
currency: Currency symbol.
openmenukey: Key to open menu.
blip: Blip settings.
Locale: Localization strings for messages and notifications.
GarageEnable: Indicates whether the garage feature is (true/false) Check GARAGE section
EnableDeformation: If you want vehicle deformations to be saved, set it to true, but remember that this is a new beta setting. (Beta Version)
GarageLocale:
Localization strings for garage-related UI elements.
garagesConfig:
Configuration for our garages:
Title: Name of the garage.
MarkerCoords: Coordinates of the marker indicating the garage location.
CameraCoords: Coordinates and rotation for the garage camera.
SpawnCoords: Coordinates and heading for vehicle spawn point within the garage.
Here you can modify the GetVehicleProperties and SetVehicleProperties functions according to the tuning script you use. Many scripts have custom functions for saving vehicle skins.
Explentation /editable/editserver.Lua
function GetIdentifier(source) ---- To compare Owner of the car and players in game (this function need if you use CHAR1/CHAR2 etc) and blip
if svConfig.Framework =="ESX" then ESX = exports['es_extended']:getSharedObject()local xPlayer = ESX.GetPlayerFromId(source)if xPlayer ~=nilthenreturn xPlayer.identifierelsereturnnilendelseif svConfig.Framework =="QBCORE" thenreturnGetPlayerIdentifier(source, 0)elsereturnGetPlayerIdentifier(source, 0):gsub("license:", "")endendRegisterServerEvent("df_impound:restoreVehicle", function(source,plate,prop)if svConfig.Framework =="ESX" then ESX = exports['es_extended']:getSharedObject()local xPlayer = ESX.GetPlayerFromId(source)if xPlayer.getMoney() >=1000thenlocal cr = clConfig.impoundcoordslocal crh = clConfig.impoundHeadinglocal crd = { coords = { x = cr.x, y = cr.y, z = cr.z }, h = crh } Spawnvehicleforgarage(prop.model, clConfig.impoundcoords, clConfig.impoundHeading, json.encode(prop), source)
TriggerClientEvent("df:ShowNotification", source, "Car restored!") xPlayer.removeMoney(1000)elseTriggerClientEvent("df:ShowNotification", source, "No money!")endelseif svConfig.Framework =="QBCORE" thenlocal QBCore = exports['qb-core']:GetCoreObject()local xPlayer = QBCore.Functions.GetPlayer(source)if xPlayer.PlayerData.money.cash >=1000thenlocal cr = clConfig.vehiclespawncoordslocal crh = clConfig.vehiclespawnheadinglocal crd = { coords = { x = cr.x, y = cr.y, z = cr.z }, h = crh } Spawnvehicleforgarage(prop.model, clConfig.impoundcoords, clConfig.impoundHeading, json.encode(prop), source)
TriggerClientEvent("df:ShowNotification", source, "Car restored!") xPlayer.Functions.RemoveMoney("cash", 1000)elseTriggerClientEvent("df:ShowNotification", source, "No money!")endelseprint("Setup for your framework")endend)
Here you can modify the GetIdentifier (xPlayer.identifier(), GetPlayerIdentifier(source, 0)) functions according to your framework, and the function that deducts money (xPlayer.getMoney(),PlayerData.money.cash) from the player.
Here you can set your custom notifications. (ShowHelpNotification,ShowNotification)
4. Exports
CarLocking
To trigger the opening or closing of car doors within your car locking system, utilize the CarLocking export provided by this script. This export allows for seamless integration of car door operations into your existing vehicle management logic.
bool: A boolean value indicating the desired action:
2: Locks the car doors.
1: Unlocks the car doors.
Integration Guide:
Server-Side Implementation:
Ensure the export is placed within a Lua file executed on the server side of your FiveM resource or framework.
Location in Car Locking Script:
Integrate the CarLocking export within the section of your car locking script responsible for managing vehicle interactions.
Usage:
Call the CarLocking export whenever locking or unlocking car doors is required within your car locking script.
Example Usage:
-- Example usage within your car locking script-- Ensure execution on the server side-- Locking a car with the plate "ABC123"exports['df_nocardespawn']:CarLocking("ABC123", 2)-- Unlocking a car with the plate "XYZ789"exports['df_nocardespawn']:CarLocking("XYZ789", 1)
By following these guidelines, you can seamlessly integrate the CarLocking export into your car locking script, enabling precise control over car door operations.
Gps
To toggle the visibility of the GPS on your vehicle, use the following export:
exports['df_nocardespawn']:GpsState(plate, bool)
plate: The license plate of the targeted vehicle.
bool: A boolean value indicating the desired GPS state:
0: GPS enabled.
1: GPS disabled.
Integration Guide:
Server-Side Implementation:
Ensure this export is placed within a Lua file executed on the server side of your FiveM resource or framework.
Location in Script:
Integrate the GpsState export within your script's logic for managing vehicle features or GPS systems.
Usage:
Call the GpsState export whenever you need to add or remove the GPS from a vehicle.
Example Usage:
-- Example usage within your Lua script-- Ensure execution on the server side-- Removing GPS from a car with the plate "ABC123"exports['df_nocardespawn']:GpsState("ABC123", 0)-- Adding GPS to a car with the plate "XYZ789"exports['df_nocardespawn']:GpsState("XYZ789", 1)
By following these guidelines, you can seamlessly manage the visibility of GPS on your vehicles, enhancing the realism of your gameplay experience.
Impound
To trigger an impound from the client side of your police job or impound function, you can utilize the following export:
exports['df_nocardespawn']:ImpoundCar()
This export will trigger the impound action client-side.
Make sure to call this export from the appropriate location within your client-side script where you want the impound action to be triggered. This could be within a police job script or any other script responsible for impounding vehicles.
-- Example usage to change the vehicle name in garages and on the GPSfunctionChangeVehicleNameInGarage(plate,name)-- Call the export to change the vehicle name exports['df_nocardespawn']:ChangeVehicleGpsName(plate, name)end
You can call this function wherever necessary in your server-side Lua script to update the name of a vehicle in the garage and on the GPS. Make sure to provide the license plate (plate) and the new name (name) as arguments to the function.
You can call this function when you deposit the vehicle in your server-side Lua Garage Custom script, this function don't delete the vehicle only disable the auto respawn logic. Make sure to provide the license plate (plate)
QBCore.Functions.CreateCallback('qb-garages:server:canDeposit', function(source,cb,plate,type,garage,state)local Player = QBCore.Functions.GetPlayer(source)local isOwned = MySQL.scalar.await('SELECT citizenid FROM player_vehicles WHERE plate = ? LIMIT 1', { plate })if isOwned ~= Player.PlayerData.citizenid thencb(false)returnend if type == 'house' and not exports['qb-houses']:hasKey(Player.PlayerData.license, Player.PlayerData.citizenid, Config.Garages[garage].houseName) then
cb(false)returnendif state ==1then MySQL.update('UPDATE player_vehicles SET state = ?, garage = ? WHERE plate = ?', { state, garage, plate }) exports['df_nocardespawn']:Despawnvehicleforgarage(plate)cb(true)elsecb(false)endend)
QBCore.Functions.CreateCallback('qb-garages:server:canDeposit', function(source,cb,plate,type,garage,state)local Player = QBCore.Functions.GetPlayer(source)local isOwned = MySQL.scalar.await('SELECT citizenid FROM player_vehicles WHERE plate = ? LIMIT 1', { plate })if isOwned ~= Player.PlayerData.citizenid thencb(false)returnend if type == 'house' and not exports['qb-houses']:hasKey(Player.PlayerData.license, Player.PlayerData.citizenid, Config.Garages[garage].houseName) then
cb(false)returnendif state ==1then MySQL.update('UPDATE player_vehicles SET state = ?, garage = ? WHERE plate = ?', { state, garage, plate })cb(true)elsecb(false)endend)
You can call this function when you retrieve the vehicle in your server-side Lua script for custom garages. This function spawns the vehicle without using different spawn logic. Ensure to provide the license plate (plate), coordinates (coord) as a Vector3, heading for spawn (heading), vehicle modifications (prop), and a task wrap (taskwrap) if you pass the player's source, which will automatically seat the player inside the vehicle.