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) | ||||||
| end | end | ||||||
|  |  | ||||||
| -- Register usable item | -- Register usable item event handler - FIXED VERSION | ||||||
| RegisterNetEvent('container_heist:client:useFlexItem', function() | RegisterNetEvent('container_heist:client:useFlexItem', function() | ||||||
|  |     Debug("useFlexItem event triggered") | ||||||
|     local zone = GetCurrentZone() |     local zone = GetCurrentZone() | ||||||
|      |      | ||||||
|     if zone then |     if zone then | ||||||
|  |         Debug("Player is in zone: " .. zone.id) | ||||||
|         StartContainerRobbery(zone) |         StartContainerRobbery(zone) | ||||||
|     else |     else | ||||||
|         QBCore.Functions.Notify(Config.Notifications.notInZone, "error") |         QBCore.Functions.Notify(Config.Notifications.notInZone, "error") | ||||||
|     end |     end | ||||||
| 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 | -- Command to toggle debug mode | ||||||
| RegisterCommand('containerdebug', function() | RegisterCommand('containerdebug', function() | ||||||
|     Config.Debug = not Config.Debug |     Config.Debug = not Config.Debug | ||||||
|  | @ -240,12 +262,14 @@ CreateThread(function() | ||||||
|                 inZone = true |                 inZone = true | ||||||
|                 currentZoneId = zone.id |                 currentZoneId = zone.id | ||||||
|                 QBCore.Functions.Notify("You entered " .. zone.label .. ". Use your flex tool to break in.", "primary") |                 QBCore.Functions.Notify("You entered " .. zone.label .. ". Use your flex tool to break in.", "primary") | ||||||
|  |                 Debug("Entered zone: " .. zone.id) | ||||||
|             end |             end | ||||||
|             sleep = 500 |             sleep = 500 | ||||||
|         else |         else | ||||||
|             if inZone then |             if inZone then | ||||||
|                 inZone = false |                 inZone = false | ||||||
|                 currentZoneId = nil |                 currentZoneId = nil | ||||||
|  |                 Debug("Left zone") | ||||||
|             end |             end | ||||||
|         end |         end | ||||||
|          |          | ||||||
|  | @ -303,7 +327,7 @@ CreateThread(function() | ||||||
|                 -- Draw zone label |                 -- Draw zone label | ||||||
|                 local centerZ = (zone.minZ + zone.maxZ) / 2 |                 local centerZ = (zone.minZ + zone.maxZ) / 2 | ||||||
|                 DrawText3D(centerX, centerY, centerZ, zone.id .. " (" .. zone.type .. ")") |                 DrawText3D(centerX, centerY, centerZ, zone.id .. " (" .. zone.type .. ")") | ||||||
|             end |             } | ||||||
|         else |         else | ||||||
|             Wait(1000) |             Wait(1000) | ||||||
|         end |         end | ||||||
|  | @ -344,3 +368,10 @@ AddEventHandler('onResourceStop', function(resourceName) | ||||||
|         end |         end | ||||||
|     end |     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 | ||||||
| end | end | ||||||
|  |  | ||||||
| -- Register usable item | -- Register usable item - FIXED VERSION | ||||||
| QBCore.Functions.CreateUseableItem(Config.RequiredItems.flex.name, function(source) | QBCore.Functions.CreateUseableItem(Config.RequiredItems.flex.name, function(source, item) | ||||||
|     TriggerClientEvent('container_heist:client:useFlexItem', source) |     local src = source | ||||||
|  |     Debug("Player " .. src .. " used item: " .. Config.RequiredItems.flex.name) | ||||||
|  |     TriggerClientEvent('container_heist:client:useFlexItem', src) | ||||||
| end) | end) | ||||||
|  |  | ||||||
| -- Check if player has required items | -- Check if player has required items | ||||||
|  | @ -23,6 +25,7 @@ QBCore.Functions.CreateCallback('container_heist:server:checkRequiredItems', fun | ||||||
|      |      | ||||||
|     -- Check for required flex tool |     -- Check for required flex tool | ||||||
|     local hasItem = exports['tgiann-inventory']:HasItem(src, Config.RequiredItems.flex.name, Config.RequiredItems.flex.amount) |     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) |     cb(hasItem) | ||||||
| end) | end) | ||||||
|  |  | ||||||
|  | @ -214,3 +217,19 @@ CreateThread(function() | ||||||
|         end |         end | ||||||
|     end |     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
	
	 Nordi98
						Nordi98