• Set Player Run Speed
    11 replies, posted
On player spawn I set the run speed, however the run speed never changes in-game. Keep in mind this is a mod so the original on spawn hook is also running. So I assume that mine is being run before the original and therefore when the original hook sets the run speed it over writes my mod's speed. So how do I fix? :P I've tried using GAMEMODE:SetPlayerSpeed and ply:SetRunSpeed (both PlayerSpawn event) and while they work when they're called normally, they don't work on the spawn event. The best work around I can think of is setting some value to true, then in a think hook detect if said value is true then change the walk speed from there. But I feel like that'd be very inefficient and generally shit. (Yes, the mod needs to be completely external from the gamemode itself)
[CODE] function GM:PlayerSpawn( ply ) ply:SetRunSpeed( x ) end [/CODE]
That's what I did, but it doesn't work
[QUOTE=Johnoo;49131951]That's what I did, but it doesn't work[/QUOTE] Are you running it in a gamemode or a script? EDIT [CODE] function PlayerSpawn( ply ) ply:SetRunSpeed( x ) end [/CODE] Try that ^
Just a script in the addon's folder (the gamemode is DarkRP) [QUOTE=CGHippo;49131953] [CODE] function PlayerSpawn( ply ) ply:SetRunSpeed( x ) end [/CODE] Try that ^[/QUOTE] And I tested that and it didn't work :(
Are you actually using a number instead of x Do it as a hook instead Add print statements before and after to see where the error lies
[code] hook.Add( "PlayerSpawn", "On Player Spawn", function( ply ) print("Test") ply:SetRunSpeed(1000) print("Test2") end) [/code] ^If I do that, I get Test and Test2 in console, but my run speed stays the same Any ideas on how to fix?
It might be gmod/lua not liking huge numbers - Try something smaller like 100 or 300
Doesn't work either :S
[lua] hook.Add( "PlayerSpawn", "On Player Spawn", function( ply ) timer.Simple(0.1, function() if !IsValid(ply) then return end ply:SetWalkSpeed(600) ply:SetRunSpeed(1000) end) end) [/lua]
[QUOTE=deinemudda32;49132079][lua] hook.Add( "PlayerSpawn", "On Player Spawn", function( ply ) timer.Simple(0.1, function() if !IsValid(ply) then return end ply:SetWalkSpeed(600) ply:SetRunSpeed(1000) end) end) [/lua][/QUOTE] This, if it doesnt work either try changing it from PlayerSpawn to PlayerLoadout or increasing the amount of time in the timer to 1-3 seconds.
That seems to work, thanks you legends ;)
Sorry, you need to Log In to post a reply to this thread.