fix
This commit is contained in:
		
							parent
							
								
									8dbe72603d
								
							
						
					
					
						commit
						a0175cbe69
					
				
					 2 changed files with 162 additions and 17 deletions
				
			
		|  | @ -5,23 +5,154 @@ local function Debug(msg) | |||
|     print("^2[Shisha Debug] ^7" .. msg) | ||||
| end | ||||
|  | ||||
| -- Check if qb-target is available | ||||
| CreateThread(function() | ||||
|     Debug("Script starting...") | ||||
|     for _, prop in pairs(Config.ShishaProps) do | ||||
|         exports['qb-target']:AddTargetModel(prop, { | ||||
|             options = { | ||||
|                 { | ||||
|                     num = 1, | ||||
|                     type = "client", | ||||
|                     event = "nordi_shisha:client:OpenMenu", | ||||
|                     icon = 'fas fa-smoking', | ||||
|                     label = 'Shisha rauchen', | ||||
|                 } | ||||
|             }, | ||||
|             distance = 2.0 | ||||
|         }) | ||||
|     Wait(1000) | ||||
|     Debug("Checking if qb-target is available...") | ||||
|      | ||||
|     if exports['qb-target'] then | ||||
|         Debug("qb-target export is available") | ||||
|     else | ||||
|         Debug("ERROR: qb-target export is NOT available!") | ||||
|     end | ||||
| end) | ||||
|  | ||||
| -- Check if the model is valid and can be loaded | ||||
| CreateThread(function() | ||||
|     Debug("Checking prop model hash...") | ||||
|      | ||||
|     local modelName = "prop_bong_01" | ||||
|     local modelHash = GetHashKey(modelName) | ||||
|     Debug(modelName .. " hash: " .. modelHash) | ||||
|      | ||||
|     if IsModelValid(modelHash) then | ||||
|         Debug("Model is valid!") | ||||
|     else | ||||
|         Debug("Model is NOT valid!") | ||||
|     end | ||||
|      | ||||
|     if IsModelInCdimage(modelHash) then | ||||
|         Debug("Model is in CD image!") | ||||
|     else | ||||
|         Debug("Model is NOT in CD image!") | ||||
|     end | ||||
|      | ||||
|     -- Try to load the model | ||||
|     RequestModel(modelHash) | ||||
|     local timeout = 0 | ||||
|     while not HasModelLoaded(modelHash) and timeout < 50 do | ||||
|         Wait(100) | ||||
|         timeout = timeout + 1 | ||||
|     end | ||||
|      | ||||
|     if HasModelLoaded(modelHash) then | ||||
|         Debug("Model loaded successfully!") | ||||
|     else | ||||
|         Debug("Model failed to load after " .. timeout * 100 .. "ms!") | ||||
|     end | ||||
| end) | ||||
|  | ||||
| -- Register target for model | ||||
| CreateThread(function() | ||||
|     Debug("Registering target for models...") | ||||
|      | ||||
|     -- Try both string and hash methods | ||||
|     local modelName = "prop_bong_01" | ||||
|     local modelHash = GetHashKey(modelName) | ||||
|      | ||||
|     -- Method 1: Using string | ||||
|     exports['qb-target']:AddTargetModel(modelName, { | ||||
|         options = { | ||||
|             { | ||||
|                 num = 1, | ||||
|                 type = "client", | ||||
|                 event = "nordi_shisha:client:OpenMenu", | ||||
|                 icon = 'fas fa-smoking', | ||||
|                 label = 'Shisha rauchen (String)', | ||||
|             } | ||||
|         }, | ||||
|         distance = 2.0 | ||||
|     }) | ||||
|     Debug("Target registered for model string: " .. modelName) | ||||
|      | ||||
|     -- Method 2: Using hash | ||||
|     exports['qb-target']:AddTargetModel(modelHash, { | ||||
|         options = { | ||||
|             { | ||||
|                 num = 1, | ||||
|                 type = "client", | ||||
|                 event = "nordi_shisha:client:OpenMenu", | ||||
|                 icon = 'fas fa-smoking', | ||||
|                 label = 'Shisha rauchen (Hash)', | ||||
|             } | ||||
|         }, | ||||
|         distance = 2.0 | ||||
|     }) | ||||
|     Debug("Target registered for model hash: " .. modelHash) | ||||
| end) | ||||
|  | ||||
| -- Create props at specific locations if needed | ||||
| CreateThread(function() | ||||
|     if Config.SpawnProps then | ||||
|         Debug("Creating shisha props at defined locations...") | ||||
|          | ||||
|         for i, location in ipairs(Config.ShishaLocations) do | ||||
|             local modelHash = GetHashKey("prop_bong_01") | ||||
|             RequestModel(modelHash) | ||||
|             while not HasModelLoaded(modelHash) do | ||||
|                 Wait(10) | ||||
|             end | ||||
|              | ||||
|             local obj = CreateObject(modelHash, location.coords.x, location.coords.y, location.coords.z - 1.0, false, false, false) | ||||
|             SetEntityHeading(obj, location.heading) | ||||
|             PlaceObjectOnGroundProperly(obj) | ||||
|             FreezeEntityPosition(obj, true) | ||||
|              | ||||
|             exports['qb-target']:AddTargetEntity(obj, { | ||||
|                 options = { | ||||
|                     { | ||||
|                         num = 1, | ||||
|                         type = "client", | ||||
|                         event = "nordi_shisha:client:OpenMenu", | ||||
|                         icon = 'fas fa-smoking', | ||||
|                         label = 'Shisha rauchen (Entity)', | ||||
|                     } | ||||
|                 }, | ||||
|                 distance = 2.0 | ||||
|             }) | ||||
|              | ||||
|             Debug("Created shisha prop #" .. i .. " at " .. json.encode(location.coords)) | ||||
|         end | ||||
|     end | ||||
| end) | ||||
|  | ||||
| -- Add box zones as a fallback | ||||
| CreateThread(function() | ||||
|     if Config.UseBoxZones then | ||||
|         Debug("Setting up box zones for shisha locations...") | ||||
|          | ||||
|         for i, location in ipairs(Config.ShishaLocations) do | ||||
|             exports['qb-target']:AddBoxZone("shisha_"..i, location.coords, 0.75, 0.75, { | ||||
|                 name = "shisha_"..i, | ||||
|                 heading = location.heading, | ||||
|                 debugPoly = Config.DebugPoly, | ||||
|                 minZ = location.coords.z - 0.5, | ||||
|                 maxZ = location.coords.z + 0.5 | ||||
|             }, { | ||||
|                 options = { | ||||
|                     { | ||||
|                         num = 1, | ||||
|                         type = "client", | ||||
|                         event = "nordi_shisha:client:OpenMenu", | ||||
|                         icon = 'fas fa-smoking', | ||||
|                         label = 'Shisha rauchen (Zone)', | ||||
|                     } | ||||
|                 }, | ||||
|                 distance = 2.0 | ||||
|             }) | ||||
|             Debug("Created box zone for shisha #" .. i) | ||||
|         end | ||||
|     end | ||||
|     Debug("Target options registered") | ||||
| end) | ||||
|  | ||||
| -- Event Handler für das Öffnen des Menüs | ||||
|  | @ -132,7 +263,7 @@ end | |||
|  | ||||
| function SmokeShisha(selectedShisha) | ||||
|     local ped = PlayerPedId() | ||||
|     local propName = "v_corp_lngestoolfd" | ||||
|     local propName = "v_corp_lngestoolfd" -- Dieses Modell wird aus dem Stream-Ordner geladen | ||||
|     local propBone = 28422 | ||||
|      | ||||
|     local propCoords = vector3(0.0, 0.0, -0.03) | ||||
|  |  | |||
|  | @ -1,8 +1,22 @@ | |||
| Config = {} | ||||
|  | ||||
| -- Debug mode | ||||
| Config.DebugPoly = false  -- Set to true to see box zones | ||||
|  | ||||
| -- Prop spawning options | ||||
| Config.SpawnProps = true  -- Set to true to spawn props at locations | ||||
| Config.UseBoxZones = true -- Set to true to use box zones as fallback | ||||
|  | ||||
| -- Welche Props sollen als Shisha funktionieren? | ||||
| Config.ShishaProps = { | ||||
|     `prop_bong_01`, | ||||
|     "prop_bong_01", -- String format | ||||
| } | ||||
|  | ||||
| -- Locations for shishas (used for box zones and prop spawning) | ||||
| Config.ShishaLocations = { | ||||
|     {coords = vector3(-1390.84, -605.84, 30.32), heading = 125.0}, -- Example location | ||||
|     {coords = vector3(1543.35, 6332.02, 24.08), heading = 42.0},   -- Example location | ||||
|     -- Add more locations as needed | ||||
| } | ||||
|  | ||||
| -- Progressbar Dauer in ms | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Nordi98
						Nordi98