You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Some add-on cars not saving with admin menu, but others are.
To Reproduce
Steps to reproduce the behavior:
add any add-on vehicle
add vehicle to vehicle.lua
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!
The text was updated successfully, but these errors were encountered:
Describe the bug
Some add-on cars not saving with admin menu, but others are.
To Reproduce
Steps to reproduce the behavior:
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!
The text was updated successfully, but these errors were encountered: