diff --git a/resources/[inventory]/pl_printer/client/main.lua b/resources/[inventory]/pl_printer/client/main.lua
index 38a4067b3..c0556c064 100644
--- a/resources/[inventory]/pl_printer/client/main.lua
+++ b/resources/[inventory]/pl_printer/client/main.lua
@@ -1,79 +1,231 @@
-
-
-
-
-
-
-
-
-
-
-
-
![Document]()
-
-
-
-
-
+ })
+ end
+end
+
+-- Funktion zum Spawnen von Objekten
+local function spawnObject(object, coords, heading)
+ lib.requestModel(object)
+
+ if not HasModelLoaded(object) then
+ _debug('[DEBUG] '..object..' failed to load.'..'')
+ return
+ end
+
+ local entity = CreateObject(object, coords.x, coords.y, coords.z, true, true, true)
+
+ if DoesEntityExist(entity) then
+ SetEntityHeading(entity, heading)
+ FreezeEntityPosition(entity, true)
+ table.insert(spawnedObjects, entity)
+ else
+ _debug('[DEBUG] '..' Failed to spawn object: '..object..'')
+ end
+end
+
+-- Funktion zum Löschen von gespawnten Objekten
+local function deleteSpawnedObjects()
+ for _, obj in ipairs(spawnedObjects) do
+ if DoesEntityExist(obj) then
+ DeleteObject(obj)
+ end
+ end
+ spawnedObjects = {}
+end
+
+-- Resource-Start-Event
+AddEventHandler('onResourceStart', function(resourceName)
+ if GetCurrentResourceName() ~= resourceName then return end
+ for _, location in ipairs(Config.Locations) do
+ spawnObject(location.object, location.coords, location.heading)
+ end
+end)
+
+-- Resource-Stop-Event
+AddEventHandler('onResourceStop', function(resourceName)
+ if GetCurrentResourceName() ~= resourceName then return end
+ deleteSpawnedObjects()
+end)
+
+-- Funktion für Spieler-Login
+function onPlayerLoaded()
+ Wait(3000)
+ for _, location in ipairs(Config.Locations) do
+ spawnObject(location.object, location.coords, location.heading)
+ end
+end
+
+-- Debug-Hilfsfunktion
+function _debug(...)
+ if Config.Debug then
+ print(...)
+ end
+end
+
+-- Notfall-Thread zum Zurücksetzen des NUI-Focus, falls etwas schief geht
+Citizen.CreateThread(function()
+ while true do
+ Citizen.Wait(1000)
+ if imageDisplayed then
+ -- Prüfe, ob ESC gedrückt wurde (Fallback für den Fall, dass der NUI-Callback nicht funktioniert)
+ if IsControlJustReleased(0, 177) then -- ESC-Taste
+ print("[DEBUG] ESC key detected in thread, resetting focus")
+ imageDisplayed = false
+ SetNuiFocus(false, false)
+ enableControls()
+ SendNUIMessage({
+ action = "hide"
+ })
+ end
+ else
+ Citizen.Wait(1000) -- Längere Wartezeit, wenn kein Bild angezeigt wird
+ end
+ end
+end)
+
+-- Füge diesen Code hinzu, um das HTML zu aktualisieren, wenn die Ressource neu gestartet wird
+AddEventHandler('onResourceStart', function(resourceName)
+ if GetCurrentResourceName() == resourceName then
+ -- Stelle sicher, dass der NUI-Focus zurückgesetzt wird
+ SetNuiFocus(false, false)
+ imageDisplayed = false
+ enableControls()
+ end
+end)
+
+-- Füge diesen Code hinzu, um den NUI-Focus zurückzusetzen, wenn der Spieler stirbt
+AddEventHandler('playerSpawned', function()
+ if imageDisplayed then
+ imageDisplayed = false
+ SetNuiFocus(false, false)
+ enableControls()
+ SendNUIMessage({
+ action = "hide"
+ })
+ end
+end)