Raised This Month: $ Target: $400
 0% 

set_user_maxspeed() not work


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
uqw04826
New Member
Join Date: Dec 2015
Old 12-31-2015 , 09:14   set_user_maxspeed() not work
Reply With Quote #1

I'm editing my deathrun server and I want to set speed of terrorists to the 550. But with no help. Here is parth of the code from deathrun.sma:

PHP Code:
// NEW ROUND
///////////////////////////////////////////
public EventRoundStart( ) {
    if( !
g_bEnabled )
        return 
PLUGIN_CONTINUE;
    
    
g_bRandromized    false;
    
g_bStarting    false;
    
    new 
iiPlayers32 ], iNumiRealPlayersCsTeams:iTeam;
    
get_playersiPlayersiNum"c" );
    
    if( 
iNum <= )
        return 
PLUGIN_CONTINUE;
    
    for( 
0iNumi++ ) {
        new 
pid iPlayers];
        
iTeam cs_get_user_team(pid);
        
        if( 
iTeam == CS_TEAM_T || iTeam == CS_TEAM_CT )
            
iRealPlayers++;

        if( 
iTeam == CS_TEAM_T ) {
            
// Terrorists should run faster
            
set_user_maxspeed(pid550.0);
        } else {
            
// Other players have default speed
            
set_user_maxspeed(pid0.0);
        }
    }
    ... 
other stuffeverything works well...

My whole server works good, except that speed boost. I try to connect as a T, but my speed is still default as CT.

Note:
server cvar sv_maxspeed is 900
client cvars cl_forwardspeed, cl_backspeed, cl_sidespeed are all set to 4000

Compilation proceed without any error or even warning. I also have a SuperHero server, where I use set_user_maxspeed and it works well. Where is the problem?

Last edited by uqw04826; 12-31-2015 at 09:14.
uqw04826 is offline
asur
Member
Join Date: Dec 2014
Old 12-31-2015 , 09:57   Re: set_user_maxspeed() not work
Reply With Quote #2

Quote:
Originally Posted by uqw04826 View Post
I'm editing my deathrun server and I want to set speed of terrorists to the 550. But with no help. Here is parth of the code from deathrun.sma:

PHP Code:
// NEW ROUND
///////////////////////////////////////////
public EventRoundStart( ) {
    if( !
g_bEnabled )
        return 
PLUGIN_CONTINUE;
    
    
g_bRandromized    false;
    
g_bStarting    false;
    
    new 
iiPlayers32 ], iNumiRealPlayersCsTeams:iTeam;
    
get_playersiPlayersiNum"c" );
    
    if( 
iNum <= )
        return 
PLUGIN_CONTINUE;
    
    for( 
0iNumi++ ) {
        new 
pid iPlayers];
        
iTeam cs_get_user_team(pid);
        
        if( 
iTeam == CS_TEAM_T || iTeam == CS_TEAM_CT )
            
iRealPlayers++;

        if( 
iTeam == CS_TEAM_T ) {
            
// Terrorists should run faster
            
set_user_maxspeed(pid550.0);
        } else {
            
// Other players have default speed
            
set_user_maxspeed(pid0.0);
        }
    }
    ... 
other stuffeverything works well...

My whole server works good, except that speed boost. I try to connect as a T, but my speed is still default as CT.

Note:
server cvar sv_maxspeed is 900
client cvars cl_forwardspeed, cl_backspeed, cl_sidespeed are all set to 4000

Compilation proceed without any error or even warning. I also have a SuperHero server, where I use set_user_maxspeed and it works well. Where is the problem?
see if there are other plugins which are dealing with client's speed , they maybe interfering.
And the default speed should be 250.0 not 0.0
asur is offline
uqw04826
New Member
Join Date: Dec 2015
Old 12-31-2015 , 10:38   Re: set_user_maxspeed() not work
Reply With Quote #3

I set 0.0 cause in docs it says "If you set a user's maxspeed to 0.0 they will be able to run normal speed."
uqw04826 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-31-2015 , 11:48   Re: set_user_maxspeed() not work
Reply With Quote #4

Speed gets reset when a user changes weapons so you can't just set it and forget it.

Try this:

If you want a players speed to be normal again at new round then you need to set g_bPlayersSpeedSet[ pid ] = false at spawn or new round. Let me know and I can set it up for you.
PHP Code:
#define MAX_PLAYERS 32
new bool:g_bPlayersSpeedSetMAX_PLAYERS ];

RegisterHamHam_CS_Player_ResetMaxSpeed "player" "ResetMaxSpeed" );

public 
ResetMaxSpeedid )
{
    return 
g_bPlayersSpeedSetid ] ? HAM_SUPERCEDE HAM_IGNORED;
}

public 
EventRoundStart() 
{
    if( !
g_bEnabled )
        return 
PLUGIN_CONTINUE;
    
    
g_bRandromized false;
    
g_bStarting false;
    
    new 
iiPlayers32 ], iNumiRealPlayersCsTeams:iTeam;
    
get_playersiPlayersiNum"c" );
    
    if( 
iNum <= )
        return 
PLUGIN_CONTINUE;
    
    for( 
0iNumi++ ) 
    {
        new 
pid iPlayers];
        
iTeam cs_get_user_team(pid);
        
        
// Terrorists should run faster
        // Other players have default speed
        
if( CS_TEAM_T <= iTeam <= CS_TEAM_CT )
        {
            
iRealPlayers++;
            
            
g_bPlayersSpeedSetpid ] = bool:( iTeam == CS_TEAM_T );
            
set_user_maxspeedpid , ( iTeam == CS_TEAM_T ) ? 550.0 0.0 );
        }
    }
    
    return 
PLUGIN_CONTINUE;

__________________

Last edited by Bugsy; 12-31-2015 at 11:52.
Bugsy is offline
MspoR
Member
Join Date: Sep 2015
Old 12-31-2015 , 20:16   Re: set_user_maxspeed() not work
Reply With Quote #5

I guess you need to make a code for all time with switching guns speed. For reset speed max.

Last edited by MspoR; 12-31-2015 at 20:16.
MspoR is offline
uqw04826
New Member
Join Date: Dec 2015
Old 01-01-2016 , 09:32   Re: set_user_maxspeed() not work
Reply With Quote #6

Oh yes, right. I'm trying your code Bugsy, but I have problem with RegisterHam. I should put it into the plugin_init() function, I guess, but it tells me, that variable Ham_CS_Player_ResetMaxSpeed is undefined.
uqw04826 is offline
PartialCloning
Senior Member
Join Date: Dec 2015
Old 01-01-2016 , 09:45   Re: set_user_maxspeed() not work
Reply With Quote #7

You need the new ham module that comes with 1.8.3. Or just replace Ham_CS_Player_ResetMaxSpeed with Ham_Item_PreFrame.
PartialCloning is offline
uqw04826
New Member
Join Date: Dec 2015
Old 01-01-2016 , 09:58   Re: set_user_maxspeed() not work
Reply With Quote #8

That Ham_Item_PreFrame thing worked! And now, the speed boost for terrorists works like I wanted, thanks a lot guys for help!

Last edited by uqw04826; 01-01-2016 at 09:59.
uqw04826 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 09:28.


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