AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   set_user_maxspeed() not work (https://forums.alliedmods.net/showthread.php?t=276965)

uqw04826 12-31-2015 09:14

set_user_maxspeed() not work
 
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?

asur 12-31-2015 09:57

Re: set_user_maxspeed() not work
 
Quote:

Originally Posted by uqw04826 (Post 2378437)
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

uqw04826 12-31-2015 10:38

Re: set_user_maxspeed() not work
 
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."

Bugsy 12-31-2015 11:48

Re: set_user_maxspeed() not work
 
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;



MspoR 12-31-2015 20:16

Re: set_user_maxspeed() not work
 
I guess you need to make a code for all time with switching guns speed. For reset speed max.

uqw04826 01-01-2016 09:32

Re: set_user_maxspeed() not work
 
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.

PartialCloning 01-01-2016 09:45

Re: set_user_maxspeed() not work
 
You need the new ham module that comes with 1.8.3. Or just replace Ham_CS_Player_ResetMaxSpeed with Ham_Item_PreFrame.

uqw04826 01-01-2016 09:58

Re: set_user_maxspeed() not work
 
That Ham_Item_PreFrame thing worked! And now, the speed boost for terrorists works like I wanted, thanks a lot guys for help!


All times are GMT -4. The time now is 09:28.

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