1
0
Fork 0
forked from Simnation/Main
Main/resources/[standalone]/controlled_npcs/client.lua

121 lines
4.1 KiB
Lua
Raw Normal View History

2025-08-12 13:27:24 +02:00
-- Globale Variablen für Bewegungserkennung
local isPlayerMoving = true
local lastPos = vector3(0,0,0)
local positionCheckTimer = 0
2025-06-07 08:51:21 +02:00
CreateThread(function()
-- Dispatch vollständig deaktivieren (Cops, Medic, Fire etc.)
for i = 1, 15 do
EnableDispatchService(i, false)
end
end)
2025-08-12 13:27:24 +02:00
-- Bewegungserkennung
2025-06-07 08:51:21 +02:00
CreateThread(function()
while true do
2025-08-12 13:27:24 +02:00
local playerPed = PlayerPedId()
local currentPos = GetEntityCoords(playerPed)
-- Prüfen, ob der Spieler sich bewegt hat
if #(currentPos - lastPos) < 1.0 then
positionCheckTimer = positionCheckTimer + 1
if positionCheckTimer > 5 then -- Nach 5 Sekunden ohne Bewegung
isPlayerMoving = false
end
else
isPlayerMoving = true
positionCheckTimer = 0
end
2025-06-29 11:16:50 +02:00
2025-08-12 13:27:24 +02:00
lastPos = currentPos
Wait(1000) -- Jede Sekunde prüfen
end
end)
2025-08-12 13:16:48 +02:00
2025-08-12 13:27:24 +02:00
CreateThread(function()
while true do
-- Fußgängerdichte beibehalten
SetPedDensityMultiplierThisFrame(0.5)
SetScenarioPedDensityMultiplierThisFrame(0.5, 0.5)
-- Verkehrsdichte basierend auf Bewegung anpassen
local densityMultiplier = isPlayerMoving and 0.1 or 0.05
SetVehicleDensityMultiplierThisFrame(densityMultiplier)
SetRandomVehicleDensityMultiplierThisFrame(densityMultiplier)
SetParkedVehicleDensityMultiplierThisFrame(densityMultiplier)
SetParkedCarDensityPercentage(densityMultiplier)
2025-06-29 11:16:50 +02:00
2025-06-07 08:51:21 +02:00
-- Kein Wanted-Level / Polizei-Eingriffe
SetPlayerWantedLevel(PlayerId(), 0, false)
ClearPlayerWantedLevel(PlayerId())
SetDispatchCopsForPlayer(PlayerId(), false)
DisablePlayerVehicleRewards(PlayerId())
-- Kein Spawn von aggressiven Gangs & Sonderfahrzeugen
local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed)
ClearAreaOfCops(coords.x, coords.y, coords.z, 1000.0)
2025-06-29 11:16:50 +02:00
2025-08-12 13:16:48 +02:00
-- Nur spezifische Fahrzeuge entfernen (Notfallfahrzeuge)
2025-06-07 08:51:21 +02:00
local peds = GetGamePool("CPed")
for _, ped in ipairs(peds) do
if DoesEntityExist(ped) and not IsPedAPlayer(ped) then
if IsPedInAnyVehicle(ped, false) then
local veh = GetVehiclePedIsIn(ped, false)
local vehModel = GetEntityModel(veh)
for k, v in pairs(Config.vehModels) do
if vehModel == GetHashKey(v) then
DeleteEntity(veh)
DeleteEntity(ped)
end
end
end
end
end
2025-08-12 13:27:24 +02:00
Wait(100)
2025-06-29 11:16:50 +02:00
end
end)
2025-08-12 13:16:48 +02:00
-- Thread für Verkehrsmanagement
2025-06-29 11:16:50 +02:00
CreateThread(function()
while true do
local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed)
2025-08-12 13:27:24 +02:00
-- Wenn Spieler steht, aggressiver Fahrzeuge in der Nähe entfernen
if not isPlayerMoving then
local vehicles = GetGamePool("CVehicle")
for _, vehicle in ipairs(vehicles) do
if DoesEntityExist(vehicle) and not IsPedAPlayer(GetPedInVehicleSeat(vehicle, -1)) then
local vehCoords = GetEntityCoords(vehicle)
local distance = #(coords - vehCoords)
-- Wenn Spieler steht, Fahrzeuge in mittlerer Entfernung entfernen
if distance > 100.0 and distance < 200.0 then
DeleteEntity(vehicle)
end
end
end
end
-- Normale Entfernung für weit entfernte Fahrzeuge
2025-06-29 11:16:50 +02:00
local vehicles = GetGamePool("CVehicle")
for _, vehicle in ipairs(vehicles) do
if DoesEntityExist(vehicle) and not IsPedAPlayer(GetPedInVehicleSeat(vehicle, -1)) then
local vehCoords = GetEntityCoords(vehicle)
local distance = #(coords - vehCoords)
2025-08-12 13:27:24 +02:00
if distance > 250.0 then
2025-06-29 11:16:50 +02:00
DeleteEntity(vehicle)
end
end
end
2025-08-12 13:27:24 +02:00
Wait(8000)
2025-06-07 08:51:21 +02:00
end
end)