Ok, so im running a server, and want to set players speed. I have written a script, and it autoexecs when the server starts.
[CODE]function playerSetSpeed(ply)
GAMEMODE:SetPlayerSpeed(ply, 160, 240)
player:SetWalkSpeed( 160 )
player:SetRunSpeed( 240 )
end
hook.Add( "PlayerSpawn", "playerSetSpeedtest", playerSetSpeed )[/CODE]
I even -basically- ran the speed command twice to make doubly sure it did work, but still does not. To troubleshoot, i did run the script manually, kill myself, and it says it launches with no error, but still does not work. I suspect it is a mod I have installed, maybe Customisable weaponry mod? but I haven't found anything signifying player speed anywhere in the scripts.
Please help with this, i -really- want to get my server into beta.
EDIT: NOPE, not Customisable weaponry mod. just backed up, then deleted the mod. Reset the server, and still the same sh*t :/
If you're creating a gamemode change the [url=http://wiki.garrysmod.com/page/Player_Classes]Player_Classes[/url].
As for why your code isn't working you should learn how lua [url=http://www.lua.org/pil/5.html]functions[/url] work and their arguments. Look at the difference between your ply argument and the player argument you're trying to use. Player is a class already defined by garrysmod itself, hence why its not error-ing.
Yeah, I was just looking at that. Thank you for the quick response! First in a while, for sure.
This is rediculous. I've went into the config, set the run and walk speed. I've edited the player_class.lua to set the runspeed, even went into the shared.lua gamemode file and put this in:
[CODE]
function GM:PlayerSpawn( pl )
player_manager.SetPlayerClass( pl, "player_darkrp" )
pl.WalkSpeed = 1
pl.RunSpeed = 50
BaseClass.PlayerSpawn( self, pl )
end
[/CODE]
Obviously those numbers are excessively low.
I seriously need help on why this isn't working. I've spent 3 hours wondering why this i'snt working. I've even edited the BASE and Sandbox gamemode player_class.lua files, and still nothing.
I saw in some other thread you made that you were trying to do this in DarkRP, if that's the case here, look at DarkRP/gamemode/config.lua on lines 207, 209, and 231. Pretty sure this could be interfering with whatever you're trying to set when the player spawns, but I could be completely wrong.
207 | GM.Config.runspeed = 240
209 | GM.Config.runspeedcp = 255
231 | GM.Config.walkspeed = 160
Already set it. didn't budge.
[editline]11th August 2013[/editline]
Im looking around my addons, to see if there is an addon doing this.
[editline]11th August 2013[/editline]
Just tried deleting all of the files I set the runspeed in, and edited the CFG again, nothing -.-
[editline]11th August 2013[/editline]
Well, I've found an addon that allows me to set the runspeed and walkspeed among other things in console (which i much prefer anyway.). I haven't tested it yet, we will see if it works.
Have you tried sticking a timer in it? That's solved many of my problems, and I had a similar problem with Mr-Gash's Deathrun.
I think calling it a few seconds later allows it to override all of the sets the game mode files do after PlayerSpawn and PlayerLoadout and such.
Who knows, maybe it'll work, maybe it won't.
[CODE]function playerSetSpeed(ply)
timer.Simple(2, function()
GAMEMODE:SetPlayerSpeed(ply, 160, 240)
player:SetWalkSpeed( 160 )
player:SetRunSpeed( 240 )
end)
end
hook.Add( "PlayerSpawn", "playerSetSpeedtest", playerSetSpeed ) [/CODE]
Sorry, you need to Log In to post a reply to this thread.