forked from Simnation/Main
edit
This commit is contained in:
parent
7de5955637
commit
e6434e77c8
2 changed files with 164 additions and 50 deletions
|
@ -1,12 +1,21 @@
|
|||
local QBCore = exports[Config.CoreName]:GetCoreObject()
|
||||
local mode = 0
|
||||
local canToggle = false
|
||||
local nvMode = 0
|
||||
local thermalMode = 0
|
||||
|
||||
-- Funktion zum Prüfen des Charaktergeschlechts
|
||||
local function IsPedMale(ped)
|
||||
return GetEntityModel(ped) == `mp_m_freemode_01`
|
||||
end
|
||||
|
||||
-- Funktion zum Deaktivieren aller Sichtmodi
|
||||
local function DisableAllVisionModes()
|
||||
SetNightvision(false)
|
||||
SetSeethrough(false)
|
||||
nvMode = 0
|
||||
thermalMode = 0
|
||||
end
|
||||
|
||||
-- Nachtsicht-Befehl
|
||||
RegisterCommand('toggleNV', function()
|
||||
local ped = PlayerPedId()
|
||||
|
||||
|
@ -14,72 +23,173 @@ RegisterCommand('toggleNV', function()
|
|||
local currentGlasses = GetPedPropIndex(ped, 1)
|
||||
local gender = IsPedMale(ped) and "male" or "female"
|
||||
|
||||
-- Prüfen, ob der Spieler eine der NV-Brillen trägt
|
||||
-- Prüfen, ob der Spieler eine der Brillen trägt
|
||||
local canToggle = not Config.CheckHelmet
|
||||
if Config.CheckHelmet then
|
||||
if currentGlasses == Config.Glasses[gender].up or currentGlasses == Config.Glasses[gender].down then
|
||||
if currentGlasses == Config.Glasses[gender].up or
|
||||
currentGlasses == Config.Glasses[gender].nvDown then
|
||||
canToggle = true
|
||||
else
|
||||
canToggle = false
|
||||
end
|
||||
else
|
||||
canToggle = true
|
||||
end
|
||||
|
||||
if canToggle then
|
||||
-- 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)
|
||||
-- Deaktiviere zuerst Wärmebild, falls aktiv
|
||||
if thermalMode > 0 then
|
||||
SetSeethrough(false)
|
||||
thermalMode = 0
|
||||
-- Wenn die Brille runtergeklappt ist, klappe sie hoch
|
||||
if currentGlasses == Config.Glasses[gender].thermalDown then
|
||||
SetPedPropIndex(ped, 1, Config.Glasses[gender].up, 0, true)
|
||||
end
|
||||
end
|
||||
|
||||
-- Nachtsicht-Modus umschalten
|
||||
if nvMode == 0 then
|
||||
-- Wenn die Brille hochgeklappt ist, klappe sie runter
|
||||
if currentGlasses == Config.Glasses[gender].up then
|
||||
SetPedPropIndex(ped, 1, Config.Glasses[gender].nvDown, 0, true)
|
||||
end
|
||||
QBCore.Functions.Notify('Nachtsicht aktiviert!')
|
||||
SetNightvision(true)
|
||||
mode = 1
|
||||
-- Wenn bereits im Nachtsichtmodus, wechsle zu Wärmesicht
|
||||
elseif mode == 1 then
|
||||
QBCore.Functions.Notify('Wärmesicht aktiviert!')
|
||||
SetSeethrough(true)
|
||||
mode = 2
|
||||
-- Wenn im Wärmesichtmodus, deaktiviere alles und klappe Brille hoch
|
||||
elseif mode == 2 then
|
||||
SetPedPropIndex(ped, 1, Config.Glasses[gender].up, 0, true)
|
||||
nvMode = 1
|
||||
else
|
||||
-- Wenn die Brille runtergeklappt ist, klappe sie hoch
|
||||
if currentGlasses == Config.Glasses[gender].nvDown then
|
||||
SetPedPropIndex(ped, 1, Config.Glasses[gender].up, 0, true)
|
||||
end
|
||||
QBCore.Functions.Notify('Nachtsicht deaktiviert!')
|
||||
SetNightvision(false)
|
||||
SetSeethrough(false)
|
||||
mode = 0
|
||||
nvMode = 0
|
||||
end
|
||||
else
|
||||
QBCore.Functions.Notify('Du trägst keine Nachtsichtbrille!', 'error')
|
||||
end
|
||||
else
|
||||
QBCore.Functions.Notify('Du hast kein Nachtsichtgerät!', 'error')
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterKeyMapping('toggleNV', 'Toggle nightvision', 'keyboard', Config.NVKey)
|
||||
-- Wärmebild-Befehl
|
||||
RegisterCommand('toggleThermal', function()
|
||||
local ped = PlayerPedId()
|
||||
|
||||
if QBCore.Functions.HasItem(Config.ThermalItem) then
|
||||
local currentGlasses = GetPedPropIndex(ped, 1)
|
||||
local gender = IsPedMale(ped) and "male" or "female"
|
||||
|
||||
-- Prüfen, ob der Spieler eine der Brillen trägt
|
||||
local canToggle = not Config.CheckHelmet
|
||||
if Config.CheckHelmet then
|
||||
if currentGlasses == Config.Glasses[gender].up or
|
||||
currentGlasses == Config.Glasses[gender].thermalDown then
|
||||
canToggle = true
|
||||
end
|
||||
end
|
||||
|
||||
-- Umbenannt für bessere Klarheit
|
||||
RegisterNetEvent('nightvision:toggleGlasses', function()
|
||||
if canToggle then
|
||||
-- Deaktiviere zuerst Nachtsicht, falls aktiv
|
||||
if nvMode > 0 then
|
||||
SetNightvision(false)
|
||||
nvMode = 0
|
||||
-- Wenn die Brille runtergeklappt ist, klappe sie hoch
|
||||
if currentGlasses == Config.Glasses[gender].nvDown then
|
||||
SetPedPropIndex(ped, 1, Config.Glasses[gender].up, 0, true)
|
||||
end
|
||||
end
|
||||
|
||||
-- Wärmebild-Modus umschalten
|
||||
if thermalMode == 0 then
|
||||
-- Wenn die Brille hochgeklappt ist, klappe sie runter
|
||||
if currentGlasses == Config.Glasses[gender].up then
|
||||
SetPedPropIndex(ped, 1, Config.Glasses[gender].thermalDown, 0, true)
|
||||
end
|
||||
QBCore.Functions.Notify('Wärmebild aktiviert!')
|
||||
SetSeethrough(true)
|
||||
thermalMode = 1
|
||||
else
|
||||
-- Wenn die Brille runtergeklappt ist, klappe sie hoch
|
||||
if currentGlasses == Config.Glasses[gender].thermalDown then
|
||||
SetPedPropIndex(ped, 1, Config.Glasses[gender].up, 0, true)
|
||||
end
|
||||
QBCore.Functions.Notify('Wärmebild deaktiviert!')
|
||||
SetSeethrough(false)
|
||||
thermalMode = 0
|
||||
end
|
||||
else
|
||||
QBCore.Functions.Notify('Du trägst keine Wärmebildbrille!', 'error')
|
||||
end
|
||||
else
|
||||
QBCore.Functions.Notify('Du hast kein Wärmebildgerät!', 'error')
|
||||
end
|
||||
end)
|
||||
|
||||
-- Tastenbelegungen registrieren
|
||||
RegisterKeyMapping('toggleNV', 'Nachtsicht umschalten', 'keyboard', Config.NVKey)
|
||||
RegisterKeyMapping('toggleThermal', 'Wärmebild umschalten', 'keyboard', Config.ThermalKey)
|
||||
|
||||
-- Event zum Umschalten der Brille
|
||||
RegisterNetEvent('nightvision:toggleGlasses', function(mode)
|
||||
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
|
||||
-- Alle Sichtmodi deaktivieren
|
||||
DisableAllVisionModes()
|
||||
|
||||
if mode == 'nightvision' then
|
||||
-- Wenn keine Brille getragen wird, setze hochgeklappte Version auf
|
||||
if currentGlasses ~= Config.Glasses[gender].up and
|
||||
currentGlasses ~= Config.Glasses[gender].nvDown and
|
||||
currentGlasses ~= Config.Glasses[gender].thermalDown then
|
||||
SetPedPropIndex(ped, 1, Config.Glasses[gender].up, 0, true)
|
||||
QBCore.Functions.Notify('Nachtsichtbrille aufgesetzt!')
|
||||
-- Wenn hochgeklappte Brille getragen wird, klappe sie runter und aktiviere Nachtsicht
|
||||
elseif currentGlasses == Config.Glasses[gender].up then
|
||||
SetPedPropIndex(ped, 1, Config.Glasses[gender].nvDown, 0, true)
|
||||
QBCore.Functions.Notify('Nachtsicht aktiviert!')
|
||||
SetNightvision(true)
|
||||
nvMode = 1
|
||||
-- Wenn runtergeklappte Brille getragen wird, klappe sie hoch und deaktiviere Nachtsicht
|
||||
elseif currentGlasses == Config.Glasses[gender].nvDown then
|
||||
SetPedPropIndex(ped, 1, Config.Glasses[gender].up, 0, true)
|
||||
QBCore.Functions.Notify('Nachtsicht deaktiviert!')
|
||||
nvMode = 0
|
||||
-- Wenn Wärmebildbrille getragen wird, wechsle zu Nachtsichtbrille
|
||||
elseif currentGlasses == Config.Glasses[gender].thermalDown then
|
||||
SetPedPropIndex(ped, 1, Config.Glasses[gender].nvDown, 0, true)
|
||||
QBCore.Functions.Notify('Nachtsicht aktiviert!')
|
||||
SetNightvision(true)
|
||||
nvMode = 1
|
||||
end
|
||||
elseif mode == 'thermal' then
|
||||
-- Wenn keine Brille getragen wird, setze hochgeklappte Version auf
|
||||
if currentGlasses ~= Config.Glasses[gender].up and
|
||||
currentGlasses ~= Config.Glasses[gender].nvDown and
|
||||
currentGlasses ~= Config.Glasses[gender].thermalDown then
|
||||
SetPedPropIndex(ped, 1, Config.Glasses[gender].up, 0, true)
|
||||
QBCore.Functions.Notify('Wärmebildbrille aufgesetzt!')
|
||||
-- Wenn hochgeklappte Brille getragen wird, klappe sie runter und aktiviere Wärmebild
|
||||
elseif currentGlasses == Config.Glasses[gender].up then
|
||||
SetPedPropIndex(ped, 1, Config.Glasses[gender].thermalDown, 0, true)
|
||||
QBCore.Functions.Notify('Wärmebild aktiviert!')
|
||||
SetSeethrough(true)
|
||||
thermalMode = 1
|
||||
-- Wenn runtergeklappte Wärmebildbrille getragen wird, klappe sie hoch und deaktiviere Wärmebild
|
||||
elseif currentGlasses == Config.Glasses[gender].thermalDown then
|
||||
SetPedPropIndex(ped, 1, Config.Glasses[gender].up, 0, true)
|
||||
QBCore.Functions.Notify('Wärmebild deaktiviert!')
|
||||
thermalMode = 0
|
||||
-- Wenn Nachtsichtbrille getragen wird, wechsle zu Wärmebildbrille
|
||||
elseif currentGlasses == Config.Glasses[gender].nvDown then
|
||||
SetPedPropIndex(ped, 1, Config.Glasses[gender].thermalDown, 0, true)
|
||||
QBCore.Functions.Notify('Wärmebild aktiviert!')
|
||||
SetSeethrough(true)
|
||||
thermalMode = 1
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
-- Behalte den alten Event-Namen für Kompatibilität
|
||||
RegisterNetEvent('nightvision:toggleHelmet', function()
|
||||
TriggerEvent('nightvision:toggleGlasses')
|
||||
TriggerEvent('nightvision:toggleGlasses', 'nightvision')
|
||||
end)
|
||||
|
|
|
@ -2,17 +2,21 @@ Config = Config or {}
|
|||
|
||||
Config.CoreName = 'qb-core' -- Change this if you changed the core name.
|
||||
Config.NVItem = 'nightvision' -- Item needed to use nightvision
|
||||
Config.CheckHelmet = true -- Umbenannt zu CheckGlasses wäre besser, aber für Kompatibilität belassen
|
||||
Config.NVKey = 'N' -- The key you want to be pressed to toggle night/thermal vision
|
||||
Config.ThermalItem = 'thermalvision' -- Neues Item für Wärmebildsicht
|
||||
Config.CheckHelmet = true -- Prüft, ob der Spieler die entsprechende Brille trägt
|
||||
Config.NVKey = 'N' -- Taste für Nachtsicht
|
||||
Config.ThermalKey = 'M' -- Neue Taste für Wärmebildsicht
|
||||
|
||||
-- Neue Konfigurationsoptionen für die Brillen
|
||||
-- Konfigurationsoptionen für die Brillen
|
||||
Config.Glasses = {
|
||||
male = {
|
||||
up = 116, -- ID für hochgeklappte NV-Brille (männlich) - Ändern Sie diese zu Ihrer tatsächlichen ID
|
||||
down = 117 -- ID für runtergeklappte NV-Brille (männlich) - Ändern Sie diese zu Ihrer tatsächlichen ID
|
||||
up = 116, -- ID für hochgeklappte NV-Brille (männlich)
|
||||
nvDown = 117, -- ID für runtergeklappte Nachtsichtbrille (männlich)
|
||||
thermalDown = 118 -- ID für runtergeklappte Wärmebildbrille (männlich)
|
||||
},
|
||||
female = {
|
||||
up = 70, -- ID für hochgeklappte NV-Brille (weiblich) - Ändern Sie diese zu Ihrer tatsächlichen ID
|
||||
down = 73 -- ID für runtergeklappte NV-Brille (weiblich) - Ändern Sie diese zu Ihrer tatsächlichen ID
|
||||
up = 70, -- ID für hochgeklappte NV-Brille (weiblich)
|
||||
nvDown = 73, -- ID für runtergeklappte Nachtsichtbrille (weiblich)
|
||||
thermalDown = 73 -- ID für runtergeklappte Wärmebildbrille (weiblich)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue