forked from Simnation/Main
ed
This commit is contained in:
parent
7c8b6135b6
commit
92940f4b7e
2 changed files with 55 additions and 5 deletions
|
@ -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)
|
||||
|
|
|
@ -10,9 +10,11 @@ local function Debug(msg)
|
|||
end
|
||||
end
|
||||
|
||||
-- Register usable item
|
||||
QBCore.Functions.CreateUseableItem(Config.RequiredItems.flex.name, function(source)
|
||||
TriggerClientEvent('container_heist:client:useFlexItem', source)
|
||||
-- Register usable item - FIXED VERSION
|
||||
QBCore.Functions.CreateUseableItem(Config.RequiredItems.flex.name, function(source, item)
|
||||
local src = source
|
||||
Debug("Player " .. src .. " used item: " .. Config.RequiredItems.flex.name)
|
||||
TriggerClientEvent('container_heist:client:useFlexItem', src)
|
||||
end)
|
||||
|
||||
-- Check if player has required items
|
||||
|
@ -23,6 +25,7 @@ QBCore.Functions.CreateCallback('container_heist:server:checkRequiredItems', fun
|
|||
|
||||
-- Check for required flex tool
|
||||
local hasItem = exports['tgiann-inventory']:HasItem(src, Config.RequiredItems.flex.name, Config.RequiredItems.flex.amount)
|
||||
Debug("Player " .. src .. " has required item: " .. tostring(hasItem))
|
||||
cb(hasItem)
|
||||
end)
|
||||
|
||||
|
@ -214,3 +217,19 @@ CreateThread(function()
|
|||
end
|
||||
end
|
||||
end)
|
||||
|
||||
-- Alternative method to register usable item for tgiann-inventory
|
||||
RegisterNetEvent('QBCore:Server:UseItem', function(source, item)
|
||||
if item.name == Config.RequiredItems.flex.name then
|
||||
Debug("Player " .. source .. " used item via QBCore:Server:UseItem: " .. item.name)
|
||||
TriggerClientEvent('container_heist:client:useFlexItem', source)
|
||||
end
|
||||
end)
|
||||
|
||||
-- Print message when resource starts
|
||||
AddEventHandler('onResourceStart', function(resourceName)
|
||||
if (GetCurrentResourceName() == resourceName) then
|
||||
print('^2[Container Heist]^7: Script started successfully')
|
||||
print('^2[Container Heist]^7: Registered usable item: ' .. Config.RequiredItems.flex.name)
|
||||
end
|
||||
end)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue