Raised This Month: $ Target: $400
 0% 

CT team can have max 4 ct's players.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 01-09-2009 , 11:31   CT team can have max 4 ct's players.
Reply With Quote #1

So this code worst coded and cause a lot of bugs ,maybe someone can give me better code?
In ct team can be max 4 players,this code buggy I don't how ,but somehow in team can be more than 4 players and when round starts(and 4 players in ct team) then one of them are switched to terrorist team and who was switched he is in ct base!.
So anyone can give a good working code?

Quote:
public message_teaminfo(msg_id, msg_dest){
if (msg_dest != MSG_ALL && msg_dest != MSG_BROADCAST) return;
new id = get_msg_arg_int(1)
static team[2]
get_msg_arg_string(2, team, sizeof team - 1)
if(team[0] == 'U' || team[0] == 'S') return;
new cts = ckrun_get_ct_num()
if(cts >= 4){
cs_set_user_team(id, CS_TEAM_T, CS_DONTCHANGE)
set_msg_arg_string(2, "TERRORIST")
}
Quote:
stock ckrun_get_ct_num(){
new num = 0 , i
for (i = 1; i <= g_maxplayers; i++){
if (is_user_connected(i) && get_user_team(i) == 2)
num ++
}
return num
}
And register this message in plugin_init:
Quote:
register_message(get_user_msgid("TeamInfo"), "message_teaminfo")
xbatista is offline
Send a message via Skype™ to xbatista
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 01-09-2009 , 12:17   Re: CT team can have max 4 ct's players.
Reply With Quote #2

Code:
#include <amxmodx> #include <amxmisc> #include <fakemeta> #define MAX_CTS 4 enum FmTeams {     FM_TEAM_UNASSIGNED,     FM_TEAM_T,     FM_TEAM_CT,     FM_TEAM_SPECTATOR }; new const g_TeamInfo[FmTeams][] = {     "UNASSIGNED",     "TERRORIST",     "CT",     "SPECTATOR" }; #define fm_get_user_team(%1) FmTeams:get_pdata_int(%1, 114) new g_max_clients; public plugin_init() {     register_message(get_user_msgid("TeamInfo"), "MessageTeamInfo");         g_max_clients =  get_maxplayers(); } public MessageTeamInfo(msgid, dest, receiver) {     if( dest != MSG_ALL ) return;         new client = get_msg_arg_int(1);     if( !is_user_connected(client) ) return;         new teamname[3];     get_msg_arg_string(2, teamname, sizeof(teamname) - 1);         new FmTeams:team;     for( new FmTeams:i = FM_TEAM_UNASSIGNED; i < FmTeams; i++ )     {         if( g_TeamInfo[i][0] == teamname[0] )         {             team = i;             break;         }     }         if( team != FM_TEAM_CT || team == fm_get_user_team(client) ) return;         new ctnum;     for( new i = 1; i <= g_max_clients; i++ )     {         if( i != client         && is_user_connected(i)         && fm_get_user_team(i) == FM_TEAM_CT         && ++ctnum == MAX_CTS )         {             set_msg_arg_string(2, g_TeamInfo[FM_TEAM_T]);             return;         }     } }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 01-09-2009 at 14:28.
Exolent[jNr] is offline
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 01-09-2009 , 12:21   Re: CT team can have max 4 ct's players.
Reply With Quote #3

WoW, thanks Going to test.

EDIT: Compiles bad,error 017 undefined symbol DLFunc_ClientInfoChanged,expected token: ";", but found ")" , all errors on that line.

Last edited by xbatista; 01-09-2009 at 12:35.
xbatista is offline
Send a message via Skype™ to xbatista
X0Left4dead0X
BANNED
Join Date: Jan 2009
Old 01-09-2009 , 12:49   Re: CT team can have max 4 ct's players.
Reply With Quote #4

Hehe it looks like this is for Left 4 Dead in counter-strike
X0Left4dead0X is offline
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 01-09-2009 , 12:56   Re: CT team can have max 4 ct's players.
Reply With Quote #5

YES,becouse my code is bad,like always ;)

EDIT: WoW I can't believe! Exolent you done mistake DD
dllfunc(DLFunc_ClientUserInfoChanged
must be ->
dllfunc(DLLFunc_ClientUserInfoChanged

xD

Last edited by xbatista; 01-09-2009 at 13:06.
xbatista is offline
Send a message via Skype™ to xbatista
X0Left4dead0X
BANNED
Join Date: Jan 2009
Old 01-09-2009 , 13:12   Re: CT team can have max 4 ct's players.
Reply With Quote #6

Oh yeah my bad

Last edited by X0Left4dead0X; 01-09-2009 at 13:14.
X0Left4dead0X is offline
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 01-09-2009 , 13:57   Re: CT team can have max 4 ct's players.
Reply With Quote #7

So I tested it,code not works | None effect.

EDIT : Oops sorry it works,but when player connected he can join to ct if there are 4 cts and more..

Last edited by xbatista; 01-09-2009 at 14:13.
xbatista is offline
Send a message via Skype™ to xbatista
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 01-09-2009 , 14:28   Re: CT team can have max 4 ct's players.
Reply With Quote #8

Okay, I rewrote a new version.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 01-09-2009 , 15:12   Re: CT team can have max 4 ct's players.
Reply With Quote #9

Sorry for stupid question,I good configured it? :
register_message( get_user_msgid( "TeamInfo" ), "msg_TeamInfo" );
PHP Code:
public msg_TeamInfomidDestid )
{
    new 
client get_msg_arg_int(1);
    if( !
is_user_connected(client) )
    {
    new 
teamname[3];
    
get_msg_arg_string(2teamnamesizeof(teamname) - 1);
    
    new 
FmTeams:team;
    for( new 
FmTeams:FM_TEAM_UNASSIGNEDFmTeamsi++ )
    {
        if( 
g_TeamInfo[i][0] == teamname[0] )
        {
            
team i;
            break;
        }
    }
    
    if( 
team != FM_TEAM_CT || team == fm_get_user_team(client) )
    {
    new 
ctnum;
    for( new 
1<= g_maxplayersi++ )
    {
        if( 
!= client
        
&& is_user_connected(i)
        && 
fm_get_user_team(i) == FM_TEAM_CT
        
&& ++ctnum == MAX_CTS )
        {
            
set_msg_arg_string(2g_TeamInfo[FM_TEAM_T]);
            return 
PLUGIN_CONTINUE;
        }
//    }
    
return PLUGIN_HANDLED;
    }
}
    return 
PLUGIN_HANDLED;
    }
    if( 
Dest != MSG_ALL && Dest != MSG_BROADCAST )
    {
        return 
PLUGIN_CONTINUE;
    }
    if( !
get_pcvar_nump_On ) )
    {
        return 
PLUGIN_CONTINUE;
    }
    
    if( 
g_bSwitchid ] )
    {
        
g_bSwitchid ] = false;
    }
    
    return 
PLUGIN_CONTINUE;


Last edited by xbatista; 01-09-2009 at 15:37.
xbatista is offline
Send a message via Skype™ to xbatista
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 01-09-2009 , 15:48   Re: CT team can have max 4 ct's players.
Reply With Quote #10

It seems as if you don't know how to script.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] 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:15.


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