[ESX] Kuana_Garage 3.0 (make your garage system more realistic)

Someone fix for errors?
Screenshot_1

ESX.UI.Menu.Open(

        'default', GetCurrentResourceName(), 'spawn_vehiclereload',

        {

            title    = _U('garage'),

            align    = 'top-left',

            elements = elements,

        },

        

        function(data, menu)

        --  Citizen.Wait(50)

                for i=1, #veh, 1 do

                    if veh then

                        local vehiclePropsn  = ESX.Game.GetVehicleProperties(veh[i])

                    

                            -- do whatever threw the err

                    if vehiclePropsn ~= nil and data.current.value.plate ~= nil then

                        if vehiclePropsn.plate == data.current.value.plate then

                            podespawn = false

                            break

                        else

                            podespawn = true

                        end

                    else

                        podespawn = true

                    end

                tend

            --  return nil

        end

Hey @KUANA do you know anything about make this work with this extended?

boas desculpa o mau ingles , mas ja sabes alguma coisa me colocar isto a funcionar com o novo extended , sem utilizar o essentialmode?
é que estou com um problema , quando faco o /garagem nao aparece os carros e esta tudo correcto , sao meus (estao na BD) nao da erros ao comprar

Help. I have no vehicles in my garage when i open the garage. there are 2 vehicles in the database but can’t see them in my garage

Where is the player deleted the vehicle when he leaves the game to function?

The /procarro command does not work. As shown in the video, the menu does not appear. I have a police job, but the menu does not appear and there are no errors on the console. Other functions will work. Help.

hello guys! so if i want to trigger the garage menu in a interact menu. how would i go to make it?

im kinda noobie to lua so i would love and highly appreciate the help!

regards jakob

‘scrollIntoView’ error should be fixed with this Pull Request

Hey, I managed to make everything work so i’ll try to help you guys.

The first thing i did was to modify the sql file “kuana.sql”

CREATE TABLE IF NOT EXISTS owned_vehicles (
owner varchar(40) NOT NULL,
plate varchar(12) NOT NULL,
vehicle longtext,
type VARCHAR(20) NOT NULL DEFAULT ‘car’,
job VARCHAR(20) NULL DEFAULT NULL,
stored TINYINT NOT NULL DEFAULT ‘0’,
state tinyint(1) NOT NULL DEFAULT ‘0’ COMMENT ‘State of the car’,
x varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT ‘0’,
y varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT ‘0’,
z varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT ‘0’,
h varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT ‘0’,
health int(11) DEFAULT ‘0’,
nitro varchar(50) NOT NULL DEFAULT ‘nao’,
lockcheck varchar(50) NOT NULL DEFAULT ‘nao’,
lastid int(20) DEFAULT NULL,
PRIMARY KEY (plate)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

This is how mine looks. You’re gonna have to import it in your database and delete the previous “owned_vehicles” (in your database) if you have one. (You probably do if you installed ESX_Vehicleshop)

I’ve done this cos I think the original SQL file messes up the order of the columns, resulting in the vehicleshop script acting weird.

The second thing i did was to replace the ESX.UI.Menu.Open code so it looks like this:(You can find it on Kuana_Garage/client.lua Line: 749)

ESX.UI.Menu.Open(
‘default’, GetCurrentResourceName(), ‘spawn_vehiclereload’,

    {

        title    = _U('Veicoli'),

        align    = 'top-left',

        elements = elements,

    },

    

    function(data, menu)

    --  Citizen.Wait(50)

            for i=1, #veh, 1 do

                if veh then

                    local vehiclePropsn  = ESX.Game.GetVehicleProperties(veh[i])

                

                        -- do whatever threw the err

                if vehiclePropsn ~= nil and data.current.value.plate ~= nil then

                    if vehiclePropsn.plate == data.current.value.plate then

                        podespawn = false

                        break

                    else

                        podespawn = true

                    end

                else

                    podespawn = true

                end

            end

        --  return nil

    end

It continues with if podespawn == true then
ESX.TriggerServerCallback… and so on (so you get a reference on where to put it)

The last thing i did, I went on the Server/main.lua of ESX_VehicleShop and added this

RegisterServerEvent(‘carshop:setVehicleOwned’)
AddEventHandler(‘carshop:setVehicleOwned’, function (vehicleProps)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)

MySQL.Async.execute('INSERT INTO owned_vehicles (owner, plate, vehicle, x, y, z, h, health) VALUES (@owner, @plate, @vehicle, @xx, @yy, @zz, @hh, @vida)',
{
	['@owner']   = xPlayer.identifier,
	['@plate']   = vehicleProps.plate,
	['@vehicle'] = json.encode(vehicleProps),
	["@xx"] = -245.86,
	["@yy"] = 6257.2,
	["@zz"] = 31.09,
	["@hh"] = 223.97,
	["@vida"] = 1000
}, function (rowsChanged)
	TriggerClientEvent('esx:showNotification', _source, "O Carro com a matricula ~y~"..vehicleProps.plate.."~w~ foi lhe ~g~entregue~w~.")
end)

end)

Right before the function “Pay Rent”

For me these steps worked, and the script is running like a champ.
If you have any issues feel free to message me or reply here, i’ll try my best to help.

NOTE: Im not a scripter/programmer of any sort, im just a normal dude that tries things with a bit of logic to make them work, so don’t expect me to know everything!

1 Like

My only problem with this script is with the search command … I typed the plate number correctly and it wont show me the menu … I even fixed the menu wont scroll\opens right, and i still cant search for car

can someone help me with this problem ?

The only thing i could think of is: It only works with purchased vehicles from the vehicleshop. Are you sure you input the correct plate (and by correct i mean adding spaces and caps letters)?

Cos it works fine for me

Also you could try to see if any errors display in the F8 menu (after you search for the plate)