This commit is contained in:
Nordi98 2025-08-05 08:45:18 +02:00
parent 636ffb007e
commit 4c9a54ff7b
10 changed files with 944 additions and 0 deletions

View file

@ -0,0 +1,59 @@
function sendToDiscord(Titel, Text, Color) ------ Sende Nachricht an Channel: Join/Left
local embeds = {
{
["title"]=Text,
["type"]="rich",
["color"] =Config.Log.Color[Color],
["footer"]= {
["text"]= Config.Log.SystemName,
},
}
}
PerformHttpRequest(Config.Log.Webhook, function(err, text, headers)
if err and err ~= 204 and err ~= 200 then
print("Fehler beim Discord Webhook [" .. tostring(err) .. "]: " .. tostring(text))
end
end, 'POST', json.encode({ username = Titel.." - Mîhó",avatar_url = Config.SystemAvatar, embeds = embeds, tts = TTS}), { ['Content-Type'] = 'application/json' })
end
AddEventHandler('mh_garage:log')
RegisterServerEvent('mh_garage:log', function(type)
local Player = QBCore.Functions.GetPlayer(source)
local PlyData = Player.PlayerData
local Color = "purple"
Playerinfo = {
name = PlyData.charinfo.firstname .. " ".. PlyData.charinfo.lastname,
citizenid = PlyData.citizenid,
}
local user = Playerinfo.name.."[".. Playerinfo.citizenid .."]"
if type == "call" then
Text = "Dr. Teddy wurde von " .. user .." gerufen."
Color = "grey"
elseif type == "cash" then
Text = user.." hat Bar Bezahlt."
Color = "green"
elseif type == "bank" then
Text = user .. "hat via Überweisung Bezahlt."
Color = "green"
elseif type == "noMoney" then
Text = user .." Hatte nicht genug Geld."
Color = "orange"
elseif type == "noPlayer" then
Text = user .. " Wurde nicht gefunden und abgebrochen!"
Color = "red"
elseif type == "storno" then
Text = user .. " Hat die Behandlung doch Abgelehnt."
Color = "red"
elseif type == "heal" then
Text = user.. " Wurde Geheilt."
Color = "green"
elseif type == "end" then
Text = "NPC wurde wieder Entfernt..."
Color = "blue"
end
sendToDiscord("Garage", Text, Color)
end)

View file

@ -0,0 +1,159 @@
QBCore = exports['qb-core']:GetCoreObject()
local test_vari = {}
RegisterServerEvent('mh_garage:setMods')
AddEventHandler('mh_garage:setMods', function(mods)
if test_vari[mods.plate] == true then
return
else
MySQL.query("SELECT mods FROM player_vehicles WHERE plate = ?", {mods.plate}, function(rs)
-- Prüfen ob rs überhaupt Daten enthält
if rs and rs[1] then
-- Wenn mods ein String ist, konvertieren wir es zu einem Table
local modsData = type(rs[1].mods) == "string" and json.decode(rs[1].mods) or rs[1].mods
if not modsData or next(modsData) == nil then
-- Hier sollten Sie wahrscheinlich auch die mods-Daten übergeben, nicht nur plate
MySQL.query("UPDATE player_vehicles SET mods = ? WHERE plate = ?", {json.encode(mods), mods.plate})
test_vari[mods.plate] = true
else
test_vari[mods.plate] = true
end
end
end)
end
end)
QBCore.Functions.CreateCallback('mh_garage:storedVehicle', function(source, cb, veh, zone)
local Player = QBCore.Functions.GetPlayer(source)
if Player ~= nil then
if Player.Functions.GetMoney('bank', zone.price) then
MySQL.query("SELECT * FROM player_vehicles WHERE citizenid = ? AND plate = ?", {Player.PlayerData.citizenid, veh.plate}, function(rs)
if rs[1] ~= nil then
MySQL.query("UPDATE player_vehicles SET garage = ?, mods = ? WHERE plate = ?", {zone.name, json.encode(veh), veh.plate})
DelVehParking(veh.plate)
cb({
status = true,
text = "Fahrzeug erfolgreich eingeparkt!",
type = "success",
other = false,
police = false
})
else
MySQL.query("SELECT * FROM vehicle_keys WHERE owner = ? AND plate = ?", {Player.PlayerData.citizenid, veh.plate}, function(rs)
if rs[1] ~= nil then
MySQL.query("UPDATE player_vehicles SET garage = ?, mods = ? WHERE plate = ?", {zone.name, json.encode(veh), veh.plate})
--TriggerEvent('mh_Parking:removeVehicle', source, veh.plate)
--DelVehParking(veh.plate)
cb({
status = true,
text = "Fahrzeug erfolgreich eingeparkt!",
type = "success",
other = true,
police = false
})
else
cb({
status = false,
text = "Du besitzt kein Schlüssel für dieses Fahrzeug.",
type = "warning",
other = false,
police = true
})
end
end)
end
end)
end
end
end)
function DelVehParking(plate)
MySQL.query("SELECT * FROM vehicle_parking WHERE plate = ?", {plate}, function(rs)
if rs[1] ~= nil then
MySQL.query("DELETE FROM vehicle_parking WHERE plate = ?", {plate})
end
end)
end
QBCore.Functions.CreateCallback('mh_garage:retrieveOwnerVehicle', function(source, cb, zone)
local _source = source
local Player = QBCore.Functions.GetPlayer(_source)
local pedid = Player.PlayerData.citizenid
local veh = {}
MySQL.query("SELECT * FROM player_vehicles WHERE citizenid = ? and garage = ?", {pedid, zone}, function(rs)
if rs ~= nil and rs[1] ~= nil then
for k, v in pairs (rs) do
table.insert(veh, {
vehicle = v.vehicle,
mods = v.mods,
plate = v.plate,
name = v.name
})
end
Wait(100)
cb(veh)
else
cb(false)
end
end)
end)
QBCore.Functions.CreateCallback('mh_garage:retrieveKeyVehicle', function(source, cb, zone)
local _source = source
local Player = QBCore.Functions.GetPlayer(_source)
local pedid = Player.PlayerData.citizenid
local veh = {}
MySQL.query("SELECT pv.* FROM player_vehicles pv JOIN vehicle_keys vk ON pv.plate = vk.plate WHERE vk.owner = ? AND vk.count > 0 AND pv.garage = ?", {pedid, zone}, function(vehicles)
if vehicles and #vehicles > 0 then
for _, vehicle in pairs(vehicles) do
table.insert(veh, {
vehicle = vehicle.vehicle,
mods = vehicle.mods,
plate = vehicle.plate,
name = vehicle.name
})
end
Wait(100)
cb(veh)
else
cb(false)
end
end)
end)
QBCore.Functions.CreateCallback('mh_garage:verwaltung', function(source, cb)
local Player = QBCore.Functions.GetPlayer(source)
local vehicles = {}
MySQL.query("SELECT * FROM player_vehicles WHERE citizenid = ?", {Player.PlayerData.citizenid}, function(rs)
if rs and rs[1] then
for k, v in pairs(rs) do
table.insert(vehicles, {
current_garage = v.garage,
current_in_garage = v.parking,
current_name = v.name,
current_plate = v.plate,
})
end
end
end)
return vehicles
end)
RegisterServerEvent('mh_garage:spawnedVehicle')
AddEventHandler('mh_garage:spawnedVehicle', function(netID, plate)
MySQL.query("UPDATE player_vehicles SET garage = ? WHERE plate = ?", {"OUT", plate})
end)
QBCore.Functions.CreateCallback('mh_garage:CheckownerVehicles', function(source, cb, plate)
MySQL.query("SELECT * FROM player_vehicles WHERE plate = ?", {plate}, function(rs)
if rs ~= nil and rs[1] ~= nil then
cb(true)
else
cb(false)
end
end)
end)