refactor(es_extended): move small modules into their own folder

This commit is contained in:
Kasey FItton
2024-11-08 05:42:45 +00:00
parent 3ad1c34d02
commit 55c8b56b0b
2 changed files with 153 additions and 47 deletions
+1 -47
View File
@@ -92,57 +92,11 @@ local function DisableNPCs()
end
local function DisableAmmoOrVehicleRewards(playerId)
CreateThread(function()
while true do
if Config.DisableDisplayAmmo then
DisplayAmmoThisFrame(false)
end
if Config.DisableVehicleRewards then
DisablePlayerVehicleRewards(playerId)
end
Wait(0)
end
end)
end
local function ApplyConfig()
-- RemoveHudComponents
for i = 1, #Config.RemoveHudComponents do
if Config.RemoveHudComponents[i] then
SetHudComponentSize(i, 0.0, 0.0)
end
end
if Config.DisableAimAssist then
SetPlayerLockon(ESX.playerId, false)
end
-- DisableNPCDrops
if Config.DisableNPCDrops then
local weaponPickups = { `PICKUP_WEAPON_CARBINERIFLE`, `PICKUP_WEAPON_PISTOL`, `PICKUP_WEAPON_PUMPSHOTGUN` }
for i = 1, #weaponPickups do
ToggleUsePickupsForPlayer(ESX.playerId, weaponPickups[i], false)
end
end
if Config.DisableVehicleSeatShuff then
AddEventHandler("esx:enteredVehicle", function(vehicle, _, seat)
if seat > -1 then
SetPedIntoVehicle(ESX.PlayerData.ped, vehicle, seat)
SetPedConfigFlag(ESX.PlayerData.ped, 184, true)
end
end)
end
if Config.DisableHealthRegeneration then
SetPlayerHealthRechargeMultiplier(ESX.playerId, 0.0)
end
if Config.DisableDisplayAmmo or Config.DisableVehicleRewards then
DisableAmmoOrVehicleRewards(ESX.playerId)
end
EnablePvP()
DisableNPCs()
@@ -175,7 +129,7 @@ ESX.SecureNetEvent("esx:playerLoaded", function(xPlayer, _, skin)
Wait(0)
end
ApplyConfig()
Adjustments:Load()
ClearPedTasksImmediately(ESX.PlayerData.ped)
@@ -0,0 +1,152 @@
Adjustments = {}
function Adjustments:RemoveHudComponents()
for i = 1, #Config.RemoveHudComponents do
if Config.RemoveHudComponents[i] then
SetHudComponentSize(i, 0.0, 0.0)
end
end
end
function Adjustments:DisableAimAssist()
if Config.DisableAimAssist then
SetPlayerLockon(ESX.playerId, false)
end
end
function Adjustments:DisableNPCDrops()
if Config.DisableNPCDrops then
local weaponPickups = { `PICKUP_WEAPON_CARBINERIFLE`, `PICKUP_WEAPON_PISTOL`, `PICKUP_WEAPON_PUMPSHOTGUN` }
for i = 1, #weaponPickups do
ToggleUsePickupsForPlayer(ESX.playerId, weaponPickups[i], false)
end
end
end
function Adjustments:SeatShuffle()
if Config.DisableVehicleSeatShuff then
AddEventHandler("esx:enteredVehicle", function(vehicle, _, seat)
if seat > -1 then
SetPedIntoVehicle(ESX.PlayerData.ped, vehicle, seat)
SetPedConfigFlag(ESX.PlayerData.ped, 184, true)
end
end)
end
end
function Adjustments:HealthRegeneration()
if Config.DisableHealthRegeneration then
SetPlayerHealthRechargeMultiplier(ESX.playerId, 0.0)
end
end
function Adjustments:AmmoAndVehicleRewards()
CreateThread(function()
while true do
if Config.DisableDisplayAmmo then
DisplayAmmoThisFrame(false)
end
if Config.DisableVehicleRewards then
DisablePlayerVehicleRewards(ESX.playerId)
end
Wait(0)
end
end)
end
function Adjustments:EnablePvP()
if Config.EnablePVP then
SetCanAttackFriendly(ESX.PlayerData.ped, true, false)
NetworkSetFriendlyFireOption(true)
end
end
function Adjustments:DispatchServices()
if Config.DisableDispatchServices then
for i = 1, 15 do
EnableDispatchService(i, false)
end
SetAudioFlag('PoliceScannerDisabled', true)
end
end
function Adjustments:NPCScenarios()
if Config.DisableScenarios then
local scenarios = {
"WORLD_VEHICLE_ATTRACTOR",
"WORLD_VEHICLE_AMBULANCE",
"WORLD_VEHICLE_BICYCLE_BMX",
"WORLD_VEHICLE_BICYCLE_BMX_BALLAS",
"WORLD_VEHICLE_BICYCLE_BMX_FAMILY",
"WORLD_VEHICLE_BICYCLE_BMX_HARMONY",
"WORLD_VEHICLE_BICYCLE_BMX_VAGOS",
"WORLD_VEHICLE_BICYCLE_MOUNTAIN",
"WORLD_VEHICLE_BICYCLE_ROAD",
"WORLD_VEHICLE_BIKE_OFF_ROAD_RACE",
"WORLD_VEHICLE_BIKER",
"WORLD_VEHICLE_BOAT_IDLE",
"WORLD_VEHICLE_BOAT_IDLE_ALAMO",
"WORLD_VEHICLE_BOAT_IDLE_MARQUIS",
"WORLD_VEHICLE_BOAT_IDLE_MARQUIS",
"WORLD_VEHICLE_BROKEN_DOWN",
"WORLD_VEHICLE_BUSINESSMEN",
"WORLD_VEHICLE_HELI_LIFEGUARD",
"WORLD_VEHICLE_CLUCKIN_BELL_TRAILER",
"WORLD_VEHICLE_CONSTRUCTION_SOLO",
"WORLD_VEHICLE_CONSTRUCTION_PASSENGERS",
"WORLD_VEHICLE_DRIVE_PASSENGERS",
"WORLD_VEHICLE_DRIVE_PASSENGERS_LIMITED",
"WORLD_VEHICLE_DRIVE_SOLO",
"WORLD_VEHICLE_FIRE_TRUCK",
"WORLD_VEHICLE_EMPTY",
"WORLD_VEHICLE_MARIACHI",
"WORLD_VEHICLE_MECHANIC",
"WORLD_VEHICLE_MILITARY_PLANES_BIG",
"WORLD_VEHICLE_MILITARY_PLANES_SMALL",
"WORLD_VEHICLE_PARK_PARALLEL",
"WORLD_VEHICLE_PARK_PERPENDICULAR_NOSE_IN",
"WORLD_VEHICLE_PASSENGER_EXIT",
"WORLD_VEHICLE_POLICE_BIKE",
"WORLD_VEHICLE_POLICE_CAR",
"WORLD_VEHICLE_POLICE",
"WORLD_VEHICLE_POLICE_NEXT_TO_CAR",
"WORLD_VEHICLE_QUARRY",
"WORLD_VEHICLE_SALTON",
"WORLD_VEHICLE_SALTON_DIRT_BIKE",
"WORLD_VEHICLE_SECURITY_CAR",
"WORLD_VEHICLE_STREETRACE",
"WORLD_VEHICLE_TOURBUS",
"WORLD_VEHICLE_TOURIST",
"WORLD_VEHICLE_TANDL",
"WORLD_VEHICLE_TRACTOR",
"WORLD_VEHICLE_TRACTOR_BEACH",
"WORLD_VEHICLE_TRUCK_LOGS",
"WORLD_VEHICLE_TRUCKS_TRAILERS",
"WORLD_VEHICLE_DISTANT_EMPTY_GROUND",
"WORLD_HUMAN_PAPARAZZI",
}
for i=1, #scenarios do
SetScenarioTypeEnabled(scenarios[i], false)
end
end
end
function Adjustments:LicensePlates()
SetDefaultVehicleNumberPlateTextPattern(-1, Config.CustomAIPlates)
end
function Adjustments:Load()
self:RemoveHudComponents()
self:DisableAimAssist()
self:DisableNPCDrops()
self:SeatShuffle()
self:HealthRegeneration()
self:AmmoAndVehicleRewards()
self:EnablePvP()
self:DispatchServices()
self:NPCScenarios()
self:LicensePlates()
end