1
0
Fork 0
forked from Simnation/Main

resources/[jobs]/[civ]/mh_jobgarage/server/server.lua aktualisiert

This commit is contained in:
Miho 2025-06-25 01:11:28 +02:00
parent c900f4d57b
commit 74868c4e12

View file

@ -16,47 +16,24 @@ end)
-- mh_jobgarage:AddVehicleToJob VARIABLEN: -- 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 Player = QBCore.Functions.GetPlayer(source)
local pedid = Player.PlayerData.citizenid local pedid = Player.PlayerData.citizenid
local pedjob = Player.PlayerData.job.name 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 MySQL.query("SELECT * FROm vehicle_keys WHERE owner = ? AND plate = ?", {pedid, plate}, function(rs)
if haveKeys[1].count == stats[2] then if rs ~= nil and rs[1] ~= nil then
MySQL.query("DELETE FROM vehicle_keys SET owner = ? AND plate = ?", {pedid, plate}) if rs[1].count == stats[2] then
elseif haveKeys[1].count > stats[2] then MySQL.query("DELETE FROM vehicle_keys WHERE owner = ? AND plate = ?", {pedid, plate})
MySQL.query("UPDATE vehicle_keys SET count = count - ? WHERE owner = ? and plate = ?", {stats[2], pedid, plate}) else
end MySQL.query("UPDATE vehicle_keys SET count = count - ? WHERE owner = ? AND plate = ?", {stats[2], pedid, plate})
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
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
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) end)