forked from Simnation/Main
resources/[jobs]/[civ]/mh_jobgarage/server/server.lua aktualisiert
This commit is contained in:
parent
728ac0c2d1
commit
4caf26bdea
1 changed files with 26 additions and 15 deletions
|
@ -43,25 +43,36 @@ AddEventHandler('mh_jobgarage:DeleteFromList', function(plate)
|
||||||
local _source = source
|
local _source = source
|
||||||
local Player = QBCore.Functions.GetPlayer(_source)
|
local Player = QBCore.Functions.GetPlayer(_source)
|
||||||
local pedid = Player.PlayerData.citizenid
|
local pedid = Player.PlayerData.citizenid
|
||||||
local veh_opt = MySQL.query.await("SELECT * FROM mh_jobgarage WHERE plate = ?", {plate})
|
local keycounter = nil
|
||||||
print(json.encode(veh_opt))
|
MySQL.query("SELECT value FROM mh_jobgarage WHERE plate = ?", {plate}, function(rs)
|
||||||
--local veh_opt = json.encode(veh_optt)
|
if rs ~= nil and rs[1] ~= nil then
|
||||||
|
keycounter = rs[1].value
|
||||||
|
else
|
||||||
|
keycounter = 0
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
if keycounter == nil then
|
||||||
|
TriggerClientEvent('mh_jobgarage:notify', _source, "Schlüsselkasten", "Fehler, versuche es Später erneut.", "inform")
|
||||||
|
end
|
||||||
|
|
||||||
|
if keycounter ~= 0 then
|
||||||
MySQL.query("SELECT * FROM vehicle_keys WHERE plate = ? and owner = ?", {plate, pedid}, function(rs)
|
MySQL.query("SELECT * FROM vehicle_keys WHERE plate = ? and owner = ?", {plate, pedid}, function(rs)
|
||||||
if rs ~= nil and rs[1] ~= nil then
|
if rs ~= nil and rs[1] ~= nil then
|
||||||
MySQL.query("UPDATE vehicle_keys SET count = count + ? WHERE plate = ? and owner = ?", {veh_opt.count, plate, pedid},function(rowsChange)
|
MySQL.query("UPDATE vehicle_keys SET count = count + ? WHERE plate = ? and owner = ?", {keycounter, plate, pedid},function(rowsChange)
|
||||||
if rowsChange then
|
if rowsChange then
|
||||||
TriggerClientEvent('mh_jobgarage:notify', _source, "Schlüsselkasten", "Du hast "..veh_opt.count.."x Schlüssel bekommen.", "success")
|
TriggerClientEvent('mh_jobgarage:notify', _source, "Schlüsselkasten", "Du hast "..keycounter.."x Schlüssel bekommen.", "success")
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
else
|
else
|
||||||
MySQL.query("INSERT INTO vehicle_keys(owner, plate, count) VALUES (?, ?, ?)", {pedid, plate, veh_opt.count}, function(rowsChange)
|
MySQL.query("INSERT INTO vehicle_keys(owner, plate, count) VALUES (?, ?, ?)", {pedid, plate, keycounter}, function(rowsChange)
|
||||||
if rowsChange then
|
if rowsChange then
|
||||||
TriggerClientEvent('mh_jobgarage:notify', _source, "Schlüsselkasten", "Du hast "..veh_opt.count.."x Schlüssel bekommen.", "success")
|
TriggerClientEvent('mh_jobgarage:notify', _source, "Schlüsselkasten", "Du hast "..keycounter.."x Schlüssel bekommen.", "success")
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
MySQL.query("UPDATE player_vehicles SET citizenid = ? WHERE plate = ?", {pedid, plate})
|
MySQL.query("UPDATE player_vehicles SET citizenid = ? WHERE plate = ?", {pedid, plate})
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue