ESX

ESX setup tutorial for "Advanced Ownable Rent Creator" script

This tutorial will help you disable your players to take out owned vehicles marked as rentable from the garage. If you don't manage to do it alone, please open ticket on our Discord Server.

What you need to find is function/event/callback in your garage's script server side where the script is getting all owned garage vehicles (esx_garage - "esx_garage:getVehiclesInParking"). Inside the function/event/callback you will find MySQL query where all vehicles from "owned_vehicles" table (usually owned_vehicles on es_extended) where owner = player's identifier. Example:

MySQL.query('SELECT * FROM `owned_vehicles` WHERE `owner` = @identifier AND `parking` = @parking AND `stored` = 1',
{
	['@identifier'] 	= xPlayer.identifier,
	['@parking']     	= parking
}, function(result)

	local vehicles = {}
	for i = 1, #result, 1 do
		table.insert(vehicles, {
			vehicle 	= json.decode(result[i].vehicle),
			plate 		= result[i].plate
		})
	end

	cb(vehicles)
end)

What you need to do is to inside the query selector add this code snippet:

AND rentable = 0

... so it shoud look like this:

MySQL.query('SELECT * FROM `owned_vehicles` WHERE `owner` = @identifier AND `parking` = @parking AND `stored` = 1 AND `rentable` = 0',
{
	['@identifier'] 	= xPlayer.identifier,
	['@parking']     	= parking
}, function(result)

	local vehicles = {}
	for i = 1, #result, 1 do
		table.insert(vehicles, {
			vehicle 	= json.decode(result[i].vehicle),
			plate 		= result[i].plate
		})
	end

	cb(vehicles)
end)

Do it for all query selectors.

Last updated