• SWEP that slows movement speed when drawn and returns to normal when holstered
    3 replies, posted
I'm simply trying to make an already existing swep slow down the players run speed when drawn and then return to normal when the weapon is switched to something else. I did some searching online and found this code on this thread: [URL="https://facepunch.com/showthread.php?t=1284123"]https://facepunch.com/showthread.php?t=1284123[/URL] [CODE] function SWEP:Think() if self.Owner: GetActiveWeapon () == self then self.Owner: SetRunSpeed(120) end end [/CODE] Some how, the OP got it to work. For me, it slows down the the players move speed after he draws the weapon and stays the same regardless of switching away. Is there a swep function that checks for when the weapon is switched again so that I can return it to the normal movement speed or is there another way I could do this?
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/SetupMove]GM:SetupMove[/url] modify movedata in here
Player:SetMaxSpeed() or Player:SetRunSpeed() AND Player:SetWalkSpeed(). If you want to do fractions you could do Player:GetMax/Run/WalkSpeed() / 2
Or you could avoid SetWalkSpeed entirely since it's destructive and not incredibly simple to revert. e: for what I mean, consider two items that each need to modify walk speed. One is a gun, and one is a set of armor. Putting on the armor slows speed by 20% of ply:GetRunSpeed(), and same goes for the gun. On equip, each reverts the movespeed back to the value before equipping them. The issue: what happens if you take off the equipment you put on first? If you equipped armor and then gun, then unequipped the armor, you'd be left with a gun that has 100% movespeed. Instead, if you were to multiply the movespeed in a hook, you'd get much better results; no need to ever revert the values, nor any danger of conflicts.
Sorry, you need to Log In to post a reply to this thread.