forked from Simnation/Main
edit
This commit is contained in:
parent
383fe3647a
commit
2d5b44dac7
2 changed files with 79 additions and 14 deletions
|
@ -99,8 +99,6 @@ end
|
||||||
-- Thread für das Licht-Update
|
-- Thread für das Licht-Update
|
||||||
Citizen.CreateThread(function()
|
Citizen.CreateThread(function()
|
||||||
while true do
|
while true do
|
||||||
Citizen.Wait(0)
|
|
||||||
|
|
||||||
if flashlightActive and DoesEntityExist(flashlightObject) then
|
if flashlightActive and DoesEntityExist(flashlightObject) then
|
||||||
local ped = PlayerPedId()
|
local ped = PlayerPedId()
|
||||||
|
|
||||||
|
@ -118,24 +116,91 @@ Citizen.CreateThread(function()
|
||||||
local pos = GetEntityCoords(ped)
|
local pos = GetEntityCoords(ped)
|
||||||
local forwardVector = GetEntityForwardVector(ped)
|
local forwardVector = GetEntityForwardVector(ped)
|
||||||
local c = Config.Flashlight.color
|
local c = Config.Flashlight.color
|
||||||
local range = Config.Flashlight.range
|
|
||||||
local intensity = Config.Flashlight.intensity
|
|
||||||
|
|
||||||
-- Zeichne das Licht in Blickrichtung
|
-- Berechne die Zielposition für das Licht (weiter vorne)
|
||||||
DrawSpotLight(
|
local targetPos = vector3(
|
||||||
pos.x, pos.y, pos.z + 1.0,
|
pos.x + forwardVector.x * 10.0,
|
||||||
forwardVector.x, forwardVector.y, forwardVector.z,
|
pos.y + forwardVector.y * 10.0,
|
||||||
c.r, c.g, c.b,
|
pos.z + forwardVector.z * 10.0
|
||||||
range, intensity,
|
)
|
||||||
0.0, 1.0, 1.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
|
end
|
||||||
|
|
||||||
|
Citizen.Wait(0) -- Jedes Frame aktualisieren
|
||||||
else
|
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
|
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
|
-- Nachtsicht-Befehl
|
||||||
RegisterCommand('toggleNV', function()
|
RegisterCommand('toggleNV', function()
|
||||||
local ped = PlayerPedId()
|
local ped = PlayerPedId()
|
||||||
|
|
|
@ -43,8 +43,8 @@ Config.Glasses = {
|
||||||
-- Flashlight configuration
|
-- Flashlight configuration
|
||||||
Config.Flashlight = {
|
Config.Flashlight = {
|
||||||
color = {r = 255, g = 255, b = 255}, -- Farbe des Lichts (weiß)
|
color = {r = 255, g = 255, b = 255}, -- Farbe des Lichts (weiß)
|
||||||
range = 30.0, -- Reichweite des Lichts
|
range = 50.0, -- Erhöhte Reichweite des Lichts
|
||||||
intensity = 8.0, -- Intensität des Lichts
|
intensity = 15.0, -- Erhöhte Intensität des Lichts
|
||||||
offset = {x = 0.0, y = 0.3, z = 0.0} -- Position des Lichts relativ zum Kopf
|
offset = {x = 0.0, y = 0.3, z = 0.0} -- Position des Lichts relativ zum Kopf
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue