Players movementspeed

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
Pudge90
Junior Member
Posts: 20
Joined: Sun Jan 14, 2018 6:18 pm
Location: Germany

Players movementspeed

Postby Pudge90 » Mon Jan 15, 2018 8:23 am

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
User avatar
L'In20Cible
Project Leader
Posts: 1044
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Players movementspeed

Postby L'In20Cible » Mon Jan 15, 2018 4:54 pm

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
User avatar
Ayuto
Project Leader
Posts: 1819
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: Players movementspeed

Postby Ayuto » Mon Jan 15, 2018 5:08 pm

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
User avatar
L'In20Cible
Project Leader
Posts: 1044
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Players movementspeed

Postby L'In20Cible » Mon Jan 15, 2018 5:28 pm

Yep, overlooked that part. :grin:
User avatar
Pudge90
Junior Member
Posts: 20
Joined: Sun Jan 14, 2018 6:18 pm
Location: Germany

Re: Players movementspeed

Postby Pudge90 » Mon Jan 15, 2018 8:22 pm

The support in this forum is absolutly incredible, thank you guys for the detailed response.
battleweaver
Member
Posts: 40
Joined: Mon Oct 02, 2017 7:57 am
Location: Moscow
Contact:

Re: Players movementspeed

Postby battleweaver » Tue Jan 16, 2018 1:16 pm

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.
User avatar
Hymns For Disco
Junior Member
Posts: 15
Joined: Wed Nov 22, 2017 7:18 am

Re: Players movementspeed

Postby Hymns For Disco » Thu Jan 18, 2018 12:33 am

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.
battleweaver
Member
Posts: 40
Joined: Mon Oct 02, 2017 7:57 am
Location: Moscow
Contact:

Re: Players movementspeed

Postby battleweaver » Tue Jan 23, 2018 6:05 pm

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.

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 2 guests