1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-06-30 01:19:32 +02:00
parent 383fe3647a
commit 2d5b44dac7
2 changed files with 79 additions and 14 deletions

View file

@ -99,8 +99,6 @@ end
-- Thread für das Licht-Update
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if flashlightActive and DoesEntityExist(flashlightObject) then
local ped = PlayerPedId()
@ -118,24 +116,91 @@ Citizen.CreateThread(function()
local pos = GetEntityCoords(ped)
local forwardVector = GetEntityForwardVector(ped)
local c = Config.Flashlight.color
local range = Config.Flashlight.range
local intensity = Config.Flashlight.intensity
-- Zeichne das Licht in Blickrichtung
DrawSpotLight(
pos.x, pos.y, pos.z + 1.0,
forwardVector.x, forwardVector.y, forwardVector.z,
c.r, c.g, c.b,
range, intensity,
0.0, 1.0, 1.0
-- Berechne die Zielposition für das Licht (weiter vorne)
local targetPos = vector3(
pos.x + forwardVector.x * 10.0,
pos.y + forwardVector.y * 10.0,
pos.z + forwardVector.z * 10.0
)
-- Zeichne das Licht mit DrawSpotlightWithShadow für bessere Sichtbarkeit
DrawSpotlightWithShadow(
pos.x, pos.y, pos.z + 1.0, -- Startposition (über dem Kopf)
forwardVector.x, forwardVector.y, forwardVector.z, -- Richtung
c.r, c.g, c.b, -- Farbe
Config.Flashlight.range, -- Reichweite
Config.Flashlight.intensity, -- Helligkeit
Config.Flashlight.range / 2, -- Radius
Config.Flashlight.range * 1.5, -- Falloff
0.0, -- Rundheit
GetHashKey("FLASH_TORCH_LIGHT") -- Shadow ID
)
-- Zusätzlich einen helleren Punkt am Ziel zeichnen
DrawLightWithRange(
targetPos.x, targetPos.y, targetPos.z,
c.r, c.g, c.b,
3.0, -- Radius
Config.Flashlight.intensity / 2 -- Intensität
)
end
Citizen.Wait(0) -- Jedes Frame aktualisieren
else
Citizen.Wait(500) -- Längere Wartezeit, wenn keine Lampe aktiv ist
Citizen.Wait(500) -- Längere Wartezeit, wenn keine Lampe aktiv ist
end
end
end)
-- Funktion zum Aktivieren der Helm-Lampe
local function ToggleHelmetFlashlight()
local ped = PlayerPedId()
-- Prüfen, ob der Spieler den richtigen Helm trägt
if not IsWearingFlashlightHelmet(ped) then
QBCore.Functions.Notify('Du trägst keinen Helm mit Lampe!', 'error')
return
end
if flashlightActive then
-- Deaktiviere die Lampe
if DoesEntityExist(flashlightObject) then
DeleteEntity(flashlightObject)
flashlightObject = nil
end
flashlightActive = false
QBCore.Functions.Notify('Helm-Lampe ausgeschaltet!')
else
-- Aktiviere die Lampe
local boneIndex = GetPedBoneIndex(ped, 31086) -- Kopf-Knochen
-- Erstelle ein Licht-Objekt
local coords = GetEntityCoords(ped)
flashlightObject = CreateObject(GetHashKey("prop_cs_police_torch"), coords.x, coords.y, coords.z, true, true, true)
-- Mache das Objekt unsichtbar, aber behalte das Licht
SetEntityVisible(flashlightObject, false, 0)
SetEntityCollision(flashlightObject, false, false)
-- Befestige das Objekt am Kopf
AttachEntityToEntity(
flashlightObject,
ped,
boneIndex,
Config.Flashlight.offset.x,
Config.Flashlight.offset.y,
Config.Flashlight.offset.z,
0.0, 0.0, 0.0,
true, true, false, true, 0, true
)
flashlightActive = true
QBCore.Functions.Notify('Helm-Lampe eingeschaltet!')
end
end
-- Nachtsicht-Befehl
RegisterCommand('toggleNV', function()
local ped = PlayerPedId()