1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-06-30 00:25:08 +02:00
parent ee2240f1d6
commit 7de5955637
2 changed files with 65 additions and 13 deletions

View file

@ -2,10 +2,21 @@ local QBCore = exports[Config.CoreName]:GetCoreObject()
local mode = 0
local canToggle = false
-- Funktion zum Prüfen des Charaktergeschlechts
local function IsPedMale(ped)
return GetEntityModel(ped) == `mp_m_freemode_01`
end
RegisterCommand('toggleNV', function()
local ped = PlayerPedId()
if QBCore.Functions.HasItem(Config.NVItem) then
local currentGlasses = GetPedPropIndex(ped, 1)
local gender = IsPedMale(ped) and "male" or "female"
-- Prüfen, ob der Spieler eine der NV-Brillen trägt
if Config.CheckHelmet then
if GetPedPropIndex(PlayerPedId(), 0) == 116 then
if currentGlasses == Config.Glasses[gender].up or currentGlasses == Config.Glasses[gender].down then
canToggle = true
else
canToggle = false
@ -15,31 +26,60 @@ RegisterCommand('toggleNV', function()
end
if canToggle then
if mode == 0 then
QBCore.Functions.Notify('Nightvision on!')
-- Wenn die Brille hochgeklappt ist und Nachtsicht aktiviert wird, klappe sie runter
if mode == 0 and currentGlasses == Config.Glasses[gender].up then
SetPedPropIndex(ped, 1, Config.Glasses[gender].down, 0, true)
QBCore.Functions.Notify('Nachtsicht aktiviert!')
SetNightvision(true)
mode = 1
-- Wenn bereits im Nachtsichtmodus, wechsle zu Wärmesicht
elseif mode == 1 then
QBCore.Functions.Notify('Thermal vision on!')
QBCore.Functions.Notify('Wärmesicht aktiviert!')
SetSeethrough(true)
mode = 2
-- Wenn im Wärmesichtmodus, deaktiviere alles und klappe Brille hoch
elseif mode == 2 then
QBCore.Functions.Notify('Nightvision off!')
SetPedPropIndex(ped, 1, Config.Glasses[gender].up, 0, true)
QBCore.Functions.Notify('Nachtsicht deaktiviert!')
SetNightvision(false)
SetSeethrough(false)
mode = 0
end
else
QBCore.Functions.Notify('You are not wearing a nightvision helmet!', 'error')
QBCore.Functions.Notify('Du trägst keine Nachtsichtbrille!', 'error')
end
end
end)
RegisterKeyMapping('toggleNV', 'Toggle nightvision', 'keyboard', Config.NVKey)
RegisterNetEvent('nightvision:toggleHelmet', function()
if GetPedPropIndex(PlayerPedId(), 0) == 116 then
SetPedPropIndex(PlayerPedId(), 0, 8, 0, true)
else
SetPedPropIndex(PlayerPedId(), 0, 116, 0, true)
-- Umbenannt für bessere Klarheit
RegisterNetEvent('nightvision:toggleGlasses', function()
local ped = PlayerPedId()
local currentGlasses = GetPedPropIndex(ped, 1)
local gender = IsPedMale(ped) and "male" or "female"
-- Wenn keine NV-Brille getragen wird, setze hochgeklappte Version auf
if currentGlasses ~= Config.Glasses[gender].up and currentGlasses ~= Config.Glasses[gender].down then
SetPedPropIndex(ped, 1, Config.Glasses[gender].up, 0, true)
QBCore.Functions.Notify('Nachtsichtbrille aufgesetzt!')
-- Wenn hochgeklappte NV-Brille getragen wird, klappe sie runter und aktiviere Nachtsicht
elseif currentGlasses == Config.Glasses[gender].up then
SetPedPropIndex(ped, 1, Config.Glasses[gender].down, 0, true)
QBCore.Functions.Notify('Nachtsicht aktiviert!')
SetNightvision(true)
mode = 1
-- Wenn runtergeklappte NV-Brille getragen wird, klappe sie hoch und deaktiviere Nachtsicht
elseif currentGlasses == Config.Glasses[gender].down then
SetPedPropIndex(ped, 1, Config.Glasses[gender].up, 0, true)
QBCore.Functions.Notify('Nachtsicht deaktiviert!')
SetNightvision(false)
SetSeethrough(false)
mode = 0
end
end)
-- Behalte den alten Event-Namen für Kompatibilität
RegisterNetEvent('nightvision:toggleHelmet', function()
TriggerEvent('nightvision:toggleGlasses')
end)