fix
This commit is contained in:
		
							parent
							
								
									b579b06056
								
							
						
					
					
						commit
						63d0db8777
					
				
					 2 changed files with 154 additions and 5 deletions
				
			
		| 
						 | 
				
			
			@ -85,12 +85,104 @@ end)
 | 
			
		|||
 | 
			
		||||
-- Nachtsicht-Befehl
 | 
			
		||||
RegisterCommand('toggleNV', function()
 | 
			
		||||
    -- [Rest des Codes bleibt unverändert]
 | 
			
		||||
    local ped = PlayerPedId()
 | 
			
		||||
    local gender = IsPedMale(ped) and "male" or "female"
 | 
			
		||||
    
 | 
			
		||||
    -- Check if player has the item
 | 
			
		||||
    QBCore.Functions.TriggerCallback('QBCore:HasItem', function(hasItem)
 | 
			
		||||
        if hasItem then
 | 
			
		||||
            -- Check if player is wearing the correct glasses if enabled
 | 
			
		||||
            if Config.CheckHelmet then
 | 
			
		||||
                local glassesConfig = Config.Glasses[gender]
 | 
			
		||||
                
 | 
			
		||||
                if nvMode == 0 then
 | 
			
		||||
                    -- Enable nightvision
 | 
			
		||||
                    if IsWearingGlasses(ped, glassesConfig.up) then
 | 
			
		||||
                        SetGlasses(ped, glassesConfig.nvDown)
 | 
			
		||||
                        SetNightvision(true)
 | 
			
		||||
                        nvMode = 1
 | 
			
		||||
                        TriggerServerEvent('InteractSound_SV:PlayWithinDistance', 3.0, 'nightvision', 0.25)
 | 
			
		||||
                        QBCore.Functions.Notify('Nachtsicht aktiviert')
 | 
			
		||||
                    else
 | 
			
		||||
                        QBCore.Functions.Notify('Du trägst nicht die richtige Brille!', 'error')
 | 
			
		||||
                    end
 | 
			
		||||
                else
 | 
			
		||||
                    -- Disable nightvision
 | 
			
		||||
                    SetGlasses(ped, glassesConfig.up)
 | 
			
		||||
                    SetNightvision(false)
 | 
			
		||||
                    nvMode = 0
 | 
			
		||||
                    TriggerServerEvent('InteractSound_SV:PlayWithinDistance', 3.0, 'nightvision', 0.25)
 | 
			
		||||
                    QBCore.Functions.Notify('Nachtsicht deaktiviert')
 | 
			
		||||
                end
 | 
			
		||||
            else
 | 
			
		||||
                -- No helmet check, just toggle nightvision
 | 
			
		||||
                if nvMode == 0 then
 | 
			
		||||
                    SetNightvision(true)
 | 
			
		||||
                    nvMode = 1
 | 
			
		||||
                    TriggerServerEvent('InteractSound_SV:PlayWithinDistance', 3.0, 'nightvision', 0.25)
 | 
			
		||||
                    QBCore.Functions.Notify('Nachtsicht aktiviert')
 | 
			
		||||
                else
 | 
			
		||||
                    SetNightvision(false)
 | 
			
		||||
                    nvMode = 0
 | 
			
		||||
                    TriggerServerEvent('InteractSound_SV:PlayWithinDistance', 3.0, 'nightvision', 0.25)
 | 
			
		||||
                    QBCore.Functions.Notify('Nachtsicht deaktiviert')
 | 
			
		||||
                end
 | 
			
		||||
            end
 | 
			
		||||
        else
 | 
			
		||||
            QBCore.Functions.Notify('Du hast kein Nachtsichtgerät!', 'error')
 | 
			
		||||
        end
 | 
			
		||||
    end, Config.NVItem)
 | 
			
		||||
end)
 | 
			
		||||
 | 
			
		||||
-- Wärmebild-Befehl
 | 
			
		||||
RegisterCommand('toggleThermal', function()
 | 
			
		||||
    -- [Rest des Codes bleibt unverändert]
 | 
			
		||||
    local ped = PlayerPedId()
 | 
			
		||||
    local gender = IsPedMale(ped) and "male" or "female"
 | 
			
		||||
    
 | 
			
		||||
    -- Check if player has the item
 | 
			
		||||
    QBCore.Functions.TriggerCallback('QBCore:HasItem', function(hasItem)
 | 
			
		||||
        if hasItem then
 | 
			
		||||
            -- Check if player is wearing the correct glasses if enabled
 | 
			
		||||
            if Config.CheckHelmet then
 | 
			
		||||
                local glassesConfig = Config.Glasses[gender]
 | 
			
		||||
                
 | 
			
		||||
                if thermalMode == 0 then
 | 
			
		||||
                    -- Enable thermal vision
 | 
			
		||||
                    if IsWearingGlasses(ped, glassesConfig.up) then
 | 
			
		||||
                        SetGlasses(ped, glassesConfig.thermalDown)
 | 
			
		||||
                        SetSeethrough(true)
 | 
			
		||||
                        thermalMode = 1
 | 
			
		||||
                        TriggerServerEvent('InteractSound_SV:PlayWithinDistance', 3.0, 'nightvision', 0.25)
 | 
			
		||||
                        QBCore.Functions.Notify('Wärmebild aktiviert')
 | 
			
		||||
                    else
 | 
			
		||||
                        QBCore.Functions.Notify('Du trägst nicht die richtige Brille!', 'error')
 | 
			
		||||
                    end
 | 
			
		||||
                else
 | 
			
		||||
                    -- Disable thermal vision
 | 
			
		||||
                    SetGlasses(ped, glassesConfig.up)
 | 
			
		||||
                    SetSeethrough(false)
 | 
			
		||||
                    thermalMode = 0
 | 
			
		||||
                    TriggerServerEvent('InteractSound_SV:PlayWithinDistance', 3.0, 'nightvision', 0.25)
 | 
			
		||||
                    QBCore.Functions.Notify('Wärmebild deaktiviert')
 | 
			
		||||
                end
 | 
			
		||||
            else
 | 
			
		||||
                -- No helmet check, just toggle thermal vision
 | 
			
		||||
                if thermalMode == 0 then
 | 
			
		||||
                    SetSeethrough(true)
 | 
			
		||||
                    thermalMode = 1
 | 
			
		||||
                    TriggerServerEvent('InteractSound_SV:PlayWithinDistance', 3.0, 'nightvision', 0.25)
 | 
			
		||||
                    QBCore.Functions.Notify('Wärmebild aktiviert')
 | 
			
		||||
                else
 | 
			
		||||
                    SetSeethrough(false)
 | 
			
		||||
                    thermalMode = 0
 | 
			
		||||
                    TriggerServerEvent('InteractSound_SV:PlayWithinDistance', 3.0, 'nightvision', 0.25)
 | 
			
		||||
                    QBCore.Functions.Notify('Wärmebild deaktiviert')
 | 
			
		||||
                end
 | 
			
		||||
            end
 | 
			
		||||
        else
 | 
			
		||||
            QBCore.Functions.Notify('Du hast kein Wärmebildgerät!', 'error')
 | 
			
		||||
        end
 | 
			
		||||
    end, Config.ThermalItem)
 | 
			
		||||
end)
 | 
			
		||||
 | 
			
		||||
-- Helm-Lampe-Befehl
 | 
			
		||||
| 
						 | 
				
			
			@ -105,7 +197,57 @@ RegisterKeyMapping('toggleHelmetLight', 'Helm-Lampe umschalten', 'keyboard', Con
 | 
			
		|||
 | 
			
		||||
-- Event zum Umschalten der Brille
 | 
			
		||||
RegisterNetEvent('nightvision:toggleGlasses', function(mode)
 | 
			
		||||
    -- [Rest des Codes bleibt unverändert]
 | 
			
		||||
    local ped = PlayerPedId()
 | 
			
		||||
    local gender = IsPedMale(ped) and "male" or "female"
 | 
			
		||||
    local glassesConfig = Config.Glasses[gender]
 | 
			
		||||
    
 | 
			
		||||
    if mode == 'nightvision' then
 | 
			
		||||
        -- Check if player has the item
 | 
			
		||||
        QBCore.Functions.TriggerCallback('QBCore:HasItem', function(hasItem)
 | 
			
		||||
            if hasItem then
 | 
			
		||||
                if nvMode == 0 then
 | 
			
		||||
                    -- Enable nightvision
 | 
			
		||||
                    SetGlasses(ped, glassesConfig.nvDown)
 | 
			
		||||
                    SetNightvision(true)
 | 
			
		||||
                    nvMode = 1
 | 
			
		||||
                    TriggerServerEvent('InteractSound_SV:PlayWithinDistance', 3.0, 'nightvision', 0.25)
 | 
			
		||||
                    QBCore.Functions.Notify('Nachtsicht aktiviert')
 | 
			
		||||
                else
 | 
			
		||||
                    -- Disable nightvision
 | 
			
		||||
                    SetGlasses(ped, glassesConfig.up)
 | 
			
		||||
                    SetNightvision(false)
 | 
			
		||||
                    nvMode = 0
 | 
			
		||||
                    TriggerServerEvent('InteractSound_SV:PlayWithinDistance', 3.0, 'nightvision', 0.25)
 | 
			
		||||
                    QBCore.Functions.Notify('Nachtsicht deaktiviert')
 | 
			
		||||
                end
 | 
			
		||||
            else
 | 
			
		||||
                QBCore.Functions.Notify('Du hast kein Nachtsichtgerät!', 'error')
 | 
			
		||||
            end
 | 
			
		||||
        end, Config.NVItem)
 | 
			
		||||
    elseif mode == 'thermal' then
 | 
			
		||||
        -- Check if player has the item
 | 
			
		||||
        QBCore.Functions.TriggerCallback('QBCore:HasItem', function(hasItem)
 | 
			
		||||
            if hasItem then
 | 
			
		||||
                if thermalMode == 0 then
 | 
			
		||||
                    -- Enable thermal vision
 | 
			
		||||
                    SetGlasses(ped, glassesConfig.thermalDown)
 | 
			
		||||
                    SetSeethrough(true)
 | 
			
		||||
                    thermalMode = 1
 | 
			
		||||
                    TriggerServerEvent('InteractSound_SV:PlayWithinDistance', 3.0, 'nightvision', 0.25)
 | 
			
		||||
                    QBCore.Functions.Notify('Wärmebild aktiviert')
 | 
			
		||||
                else
 | 
			
		||||
                    -- Disable thermal vision
 | 
			
		||||
                    SetGlasses(ped, glassesConfig.up)
 | 
			
		||||
                    SetSeethrough(false)
 | 
			
		||||
                    thermalMode = 0
 | 
			
		||||
                    TriggerServerEvent('InteractSound_SV:PlayWithinDistance', 3.0, 'nightvision', 0.25)
 | 
			
		||||
                    QBCore.Functions.Notify('Wärmebild deaktiviert')
 | 
			
		||||
                end
 | 
			
		||||
            else
 | 
			
		||||
                QBCore.Functions.Notify('Du hast kein Wärmebildgerät!', 'error')
 | 
			
		||||
            end
 | 
			
		||||
        end, Config.ThermalItem)
 | 
			
		||||
    end
 | 
			
		||||
end)
 | 
			
		||||
 | 
			
		||||
-- Behalte den alten Event-Namen für Kompatibilität
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,6 +3,13 @@ local QBCore = exports[Config.CoreName]:GetCoreObject()
 | 
			
		|||
QBCore.Functions.CreateUseableItem(Config.NVItem, function(source, item)
 | 
			
		||||
    local Player = QBCore.Functions.GetPlayer(source)
 | 
			
		||||
    if Player.Functions.GetItemByName(item.name) then
 | 
			
		||||
        TriggerClientEvent('nightvision:toggleHelmet', source)
 | 
			
		||||
        TriggerClientEvent('nightvision:toggleGlasses', source, 'nightvision')
 | 
			
		||||
    end
 | 
			
		||||
end)
 | 
			
		||||
end)
 | 
			
		||||
 | 
			
		||||
QBCore.Functions.CreateUseableItem(Config.ThermalItem, function(source, item)
 | 
			
		||||
    local Player = QBCore.Functions.GetPlayer(source)
 | 
			
		||||
    if Player.Functions.GetItemByName(item.name) then
 | 
			
		||||
        TriggerClientEvent('nightvision:toggleGlasses', source, 'thermal')
 | 
			
		||||
    end
 | 
			
		||||
end)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue