From 4a0c8c282e17f74100aa3c67a6af209af301d46b Mon Sep 17 00:00:00 2001 From: Miho931 <98314142+Miho931@users.noreply.github.com> Date: Mon, 9 Jun 2025 15:23:24 +0200 Subject: [PATCH] [GARAGE] Fill Mods --- .../[carscripts]/mh_garage/client/main.lua | 14 +++++++++++ .../[carscripts]/mh_garage/server/server.lua | 24 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/resources/[carscripts]/mh_garage/client/main.lua b/resources/[carscripts]/mh_garage/client/main.lua index 6f512144d..945286e33 100644 --- a/resources/[carscripts]/mh_garage/client/main.lua +++ b/resources/[carscripts]/mh_garage/client/main.lua @@ -11,6 +11,20 @@ Citizen.CreateThread(function() end end) +Citizen.CreateThread(function() + while true do + Wait(5000) + local ped = PlayerPedId() + + if PedIsInAnyVehicle(ped) then + local veh = GetVehiclePedIsUsing(ped) + local mods = QBCore.Functions.GetVehicleProperties(vehicle) + + TriggerServerEvent('mh_garage:setMods', mods) + end + end +end) + -- Funktion zum Spawnen des NPCs function SpawnGuardNPC(npc) -- Ped Model laden diff --git a/resources/[carscripts]/mh_garage/server/server.lua b/resources/[carscripts]/mh_garage/server/server.lua index 0de1032a7..5902d697e 100644 --- a/resources/[carscripts]/mh_garage/server/server.lua +++ b/resources/[carscripts]/mh_garage/server/server.lua @@ -1,4 +1,28 @@ QBCore = exports['qb-core']:GetCoreObject() +local test_vari = {} + +RegisterServerEvent('mh_garage:setMods') +AddEventHandler('mh_garage:setMods', function(mods) + if test_vari ~= nil then + for k, v in pairs(test_vari) do + if v.plate ~= mods.plate then + MySQL.query("SELECT * FROM player_vehicles WHERE plate = ?", {mods.plate}, function(rs) + if rs[1].mods == nil then + MySQL.query("UPDATE player_vehicles SET mods = ? WHERE plate = ?", {mods, mods.plate}) + table.insert(test_vari, {plate = mods.plate}) + end + end) + end + end + else + MySQL.query("SELECT * FROM player_vehicles WHERE plate = ?", {mods.plate}, function(rs) + if rs[1].mods == nil then + MySQL.query("UPDATE player_vehicles SET mods = ? WHERE plate = ?", {mods, mods.plate}) + table.insert(test_vari, {plate = mods.plate}) + end + end) + end +end) QBCore.Functions.CreateCallback('mh_garage:storedVehicle', function(source, cb, veh, zone) local Player = QBCore.Functions.GetPlayer(source)