Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG][FIXED] THIS IS TO SAVE PEOPLE YEARS OF HEADACHE (YOU'RE WELCOME) #219

Closed
tmwtvtwitch opened this issue Feb 19, 2024 · 0 comments
Closed
Labels
bug Something isn't working

Comments

@tmwtvtwitch
Copy link

tmwtvtwitch commented Feb 19, 2024

Describe the bug
Some add-on cars not saving with admin menu, but others are.

To Reproduce
Steps to reproduce the behavior:

  1. add any add-on vehicle
  2. add vehicle to vehicle.lua
  3. use admin menu to save car, and says "cannot store vehicle in garage"

Expected behavior
not too long ago (8 months or so) there was ZERO issue saving ANY car added to vehicle.lua, NOW it's a crapshoot and i get told "the vehicle name is incorrect" when quite clearly it is indeed correct.

HOW TO FIX IT:

Server Side (server.lua)

RegisterNetEvent('qb-admin:server:SaveCar', function(mods, vehicle, _, plate, name)
local src = source
if QBCore.Functions.HasPermission(src, 'admin') or IsPlayerAceAllowed(src, 'command') then
local Player = QBCore.Functions.GetPlayer(src)
local result = MySQL.query.await('SELECT plate FROM player_vehicles WHERE plate = ?', { plate })
if result[1] == nil then
MySQL.insert('INSERT INTO player_vehicles (license, citizenid, vehicle, hash, mods, plate, state) VALUES (?, ?, ?, ?, ?, ?, ?)', {
Player.PlayerData.license,
Player.PlayerData.citizenid,
vehicle.model,
vehicle.hash,
json.encode(mods),
plate,
0
})
TriggerClientEvent('QBCore:Notify', src, Lang:t('success.success_vehicle_owner'), 'success', 5000)
else
TriggerClientEvent('QBCore:Notify', src, Lang:t('error.failed_vehicle_owner'), 'error', 3000)
end
else
BanPlayer(src)
end
end)

client side (events.lua)

RegisterNetEvent('qb-admin:server:SaveCar', function(mods, vehicle, _, plate, name)
local src = source
if QBCore.Functions.HasPermission(src, 'admin') or IsPlayerAceAllowed(src, 'command') then
local Player = QBCore.Functions.GetPlayer(src)
local result = MySQL.query.await('SELECT plate FROM player_vehicles WHERE plate = ?', { plate })
if result[1] == nil then
MySQL.insert('INSERT INTO player_vehicles (license, citizenid, vehicle, hash, mods, plate, state) VALUES (?, ?, ?, ?, ?, ?, ?)', {
Player.PlayerData.license,
Player.PlayerData.citizenid,
vehicle.model,
vehicle.hash,
json.encode(mods),
plate,
0
})
TriggerClientEvent('QBCore:Notify', src, Lang:t('success.success_vehicle_owner'), 'success', 5000)
else
TriggerClientEvent('QBCore:Notify', src, Lang:t('error.failed_vehicle_owner'), 'error', 3000)
end
else
BanPlayer(src)
end
end)

Finally: Manually add the vehicle hash and vehicle name to your database and VOILA! IT MAGICALLY WORKS!

@tmwtvtwitch tmwtvtwitch added the bug Something isn't working label Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant