Skip to content

Commit

Permalink
stamina: Move speed reduction to a SetupMove (#457)
Browse files Browse the repository at this point in the history
* stamina: Move speed reduction to a SetupMove

We should not be forcing the speed of anything in a temporary manner, especially reverting back to config values when these may not be the values that were being used.

* stamina: use a plugin hook

* stamina: style fix
  • Loading branch information
NathanX-S authored Dec 10, 2024
1 parent b64d465 commit de782b4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions plugins/stamina/sh_plugin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,13 @@ local function CalcStaminaChange(client)
client:SetLocalVar("stm", value)

if (value == 0 and !client:GetNetVar("brth", false)) then
client:SetRunSpeed(walkSpeed)
client:SetNetVar("brth", true)

character:UpdateAttrib("end", 0.1)
character:UpdateAttrib("stm", 0.01)

hook.Run("PlayerStaminaLost", client)
elseif (value >= 50 and client:GetNetVar("brth", false)) then
client:SetRunSpeed(runSpeed)
client:SetNetVar("brth", nil)

hook.Run("PlayerStaminaGained", client)
Expand All @@ -80,6 +78,11 @@ local function CalcStaminaChange(client)
end
end

function PLUGIN:SetupMove(client, mv, cmd)
if (client:GetNetVar("brth", false)) then
mv:SetMaxClientSpeed(client:GetWalkSpeed())
end
end

if (SERVER) then
function PLUGIN:PostPlayerLoadout(client)
Expand Down

0 comments on commit de782b4

Please sign in to comment.