[RELEASE] renzu_garage - v1.8 - Advanced Garage Fivem

Today i have a problem with images of cars at garage menu. All of cars now have default image. How can i fix it?

is this turned on?

Config.use_renzu_vehthumb

if yes you should use vImagecreator

you can start it and once the globalstate have data you can stop the resource.

What is the line of code that removes a car from a private garage when you pull it out? I am trying to make this work with my valet app on my phone and I have it like 90% working. My only issue is when they call a car from a private garage it does not remove the car from the garage so even though the valet brings the car if they go back to the garage it will still be inside and they can even park the new one that the valet brought (so it pretty much dupes it). I cannot seem to figure out removing the car from private garage when the valet is called.

It even updates the sql databse correctly but the car still remains in the garage. This is the line of code I have in my valet app for when the car is called.

RegisterServerEvent('gksphone:valet-car-set-outside')
AddEventHandler('gksphone:valet-car-set-outside', function(plate)
  local _source = source
  if Config.cdGarages then
    MySQL.Async.execute('UPDATE '..Config.OwnedVehicles..' SET `stored` = @stored WHERE `plate` = @plate', {
      ['@plate'] = plate,
      ['@stored'] = 0,
    })
    MySQL.Async.execute('UPDATE '..Config.OwnedVehicles..' SET `garage_id` = @garage_id WHERE `plate` = @plate', {
      ['@plate'] = plate,
      ['@garage_id'] = 'A',
    })
      Citizen.Wait(500)
      TriggerClientEvent('renzu_garage:syncstate', plate, _source)
      TriggerClientEvent('gksphone:client:valecik', _source)
  end
end)

the logic of private garage is, when its inside , the garage_id is private

when you pull out change it to original garage_id the resource always make it Garage A when pulling out.

yes which is fine, but with the script i posted it marks the vehicle as not stored and sets the garage id to ā€œAā€ so in theory the car should disappear from private garage when valet is called but its not. The car remains in private garage even though valet brings the car and database updates correctly.

I believe it is because the car stays in the private_garages database even though the owned_vehicles updates correctly. I just cannot seem to figure out the right code to remove the car from the private_garages table when the valet is called.

you have to make the garage_id private

so it wont appear in this resource garage.

you need to make a exemption too in your valet script, that dont show any vehicle using private

But we want to be able to call the cars from the private garages we just want the cars to actually disappear from the private garage when it’s called. I was trying to look in the event in your script for the sql code that takes the car out of the private garage when you exit the garage but I am not finding it correctly. Simply changing the garage_id in the owned_vehicles table from ā€œprivateā€ to ā€œAā€ does not do it. Even if garage_id is changed to ā€œAā€ if the car is not removed from private_garages sql database then it will still appear in the private garage.

you cant do that as for now…
you need to remove the vehicle from private garage table.

this is how its geting removed when you choose a vehicle from private garage

local result = MysqlGarage(Config.Mysql,'fetchAll','SELECT * FROM private_garage WHERE identifier = @identifier and garage = @garage', {
            ['@identifier'] = identifier,
            ['@garage'] = id
        })
        local vehicles = json.decode(result[1].vehicles)
        local success = false
        for k,v in pairs(vehicles) do
            if v.vehicle == nil then v.taken = false end
            if v.taken and v.vehicle ~= nil and v.vehicle.plate == prop.plate then
                v.taken = false
                v.vehicle = nil
                success = true
                break
            end
        end
        local result = MysqlGarage(Config.Mysql,'execute','UPDATE '..vehicletable..' SET `'..stored..'` = @stored, '..garage__id..' = @garage_id, '..vehiclemod..' = @vehicle WHERE TRIM(UPPER(plate)) = @plate', {
            ['@vehicle'] = json.encode(prop),
            ['@garage_id'] = 'A',
            ['@plate'] = string.gsub(prop.plate:upper(), '^%s*(.-)%s*$', '%1'),
            ['@stored'] = 0
        })
        local result = MysqlGarage(Config.Mysql,'execute','UPDATE private_garage SET `vehicles` = @vehicles WHERE garage = @garage and identifier = @identifier', {
            ['@vehicles'] = json.encode(vehicles),
            ['@garage'] = id,
            ['@identifier'] = identifier,
        })

i can create a exports for this.

but it needs you to know the garage id of private garage and the current vehicle plate

EDIT:

you could try this new exports

local garageid = exports.renzu_garage:GetPrivateGaragefromPlate(source,plate)
if garageid then
       exports.renzu_garage:RemoveVehicleFromPrivate(source,plate,garageid)
end

i havent actually tested this yet, as i dont have a use case.

Ok I will test this out and let you know :+1:t4:. I was also curious do you know why when the vehicles spawn they receive a little damage? Like everytime I pull a car out the windows break and it gets a little dented. If I keep pulling it in and out it will eventually destroy the car.

Yes so i tested and export does not work. It’s so werid there’s no errors or anything. The car just remains in the garage unless the player themselves takes it out. Even though the code seems to be the exact same as when a player exits the garage. Is there a way to just disable private garages entirely? So that way there is just regular garages and parking? I am starting to notice some more bugs with private garages for instance players can pretty much put any car in a private garage even if they don’t own it. So they can steal NPC cars and other players cars and just keep them in a private garage. I also crash alot when going into private garage and sometimes when I pull cars out it spawns two cars on top of eachother.

UPDATE
So after a lot of tinkering I was able to get valet to work with the private garages. The only thing is this script that seems to not work for me is the disable private garages (i submitted issue on git) and vehicle keys which is fine as I have another vehicle key script I can use for now. But yea the vehicle keys only worked to a certain extent. I would receive keys when taking cars in and out of garages and the lockpicking worked on parked local cars. I could still pull NPCs out of their cars though and I couldn’t get /vehiclekeys or /garagekeys to pull up any UI.

i have replied to your issues in git regarding private garage.

about the keys, what exactly is your issue? you could open another one regarding keys.
and /vehiclekeys is disable if your using ox_inventory as its logic is item keys.
the garagekeys command should still work. as its the UI to request Garage keys.

Oh I didn’t know the UI disabled if ox inventory was enabled so that might be why But even still the garage keys ui does not work for me. I am also able to pull NPCs out of vehicles as well (unless this script doesn’t lock NPC cars I was just assuming based on other vehicle key scripts) I will open a issue on hit hub for the vehicle keys too

Love the script only issue im having is when server restarts the car is still in front of me when i spawn back in. How do you make it so that the car either gets sent to impound or garage when server restarts?

the garage resource currently uses persistent vehicle mode, if you locked the vehicle before restarting…so it will show up again after your server restart.

you could remove it by commenting out this line around line:99 keys.lua (server)

Is there a release that does not require Ox_Inventory by chance? The server im working on, will not be using Ox_Inventory, so was curious if you have a older release that doesnt require it.

it does, but i wont recommend it anymore as framework started using server entities that might conflict with keys system.

look for release page on github

Thanks for the update Renzu. I’m going to use parts of this but not all. I’m hoping I can disable what I dont need via config :slight_smile: I’ll come back if we find any bugs.
Very glad you’ve integrated this with ox_lib.

1 Like

SCRIPT ERROR: citizen:/scripting/lua/scheduler.lua:741: SCRIPT ERROR: @renzu_garage/server/server.lua:94: attempt to compare nil with number

can someone help please, cant find the solution :frowning:

where can i find this script