I’m trying to use the move hook to change the player’s max speed in my script, but for some reason it’s making the player go hyper speed. I’ve checked the math in a calculator and it doesn’t make any sense so maybe someone here can see the error.
if SERVER then
hook.Add(“Move”, “VNTWeaponWeightSpeedMod”, function(_P)
local _PLYSPEEDWALK = _P:GetWalkSpeed()
local _PLYSPEEDRUN = _P:GetRunSpeed()
local _CURWEIGHT = _P:GetNWInt( “VNTWeaponWeightCurrent” )
local _PLYSPEEDWALKNEW = ( _PLYSPEEDWALK / _CURWEIGHT )
local _PLYSPEEDRUNNEW = ( _PLYSPEEDRUN / _CURWEIGHT )
if (((_P:KeyDown(IN_FORWARD) or _P:KeyDown(IN_BACK) or _P:KeyDown(IN_MOVELEFT) or _P:KeyDown(IN_MOVERIGHT))) and (_P:GetNWInt(“VNTWeaponWeightCurrent”) > GetConVarNumber(“VNT_WeaponWeight_Max”)) ) then
_P:SetWalkSpeed( _PLYSPEEDWALKNEW )
_P:SetRunSpeed( _PLYSPEEDRUNNEW )
The function works, but the speed it’s setting the player to is exponentially higher than the default causing you to go airbourne. Can anyone explain what I did wrong?
In the calculator, the walk speed (250) divided by the weapon weight, say 45, comes out to 5, but for some reason no matter what speed I give it the player’s speed goes berserk.