Raised This Month: $51 Target: $400
 12% 

[SOLVED] Player maxspeed on round start


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
OFFBEAT
Junior Member
Join Date: Feb 2011
Location: Sweden
Old 09-08-2011 , 23:08   [SOLVED] Player maxspeed on round start
Reply With Quote #1

Don't really get why this isn't working, it's suppose too, I've read around alot about the events of round start, round end, player spawn etc.

I'm trying to set the player maxspeed on round start, though it doesn't set it... Even if the id is correct and everything is a match.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta_util>

#define PLUGIN "Test Plugin"
#define VERSION "0.0.1"
#define AUTHOR "OFFBEAT"

new g_iDecals;
new 
g_cvarCount;
new 
g_iDecFreq;

new 
bool:g_bMaySpray true;

public 
plugin_init( )
{
    
register_pluginPLUGINVERSIONAUTHOR );
    
    
register_logevent"fnRoundStart"2"1=Round_Start" )  
    
    
g_cvarCount register_cvar"mod_countspray""1" );
    
    
g_iDecFreq get_cvar_num"decalfrequency" );
}

public 
fnRoundStart( )
{
    new 
players[32], Max;
    
get_playersplayersMax );
    
    for( new 
0Maxi++ )
    {
        if( 
is_user_aliveplayers[i] ) )
            
fm_set_user_maxspeedplayers[i], fm_get_user_maxspeedplayers[i] ) + 50.0 );
    }
    
    return 
PLUGIN_HANDLED;
}

public 
client_impulseidimpulse )
{
    if( 
get_pcvar_numg_cvarCount ) && impulse == 201 && g_bMaySpray )
    {
        
g_iDecals++;
        
        switch( 
g_iDecals )
        {
            case 
5:
            {
                
client_printidprint_chat"[DECAL COUNTER] You have sprayed %d decals, spray 5 more to increase in speed!"g_iDecals );
            }
                
            case 
10:
            {
                
client_printidprint_chat"[DECAL COUNTER] You have sprayed %d decals, increasing 50 units in speed"g_iDecals );
                
                
fm_set_user_maxspeedidfm_get_user_maxspeedid ) + 50.0 );
            }
            
            default:
            {
                
client_printidprint_chat"[DECAL COUNTER] You have now sprayed %d decal(s)"g_iDecals );
            }
        }
        
        
g_bMaySpray false;
        
set_taskfloatg_iDecFreq ), "fnMaySpray" );
        
        return 
PLUGIN_CONTINUE;
    } else if( 
get_pcvar_numg_cvarCount ) && impulse == 201 && !g_bMaySpray )
    {
        
// return handled
    
}
    
    return 
PLUGIN_HANDLED;
}

public 
fnMaySpray( )
{
    
g_bMaySpray true;

Don't worry about the other parts of the code, it's just the round start code i want to work, the other was just a test.

EDIT: Fixed it, thanks guys! Fixed code in my latest post.

Last edited by OFFBEAT; 09-09-2011 at 10:30. Reason: Solved it
OFFBEAT is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-09-2011 , 00:04   Re: [HELP] Player maxspeed on round start
Reply With Quote #2

You need to search around for setting max speed now. Also, don't use fm_ functions if there is an identical function already created to do the same thing.
__________________
fysiks is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-09-2011 , 01:05   Re: [HELP] Player maxspeed on round start
Reply With Quote #3

It deosn't work because right after this event, players maxspeed are reset because it's the end of freezetime.
As fysiks said, use set_user_maxspeed and get_user_maxspeed natives instead of fm_*
Instead of client_impulse, you can use register_impulse( 201 , "client_impulse_201" )
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
OFFBEAT
Junior Member
Join Date: Feb 2011
Location: Sweden
Old 09-09-2011 , 09:29   Re: [HELP] Player maxspeed on round start
Reply With Quote #4

Oh okey, so fun's set_user_maxspeed and register impulse instead of client_impulse, got it, thank you I will try that out.

Solved:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fun>

#define PLUGIN "Test Plugin"
#define VERSION "0.0.1"
#define AUTHOR "OFFBEAT"

new g_iDecals;
new 
g_cvarCount;
new 
g_iDecFreq;

new 
bool:g_bMaySpray true;

public 
plugin_init( )
{
    
register_pluginPLUGINVERSIONAUTHOR );
    
    
register_event"HLTV""fnFreeze""a""1=0""2=0" );
    
register_impulse201"fnClientImpulse" );
    
    
g_cvarCount register_cvar"mod_countspray""1" );
    
    
g_iDecFreq get_cvar_num"decalfrequency" );
}

public 
fnFreeze( )
{
    new 
Float:flFreeze get_cvar_float"mp_freezetime" );
    
    
set_taskflFreeze"fnSetSpeed" );
    
    return 
PLUGIN_HANDLED;
}

public 
fnSetSpeed( )
{
    new 
iPlayers[32], iMax;
    
get_playersiPlayersiMax );
    
    for( new 
0iMaxi++ )
    {
        if( 
is_user_aliveiPlayers[i] ) )
            
set_user_maxspeediPlayers[i], get_user_maxspeediPlayers[i] ) + 50.0 );
    }
    
    return 
PLUGIN_HANDLED;
}

public 
fnClientImpulseidimpulse )
{
    if( 
get_pcvar_numg_cvarCount ) && g_bMaySpray )
    {
        
g_iDecals++;
        
        switch( 
g_iDecals )
        {
            case 
5:
            {
                
client_printidprint_chat"[DECAL COUNTER] You have sprayed %d decals, spray 5 more to increase in speed!"g_iDecals );
            }
                
            case 
10:
            {
                
client_printidprint_chat"[DECAL COUNTER] You have sprayed %d decals, increasing 50 units in speed"g_iDecals );
                
                
set_user_maxspeedidget_user_maxspeedid ) + 50.0 );
            }
            
            default:
            {
                
client_printidprint_chat"[DECAL COUNTER] You have now sprayed %d decal(s)"g_iDecals );
            }
        }
        
        
g_bMaySpray false;
        
set_taskfloatg_iDecFreq ), "fnMaySpray" );
        
        return 
PLUGIN_CONTINUE;
    } else if( 
get_pcvar_numg_cvarCount ) && !g_bMaySpray )
    {
        
// return handled
    
}
    
    return 
PLUGIN_HANDLED;
}

public 
fnMaySpray( )
{
    
g_bMaySpray true;


Last edited by OFFBEAT; 09-09-2011 at 10:30. Reason: Fixed it
OFFBEAT 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 14:08.


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