Raised This Month: $ Target: $400
 0% 

Team_swtich


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-13-2011 , 12:43   Re: Team_swtich
Reply With Quote #8

Your original code is fine.
You just need to remove task if the player disconnects, because a player can disconnect before the task is executed, thus giving you the invalid player error.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>

#define PLUGIN "Auto Team Switcher"
#define VERSION "1.0"
#define AUTHOR "nikhilgupta345"

#pragma semicolon 1

new roundnumber 0;
new 
Atsround;

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
register_clcmd"say /roundnumber""sayRound" );
    
register_concmd"amx_roundrestart""restartnumber"ADMIN_KICK );
    
    
register_logevent"roundend"2"1=Round_End" );
    
register_event"TextMsg","restart","a","2&#Game_C""2&#Game_W" ); // Event for "Game Commencing" TextMsg and "Game Will Restart in X Seconds" TextMsg
    
    
Atsround register_cvar"amx_atsrounds""15" );
    
}

public 
client_disconnectid )
{
    
remove_taskid );
}

public 
sayRoundid )
{
    
client_printidprint_chat"The current round is %i."roundnumber );
    return 
PLUGIN_HANDLED;
}

public 
roundend()
{
    
roundnumber++;
    
    if( 
roundnumber >= get_pcvar_numAtsround ) )
    {
        new 
players[32], num;
        
get_playersplayersnum );
        
        for( new 
inumi++ )
            
set_taskfloat), "changeTeam"players[i] );
            
    }
}


public 
restartnumberidlevelcid )
{
    if( !
cmd_accessidlevelcid) )
        return 
PLUGIN_HANDLED;
    
    
roundnumber 0;
    return 
PLUGIN_HANDLED;
}

public 
restartid )
{
    
roundnumber 0;
    return 
PLUGIN_HANDLED;
}

public 
changeTeamid )
{
    switch( 
cs_get_user_teamid ) )
    {
        case 
CS_TEAM_CTcs_set_user_teamidCS_TEAM_T );
        
        case 
CS_TEAM_Tcs_set_user_teamidCS_TEAM_CT );
    }

    
roundnumber 0;

__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 06-13-2011 at 13:17.
Exolent[jNr] is offline
 



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 04:25.


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