Page 1 of 1

Players movementspeed

Posted: Mon Jan 15, 2018 8:23 am
by Pudge90
So I am trying to change a players movementspeed for a certain amount of time and don't even know where to begin with :confused: . Any help is appreciated

Re: Players movementspeed

Posted: Mon Jan 15, 2018 4:54 pm
by L'In20Cible

Syntax: Select all

from events import Event
from players.entity import Player

@Event('player_spawn')
def _player_spawn(game_event):
"""Fired when a player spawns."""
# Get a Player instance of the player spawning...
player = Player.from_userid(game_event.get_int('userid'))

# Exit the function if the player is not in a valid team...
if player.team_index <= 1:
return

# Double the player's speed...
player.speed *= 2

Re: Players movementspeed

Posted: Mon Jan 15, 2018 5:08 pm
by Ayuto
Looks like you missed the part "for a certain amount of time". Here's what L'In20Cible's code would look like with that addition:

Syntax: Select all

from events import Event
from players.entity import Player

@Event('player_spawn')
def _player_spawn(game_event):
"""Fired when a player spawns."""
# Get a Player instance of the player spawning...
player = Player.from_userid(game_event.get_int('userid'))

# Exit the function if the player is not in a valid team...
if player.team_index <= 1:
return

# Double the player's speed...
player.speed *= 2

# Call reset_speed(player) after 10 seconds
player.delay(10, reset_speed, [player])

def reset_speed(player):
# Set the player's speed back to the normal value
player.speed = 1

For reference:
http://wiki.sourcepython.com/developing ... tity.speed
http://wiki.sourcepython.com/developing ... tity.delay
http://wiki.sourcepython.com/developing ... ers.entity

Re: Players movementspeed

Posted: Mon Jan 15, 2018 5:28 pm
by L'In20Cible
Yep, overlooked that part. :grin:

Re: Players movementspeed

Posted: Mon Jan 15, 2018 8:22 pm
by Pudge90
The support in this forum is absolutly incredible, thank you guys for the detailed response.

Re: Players movementspeed

Posted: Tue Jan 16, 2018 1:16 pm
by battleweaver
Would like to add some info.
First of all: I talk about CS:GO.
There are 2 variables that control speed.
If I am correct, the way offered above works with 'sv_accelerate', which is multiplier to your base speed
Console variable 'sv_maxspeed' - base speed, which is determined, for example, by weapon you carry. More detailed info over here https://steamcommunity.com/sharedfiles/filedetails/?id=501419345
From what I read about it, 'sv_maxspeed' can't be more than 500 if set manually.

Re: Players movementspeed

Posted: Thu Jan 18, 2018 12:33 am
by Hymns For Disco
battleweaver wrote:Would like to add some info.
First of all: I talk about CS:GO.
There are 2 variables that control speed.
If I am correct, the way offered above works with 'sv_accelerate', which is multiplier to your base speed
Console variable 'sv_maxspeed' - base speed, which is determined, for example, by weapon you carry. More detailed info over here https://steamcommunity.com/sharedfiles/filedetails/?id=501419345
From what I read about it, 'sv_maxspeed' can't be more than 500 if set manually.


I believe you are incorrect about both of these cvars. First, sv_accelerate will affect how fast you will accelerate while walking. This wont affect max speed, only make you achieve that max speed faster or slower after you start moving. Second, sv_maxspeed is not your base speed, and is not determined by your weapon. sv_maxspeed will remain the same unless changed by the server. (default value is 320). It also does not affect how fast you can walk directly. Setting the sv_maxspeed super high won't make you walk super fast. Setting it below 250 however will limit you to that speed and therefore make you walk slower.

Re: Players movementspeed

Posted: Tue Jan 23, 2018 6:05 pm
by battleweaver
Hymns For Disco wrote:I believe you are incorrect about both of these cvars. First, sv_accelerate will affect how fast you will accelerate while walking. This wont affect max speed, only make you achieve that max speed faster or slower after you start moving. Second, sv_maxspeed is not your base speed, and is not determined by your weapon. sv_maxspeed will remain the same unless changed by the server. (default value is 320). It also does not affect how fast you can walk directly. Setting the sv_maxspeed super high won't make you walk super fast. Setting it below 250 however will limit you to that speed and therefore make you walk slower.

What can I say. This august i had a nasty bug: after zoomed AWP shot during swap to pistol and back swap to awp, player moved with speed of zoomed awp. My workaround was through sv_accelerate. Bug was caused by creating weapon as entity and not through giving this weapon to player. During fixes at september 2017 my workaround was not needed anymore cause Valve fixed the issue of weapon entities.
As for the sv_maxspeed, i advise you to read the article a linked in previous comment.