mirror of
https://github.com/jimathy/jim_bridge.git
synced 2026-08-17 05:56:02 +01:00
Create setStress function
This allows per framework stress functions to be set, including ESX For ESX the math is done in this function as their values are insanely high instead of 0 - 100
This commit is contained in:
@@ -29,6 +29,14 @@ local hungerThirstFunc = {
|
||||
Player.Functions.SetMetaData('hunger', newHunger)
|
||||
TriggerClientEvent("hud:client:UpdateNeeds", src, newHunger, Player.PlayerData.metadata.thirst)
|
||||
end,
|
||||
setStress =
|
||||
function(src, stress)
|
||||
local Player = Core.Functions.GetPlayer(src)
|
||||
local newStress = Player.PlayerData.metadata.stress + stress
|
||||
newStress = (newStress >= 100.0 and 100.0)or (newStress <= 0 and 0) or newStress
|
||||
Player.Functions.SetMetaData('stress', newStress)
|
||||
TriggerClientEvent('hud:client:UpdateStress', src, newStress)
|
||||
end,
|
||||
},
|
||||
|
||||
{ framework = QBExport,
|
||||
@@ -48,6 +56,14 @@ local hungerThirstFunc = {
|
||||
Player.Functions.SetMetaData('hunger', newHunger)
|
||||
TriggerClientEvent("hud:client:UpdateNeeds", src, newHunger, Player.PlayerData.metadata.thirst)
|
||||
end,
|
||||
setStress =
|
||||
function(src, stress)
|
||||
local Player = Core.Functions.GetPlayer(src)
|
||||
local newStress = Player.PlayerData.metadata.stress + stress
|
||||
newStress = (newStress >= 100.0 and 100.0)or (newStress <= 0 and 0) or newStress
|
||||
Player.Functions.SetMetaData('stress', newStress)
|
||||
TriggerClientEvent('hud:client:UpdateStress', src, newStress)
|
||||
end,
|
||||
},
|
||||
|
||||
{ framework = RSGExport,
|
||||
@@ -67,6 +83,14 @@ local hungerThirstFunc = {
|
||||
Player.Functions.SetMetaData('hunger', newHunger)
|
||||
TriggerClientEvent("hud:client:UpdateNeeds", src, newHunger, Player.PlayerData.metadata.thirst)
|
||||
end,
|
||||
setStress =
|
||||
function(src, stress)
|
||||
local Player = Core.Functions.GetPlayer(src)
|
||||
local newStress = Player.PlayerData.metadata.stress + stress
|
||||
newStress = (newStress >= 100.0 and 100.0) or (newStress <= 0 and 0) or newStress
|
||||
Player.Functions.SetMetaData('stress', newStress)
|
||||
TriggerClientEvent('hud:client:UpdateStress', src, newStress)
|
||||
end,
|
||||
},
|
||||
|
||||
{ framework = ESXExport,
|
||||
@@ -78,6 +102,10 @@ local hungerThirstFunc = {
|
||||
function(src, hunger)
|
||||
TriggerClientEvent('esx_status:add', src, 'hunger', tonumber(hunger) * 10000)
|
||||
end,
|
||||
setStress =
|
||||
function(src, stress)
|
||||
TriggerClientEvent("esx_status:add", src, "stress", tonumber(stress) * 10000)
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -126,6 +154,26 @@ function setHunger(src, hunger)
|
||||
end
|
||||
end
|
||||
|
||||
--- Sets the player's stress level.
|
||||
---
|
||||
--- @param src number The player's server ID.
|
||||
--- @param stress number The new stress level.
|
||||
---
|
||||
--- @usage
|
||||
--- ```lua
|
||||
--- setStress(playerId, 60)
|
||||
--- ```
|
||||
function setStress(src, stress)
|
||||
for i = 1, #hungerThirstFunc do
|
||||
local framework = hungerThirstFunc[i]
|
||||
if isStarted(framework.framework) then
|
||||
debugPrint("^4Debug^7: ^2Adding ^3"..framework.framework.." ^2stress^7: ^3"..stress.." ^2to player^7: ^3"..src.."^7")
|
||||
framework.setStress(src, stress)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- Server event handler for urinal usage.
|
||||
--- Decreases player's thirst by a random amount.
|
||||
RegisterNetEvent(getScript()..":server:Urinal", function()
|
||||
|
||||
Reference in New Issue
Block a user