From de782b41f6a60ce7605040a9bd41788869648045 Mon Sep 17 00:00:00 2001 From: "Nathan S." <55564547+NathanX-S@users.noreply.github.com> Date: Tue, 10 Dec 2024 14:56:16 -0500 Subject: [PATCH] stamina: Move speed reduction to a SetupMove (#457) * 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 --- plugins/stamina/sh_plugin.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/stamina/sh_plugin.lua b/plugins/stamina/sh_plugin.lua index 709a16938..ff4d154c9 100644 --- a/plugins/stamina/sh_plugin.lua +++ b/plugins/stamina/sh_plugin.lua @@ -63,7 +63,6 @@ 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) @@ -71,7 +70,6 @@ local function CalcStaminaChange(client) hook.Run("PlayerStaminaLost", client) elseif (value >= 50 and client:GetNetVar("brth", false)) then - client:SetRunSpeed(runSpeed) client:SetNetVar("brth", nil) hook.Run("PlayerStaminaGained", client) @@ -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)