1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-07-20 17:27:40 +02:00
parent 7c8b6135b6
commit 92940f4b7e
2 changed files with 55 additions and 5 deletions

View file

@ -207,17 +207,39 @@ local function StartContainerRobbery(zone)
end)
end
-- Register usable item
-- Register usable item event handler - FIXED VERSION
RegisterNetEvent('container_heist:client:useFlexItem', function()
Debug("useFlexItem event triggered")
local zone = GetCurrentZone()
if zone then
Debug("Player is in zone: " .. zone.id)
StartContainerRobbery(zone)
else
QBCore.Functions.Notify(Config.Notifications.notInZone, "error")
end
end)
-- Alternative method to handle item use
RegisterNetEvent('inventory:client:UseItem', function(item)
if item.name == Config.RequiredItems.flex.name then
Debug("Used item via inventory:client:UseItem: " .. item.name)
TriggerEvent('container_heist:client:useFlexItem')
end
end)
-- Command to test the robbery (for debugging)
RegisterCommand('testcontainerrob', function()
local zone = GetCurrentZone()
if zone then
Debug("Testing robbery in zone: " .. zone.id)
StartContainerRobbery(zone)
else
QBCore.Functions.Notify(Config.Notifications.notInZone, "error")
end
end, false)
-- Command to toggle debug mode
RegisterCommand('containerdebug', function()
Config.Debug = not Config.Debug
@ -240,12 +262,14 @@ CreateThread(function()
inZone = true
currentZoneId = zone.id
QBCore.Functions.Notify("You entered " .. zone.label .. ". Use your flex tool to break in.", "primary")
Debug("Entered zone: " .. zone.id)
end
sleep = 500
else
if inZone then
inZone = false
currentZoneId = nil
Debug("Left zone")
end
end
@ -303,7 +327,7 @@ CreateThread(function()
-- Draw zone label
local centerZ = (zone.minZ + zone.maxZ) / 2
DrawText3D(centerX, centerY, centerZ, zone.id .. " (" .. zone.type .. ")")
end
}
else
Wait(1000)
end
@ -344,3 +368,10 @@ AddEventHandler('onResourceStop', function(resourceName)
end
end
end)
-- Print message when resource starts
AddEventHandler('onClientResourceStart', function(resourceName)
if (GetCurrentResourceName() == resourceName) then
Debug("Client script started successfully")
end
end)