[H@mer] Garage (GTA:O Style)

Thumbnail

Config

QBCore example

Config.LoadGarage = function(source) -- When player no vehicle press E into garage.
	local mysql = MySQL.Sync.fetchAll('SELECT vehicle, mods, plate FROM `player_vehicles` WHERE steam= @steam',
	{
		['@steam'] = GetIdentifier(source),
	})

	local VehData = {}
	for k,v in pairs(mysql) do
		table.insert(VehData, { -- This is data using in clinet, just change MySQL query and push data on this.
			model = v.vehicle, -- string or number, Example is Bmx ("bmx" or 1131912276)
			plate = v.plate, -- string of vehicle plate, Example ("AAA 116")
			mod = Config.GetVehicleMod(v.mods), -- Set vehicle mod data. (readme props.lua)
		})
	end
	return VehData
end

ESX eample.

Config.LoadGarage = function(source) -- When player no vehicle press E into garage.
	local mysql = MySQL.Sync.fetchAll('SELECT vehicle FROM `owned_vehicles` WHERE identifier = @identifier',
	{
		['@identifier'] = GetIdentifier(source),
	})

	local VehData = {}
	for k,v in pairs(mysql) do
		local vehicle = json.decode(v.vehicle)
		
		table.insert(VehData, { -- This is data using in clinet, just change MySQL query and push data on this.
			model = vehicle.model, -- string or number, Example is Bmx ("bmx" or 1131912276)
			plate = vehicle.plate, -- string of vehicle plate, Example ("AAA 116")
			mod = Config.GetVehicleMod(vehicle), -- Set vehicle mod data. (readme props.lua)
		})
		
	end
	return VehData
end

Info

  • Easy Config.
  • No database change.
  • Example database file.
  • Test on exp, vrp, qbcore.
  • No capacity limit (use elevator).
  • Display vehicle info.

Buy On Tebex

Code is accessible No
Subscription-based No
Lines (approximately) 1000
Requirements oxmysql or fivem-mysql-async
Support Yes

Very good, but I use qbcore, the database table is player_vehicles.mods, the vehicle is saved, but when I leave the garage and enter the garage again, I will find that the vehicle no longer exists, can you solve this problem?

Checkout last update, you will see config compatible with any system.


The car is ok when it is deposited, thank you, but now there is a problem when you press w to drive out



image
Your script is great, can you give me another look, please

Update newest, I fixed it.
Change to this for saving server cpu.

Config.LoadGarage = function(source) -- When player no vehicle press E into garage.
	local mysql = MySQL.Sync.fetchAll('SELECT vehicle, mods, plate FROM `player_vehicles` WHERE steam= @steam',
	{
		['@steam'] = GetIdentifier(source),
	})

	local VehData = {}
	for k,v in pairs(mysql) do
		table.insert(VehData, { -- This is data using in clinet, just change MySQL query and push data on this.
			model = v.vehicle, -- string or number, Example is Bmx ("bmx" or 1131912276)
			plate = v.plate, -- string of vehicle plate, Example ("AAA 116")
			mod = Config.GetVehicleMod(v.mods), -- Set vehicle mod data. (readme props.lua)
		})
	end
	return VehData
end
1 Like

Thanks, your scripts are great

1 Like

This for QB or It can use this code with esx

This ESX exampke.

Config.LoadGarage = function(source) -- When player no vehicle press E into garage.
	local mysql = MySQL.Sync.fetchAll('SELECT vehicle FROM `owned_vehicles` WHERE identifier = @identifier',
	{
		['@identifier'] = GetIdentifier(source),
	})

	local VehData = {}
	for k,v in pairs(mysql) do
		local vehicle = json.decode(v.vehicle)
		
		table.insert(VehData, { -- This is data using in clinet, just change MySQL query and push data on this.
			model = vehicle.model, -- string or number, Example is Bmx ("bmx" or 1131912276)
			plate = vehicle.plate, -- string of vehicle plate, Example ("AAA 116")
			mod = Config.GetVehicleMod(vehicle), -- Set vehicle mod data. (readme props.lua)
		})
		
	end
	return VehData
end