Raised This Month: $ Target: $400
 0% 

[Tutorial] how to set player movement speed?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
javalia
Senior Member
Join Date: May 2009
Location: korea, republic of
Old 08-02-2010 , 22:59   [Tutorial] how to set player movement speed?
Reply With Quote #1

----battle report (report type c-84)----

on ep1 engine(at this time, only hl2mp)
u can just set m_fl_Maxspeed as just u want and it is all.
but on ep2 engine(css tf2...), that is not all

but it is not impossible to edit player movement speed.

so i am posting that simple way to edit movement speed of client

to edit player speed on ep2 engine, u need to use sdkhooks.

see this

Code:
public OnClientPutInServer(client){
    
    SDKHook(client, SDKHook_PreThinkPost, PreThinkPostHook);
    
}

public PreThinkPostHook(client){
    
    if(IsClientConnectedIngameAlive(client)){
        
        if(suitmode[client] == suitmode_speed){
        
            SetEntPropFloat(client, Prop_Data, "m_flMaxspeed", SUIT_SPEED_MAXSPEED);
            
        }
        
    }
    
}
suitmode[client] was global variable on that code.
so u can set client`s max speed as u want.

but, there is some limit on that.

first, to make players able to move faster than 320,
u need to set server convar "sv_maxspeed" to higher value of max speed that u want to set.
but u must not set it too high than u need.
if that value is too high, spectators will move too faster.

twice, if u want to players able to move faster than 400,
u must set ur server as "sv_cheats 1" server!!!!

cuz there is a client side cvar "cl_forwardspeed"
and it determinds how clients can be faster.
they cannot move faster than that value.
that convar dont exist on serverside.
and that convar has cheat flag.
so to set that convar, u must set sv_cheats 1

but at most of time, u will have no need to set client`s speed to higher value than 400. but if u need to do so, well...i was not able to find way to set that client side value without "sv_cheats 1"

-from a terran battlefield commander

----end of transmitsion----

Last edited by javalia; 08-02-2010 at 23:04.
javalia is offline
DarkEnergy
SourceMod Donor
Join Date: Apr 2008
Location: Georgia Tech, MSECE
Old 08-03-2010 , 00:26   Re: [Tutorial] how to set player movement speed?
Reply With Quote #2

m_flMaxspeed an absolute value on tf2 (400.0)

FindSendPropOffs("CBasePlayer","m_flLaggedMov ementValue") is a ratio on CSS

i dont know about you but i only need to set it once in both mods (both offsets) (see war3source)

Last edited by DarkEnergy; 08-03-2010 at 10:28.
DarkEnergy is offline
javalia
Senior Member
Join Date: May 2009
Location: korea, republic of
Old 08-03-2010 , 00:47   Re: [Tutorial] how to set player movement speed?
Reply With Quote #3

Quote:
Originally Posted by DarkEnergy View Post
m_flMaxspeed is a ratio on CSS (1.0) and an absolute value on tf2 (400.0)

i dont know about you but i only need to set it once in both mods (see war3source)
i am not sure it is need to set once but that sample code is from my plugin and it works fine. so m_flMaxspeed is not ratio in css. it is absolute like tf2.
javalia is offline
DarkEnergy
SourceMod Donor
Join Date: Apr 2008
Location: Georgia Tech, MSECE
Old 08-03-2010 , 10:29   Re: [Tutorial] how to set player movement speed?
Reply With Quote #4

my bad, ratio is m_flLaggedMovementValue
DarkEnergy is offline
InB
AlliedModders Donor
Join Date: Aug 2012
Location: Los Angeles
Old 10-29-2012 , 18:46   Re: [Tutorial] how to set player movement speed?
Reply With Quote #5

Can u make it 1.5x? how?


is it?
if(suitmode[client] == 1.5)
__________________

Last edited by InB; 10-29-2012 at 18:55.
InB is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 10-30-2012 , 09:25   Re: [Tutorial] how to set player movement speed?
Reply With Quote #6

Quote:
Originally Posted by InB View Post
Can u make it 1.5x? how?


is it?
if(suitmode[client] == 1.5)
what game, if it is css, then you can do this with laggedmovement now.
Mitchell is offline
donrevan
AlliedModders Donor
Join Date: Jul 2010
Old 10-31-2012 , 07:23   Re: [Tutorial] how to set player movement speed?
Reply With Quote #7

Yes , but flMaxSpeed and lagged movement are not the same.
see:
Quote:
Originally Posted by DarkEnergy View Post
my bad, ratio is m_flLaggedMovementValue

flmaxspeed is NOT ratio, therefore setting 1.5 will slow a player down.

Last edited by donrevan; 10-31-2012 at 07:26.
donrevan is offline
yokomo
Surprise Ascot!
Join Date: May 2010
Location: Malaysia
Old 11-02-2012 , 00:40   Re: [Tutorial] how to set player movement speed?
Reply With Quote #8

Set player speed in Prethink? server will lag right? by the way i modified your code a bit, since prethink is called too much.

PHP Code:
#include <sourcemod>
#include <sdkhooks>

new bool:IsConnected[MAXPLAYERS]
new 
bool:IsAlive[MAXPLAYERS]
static 
String:FlMaxSpeed[] = "m_flMaxspeed"
static Float:CustomSpeed 600.0

#define IsClientValidConnected(%1) (1<=%1<=MaxClients && IsConnected[%1])
#define IsClientValidAlive(%1) (1<=%1<=MaxClients && IsAlive[%1])

public OnPluginStart()
{
    
HookEvent("player_spawn"OnPlayerSpawn)
    
HookEvent("player_death"OnPlayerDeath)
}

public 
OnClientPutInServer(x)
{
    
IsConnected[x] = true
    SDKHook
(xSDKHook_PreThinkPostOnPreThinkPost)
}

public 
OnClientDisconnect(x)
{
    
IsConnected[x] = false
    IsAlive
[x] = false
}

public 
Action:OnPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
GetClientOfUserId(GetEventInt(event"userid"))
    if(!
IsClientValidConnected(x) || !IsPlayerAlive(x)) return;
    
    
IsAlive[x] = true
}

public 
Action:OnPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
GetClientOfUserId(GetEventInt(event"userid"))
    if(!
IsClientValidConnected(x)) return;
    
    
IsAlive[x] = false
}

public 
OnPreThinkPost(x)
{
    if(
IsClientValidAlive(x))
    {
        
SetEntPropFloat(xProp_DataFlMaxSpeedCustomSpeed)
    }

__________________
Team-MMG CS1.6 Servers:
✅ MultiMod -- 103.179.44.152:27016
✅ Zombie Plague -- 103.179.44.152:27015
✅ Zombie Escape -- 103.179.44.152:27017
✅ Klassik Kombat -- 103.179.44.152:27018
✅ Boss-Battle -- 103.179.44.152:27019
yokomo is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:23.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode