mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 02:01:31 +00:00
Merge remote-tracking branch 'AlexRXWindy/adjust-player-stats' into dev
This commit is contained in:
@@ -235,6 +235,107 @@ function Adjustments:Multipliers()
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Adjustments:ApplyPlayerStats()
|
||||||
|
if not Config.PlayerStatsByGender.enabled then return end
|
||||||
|
|
||||||
|
if Config.EnableDebug then
|
||||||
|
print('[^3adjustments^7] applying player stats...')
|
||||||
|
end
|
||||||
|
|
||||||
|
local gender = self:GetPlayerGender()
|
||||||
|
if not gender then
|
||||||
|
if Config.EnableDebug then
|
||||||
|
print('[^1adjustments^7] failed to detect gender')
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local stats = Config.PlayerStatsByGender[gender]
|
||||||
|
if not stats then
|
||||||
|
if Config.EnableDebug then
|
||||||
|
print('[^1adjustments^7] no stats found for gender: ' .. gender)
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if stats.stamina then
|
||||||
|
SetRunSprintMultiplierForPlayer(ESX.playerId, stats.stamina)
|
||||||
|
end
|
||||||
|
|
||||||
|
if stats.strength then
|
||||||
|
SetPlayerMeleeWeaponDamageModifier(ESX.playerId, stats.strength)
|
||||||
|
end
|
||||||
|
|
||||||
|
if stats.swimSpeed then
|
||||||
|
SetSwimMultiplierForPlayer(ESX.playerId, stats.swimSpeed)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- moveSpeed requires continuous loop
|
||||||
|
if stats.moveSpeed then
|
||||||
|
self.currentMoveSpeed = stats.moveSpeed
|
||||||
|
if not self.moveSpeedThreadRunning then
|
||||||
|
self.moveSpeedThreadRunning = true
|
||||||
|
CreateThread(function()
|
||||||
|
while Config.PlayerStatsByGender.enabled and self.currentMoveSpeed do
|
||||||
|
if ESX.PlayerData.ped then
|
||||||
|
SetPedMoveRateOverride(ESX.PlayerData.ped, self.currentMoveSpeed)
|
||||||
|
end
|
||||||
|
Wait(0)
|
||||||
|
end
|
||||||
|
self.moveSpeedThreadRunning = false
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if Config.EnableDebug then
|
||||||
|
print('[^2adjustments^7] stats applied for gender: ' .. gender)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Adjustments:GetPlayerGender()
|
||||||
|
if not ESX.PlayerLoaded then
|
||||||
|
if Config.EnableDebug then
|
||||||
|
print('[^1adjustments^7] player not loaded yet')
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if Config.EnableDebug then
|
||||||
|
print('[^3adjustments^7] detecting gender using: ' .. (Config.PlayerStatsByGender.useCharacterData and 'character data' or 'ped model'))
|
||||||
|
end
|
||||||
|
|
||||||
|
if Config.PlayerStatsByGender.useCharacterData then
|
||||||
|
-- Option 1: character data
|
||||||
|
if ESX.PlayerData.sex then
|
||||||
|
return ESX.PlayerData.sex == 'm' and 'male' or 'female'
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- Option 2: ped model
|
||||||
|
local model = GetEntityModel(ESX.PlayerData.ped)
|
||||||
|
|
||||||
|
for i = 1, #Config.PlayerStatsByGender.malePeds do
|
||||||
|
if model == Config.PlayerStatsByGender.malePeds[i] then
|
||||||
|
return 'male'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for i = 1, #Config.PlayerStatsByGender.femalePeds do
|
||||||
|
if model == Config.PlayerStatsByGender.femalePeds[i] then
|
||||||
|
return 'female'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Native fallback
|
||||||
|
if IsPedMale(ESX.PlayerData.ped) then
|
||||||
|
return 'male'
|
||||||
|
else
|
||||||
|
return 'female'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
function Adjustments:Load()
|
function Adjustments:Load()
|
||||||
self:RemoveHudComponents()
|
self:RemoveHudComponents()
|
||||||
self:DisableAimAssist()
|
self:DisableAimAssist()
|
||||||
@@ -250,4 +351,25 @@ function Adjustments:Load()
|
|||||||
self:WantedLevel()
|
self:WantedLevel()
|
||||||
self:DisableRadio()
|
self:DisableRadio()
|
||||||
self:Multipliers()
|
self:Multipliers()
|
||||||
|
|
||||||
|
AddEventHandler('esx:playerLoaded', function(xPlayer, isNew, skin)
|
||||||
|
self:ApplyPlayerStats()
|
||||||
|
end)
|
||||||
|
|
||||||
|
if not Config.PlayerStatsByGender.useCharacterData then
|
||||||
|
AddEventHandler('skinchanger:modelLoaded', function()
|
||||||
|
self:ApplyPlayerStats()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
AddEventHandler('esx:onPlayerSpawn', function()
|
||||||
|
self:ApplyPlayerStats()
|
||||||
|
end)
|
||||||
|
|
||||||
|
if Config.PlayerStatsByGender.enabled and Config.EnableDebug then
|
||||||
|
print('[^2adjustments^7] player stats by gender loaded')
|
||||||
|
print('[^3adjustments^7] enabled: ' .. tostring(Config.PlayerStatsByGender.enabled))
|
||||||
|
print('[^3adjustments^7] use character data: ' .. tostring(Config.PlayerStatsByGender.useCharacterData))
|
||||||
|
print('[^3adjustments^7] debug mode: active')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -44,6 +44,37 @@ Config.Multipliers = {
|
|||||||
vehicleDensity = 1.0
|
vehicleDensity = 1.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Config.PlayerStatsByGender = {
|
||||||
|
enabled = true,
|
||||||
|
debugMode = true,
|
||||||
|
useCharacterData = true, -- true: uses ESX.PlayerData.sex | false: uses ped model/skin
|
||||||
|
malePeds = {
|
||||||
|
`mp_m_freemode_01`,
|
||||||
|
},
|
||||||
|
femalePeds = {
|
||||||
|
`mp_f_freemode_01`,
|
||||||
|
},
|
||||||
|
male = {
|
||||||
|
stamina = 1.0,
|
||||||
|
strength = 1.0,
|
||||||
|
swimSpeed = 1.25,
|
||||||
|
moveSpeed = 1.0,
|
||||||
|
|
||||||
|
-- ADD NEW STATS HERE
|
||||||
|
-- 1. Uncomment line below (remove --)
|
||||||
|
-- 2. Change value: 1.0 = normal, 1.5 = +50%, 0.5 = -50%
|
||||||
|
-- 3. Find natives: https://docs.fivem.net/natives/
|
||||||
|
-- statName = 1.0,
|
||||||
|
},
|
||||||
|
female = {
|
||||||
|
stamina = 1.15,
|
||||||
|
strength = 0.85,
|
||||||
|
swimSpeed = 1.25,
|
||||||
|
moveSpeed = 7.00,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
-- Pattern string format
|
-- Pattern string format
|
||||||
--1 will lead to a random number from 0-9.
|
--1 will lead to a random number from 0-9.
|
||||||
--A will lead to a random letter from A-Z.
|
--A will lead to a random letter from A-Z.
|
||||||
|
|||||||
Reference in New Issue
Block a user