forked from Simnation/Main
resources/[jobs]/[civ]/mh_jobgarage/server/server.lua aktualisiert
This commit is contained in:
parent
c900f4d57b
commit
74868c4e12
1 changed files with 12 additions and 35 deletions
|
@ -16,47 +16,24 @@ end)
|
|||
|
||||
-- mh_jobgarage:AddVehicleToJob VARIABLEN:
|
||||
|
||||
QBCore.Functions.CreateCallback('mh_jobgarage:AddVehicleToJob', function(source, cb, plate, stats)
|
||||
RegisterServerEvent('mh_jobgarage:AddVehicleToJob')
|
||||
AddEventHandler('mh_jobgarage:AddVehicleToJob', function(plate, stats)
|
||||
local Player = QBCore.Functions.GetPlayer(source)
|
||||
local pedid = Player.PlayerData.citizenid
|
||||
local pedjob = Player.PlayerData.job.name
|
||||
|
||||
local isOwner = CheckVehicleOwner(pedid, plate)--MySQL.query("SELECT * FROM player_vehicles WHERE citizenid = ? and plate = ?", {pedid, plate})
|
||||
local haveKeys = MySQL.query("SELECT * FROM vehicle_keys WHERE owner = ? and plate = ?", {pedid, plate})
|
||||
|
||||
if isOwner and haveKeys then
|
||||
if haveKeys[1].count == stats[2] then
|
||||
MySQL.query("DELETE FROM vehicle_keys SET owner = ? AND plate = ?", {pedid, plate})
|
||||
elseif haveKeys[1].count > stats[2] then
|
||||
MySQL.query("UPDATE vehicle_keys SET count = count - ? WHERE owner = ? and plate = ?", {stats[2], pedid, plate})
|
||||
MySQL.query("SELECT * FROm vehicle_keys WHERE owner = ? AND plate = ?", {pedid, plate}, function(rs)
|
||||
if rs ~= nil and rs[1] ~= nil then
|
||||
if rs[1].count == stats[2] then
|
||||
MySQL.query("DELETE FROM vehicle_keys WHERE owner = ? AND plate = ?", {pedid, plate})
|
||||
else
|
||||
MySQL.query("UPDATE vehicle_keys SET count = count - ? WHERE owner = ? AND plate = ?", {stats[2], pedid, plate})
|
||||
end
|
||||
|
||||
MySQL.query("INSERT INTO mh_jobgarage(job, rang, value, plate, name, closed) VALUES (?, ?, ?, ?, ?, ?)", {pedjob, stats[3], stats[2], plate, stats[1], "false"}, function(rs)
|
||||
if rs then
|
||||
MySQL.query("UPDATE player_vehicles SET citizenid = ? WHERE owner = ? and plate = ?", {"11111111111", pedid, plate})
|
||||
cb({
|
||||
status = true,
|
||||
text = "Fahrzeug wurde Hinzugefügt!",
|
||||
type ="success"
|
||||
})
|
||||
end
|
||||
end)
|
||||
else
|
||||
if not isOwner then
|
||||
cb({
|
||||
status = false,
|
||||
text = "Du bist nicht der Besitzer vom Fahrzeug!",
|
||||
type ="warning"
|
||||
})
|
||||
elseif not haveKeys then
|
||||
cb({
|
||||
status = false,
|
||||
key = true,
|
||||
text = "Du hast keinen Ersatzschlüssel, Stelle erst welche her. \nMakierung wurde dir gesetzt!",
|
||||
type = "inform"
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
MySQL.query("INSERT INTO mh_jobgarage(job, rang, value, plate, name, closed) VALUES (?, ?, ?, ?, ?, ?)", {pedjob, stats[3], stats[2], plate, stats[1], "false"})
|
||||
MySQL.query("UPDATE player_vehicles SET citizenid = ? WHERE owner = ? and plate = ?", {pedjob, pedid, plate})
|
||||
end)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue