This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Player count.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mucx
Member
Join Date: Mar 2011
Location: Estonia
Old 01-14-2012 , 10:00   Player count.
Reply With Quote #1

Hi.

I want to make a kinda different team menu but i'm stuck on one thing.
I don't know how to get players coun't from one team.

PHP Code:
#include < amxmodx >

public plugin_init( ) {
    
register_plugin"PLUGIN" "VERSION" "AUTHOR" );
    
    
register_clcmd"say /team"        "cmdTeam" );
    
register_clcmd"say_team /team"    "cmdTeam" );
}

GetPlayersNumiFlags[ ] = "" iTeam[ ] = "" ) {
    new 
iPlrs32 ] , iNum;
    
get_playersiPlrs iNum iFlags iTeam );
    
    return 
iNum;
}

public 
cmdTeamiPlr ) {
    new 
iMenu menu_create"Select a Team.    \R [ Players ]" "TeamHandler" );
    
    new 
iFlags] , iTeam10 ];
    
    
menu_additemiMenu "Terrorist        \R [ %s ]" "1" GetPlayersNumiFlags[ ] = "h" iTeam[ ] = "TE" ) );
    
menu_additemiMenu "Counter-Terrorist    \R [ %s ]" "2" );
    
menu_additemiMenu "Spectactor    \R [ %s ]" "3" );
    
    
menu_setpropiMenu MPROP_EXIT MEXIT_ALL );
    
menu_displayiPlr iMenu );
}

public 
TeamHandleriPlr iMenu item ) {
    if( 
item == MENU_EXIT ) {
        
menu_destroyiMenu );
        return 
PLUGIN_HANDLED;
    }
    
    new 
Data] , szName64 ];
    new 
access callback;
    
    
menu_item_getinfoiMenu item access Data charsmaxData ) , szName charsmaxszName ) , callback );
    new 
iKey str_to_numData );
    
    switch( 
iKey ) {
        case 
1: {
            
menu_destroyiMenu );
            return 
PLUGIN_HANDLED;
        }
        case 
2: {
            
menu_destroyiMenu );
            return 
PLUGIN_HANDLED;
        }
        case 
3: {
            
menu_destroyiMenu );
            return 
PLUGIN_HANDLED;
        }
    }
    
    
menu_destroyiMenu );
    return 
PLUGIN_HANDLED;

Mucx is offline
raghunarnindi001
Member
Join Date: Apr 2011
Old 01-14-2012 , 10:13   Re: Player count.
Reply With Quote #2

Please give more info on what your trying to do
raghunarnindi001 is offline
Mucx
Member
Join Date: Mar 2011
Location: Estonia
Old 01-14-2012 , 10:15   Re: Player count.
Reply With Quote #3

I want to retrive how many players, each team has.
Then show them in menu

Like
Terrorist [ 10 ]
Counter-Terrorist [ 2 ]
Spectactor [ 5 ]
Mucx is offline
Pastout
Senior Member
Join Date: Dec 2010
Location: 1337 Street LeetTown
Old 01-14-2012 , 10:17   Re: Player count.
Reply With Quote #4

PHP Code:
public cmdTeamiPlr ) {
     new 
iMenu menu_create"Select a Team. \R [ Players ]" "TeamHandler" );
     new 
szText[128];
 
     
formatex(szTextcharsmax(szText), "Terrorist \R [ %d ]"GetPlayersNum"he" "TERRORIST" ) );
     
menu_additem(iMenuszText"1"0);
 
     
formatex(szTextcharsmax(szText), "Counter-Terrorist \R [ %d ]"GetPlayersNum"he" "CT" ) );
     
menu_additem(iMenuszText"2"0);
 
     
formatex(szTextcharsmax(szText), "Spectactor \R [ %d ]"GetPlayersNum"he" "SPEC" ) );
     
menu_additem(iMenuszText"3"0);
 
     
menu_setpropiMenu MPROP_EXIT MEXIT_ALL );
     
menu_displayiPlr iMenu );

Umm Try this now!

Last edited by Pastout; 01-14-2012 at 11:42.
Pastout is offline
Mucx
Member
Join Date: Mar 2011
Location: Estonia
Old 01-14-2012 , 10:21   Re: Player count.
Reply With Quote #5

PHP Code:
ErrorInvalid expressionassumed zero on line 24
Warning
Expression has no effect on line 24
Error
Invalid expressionassumed zero on line 24
Warning
Expression has no effect on line 24
Error
Expected token";"but found ")" on line 24
Error
Too many error messages on one line on line 24. 
Line24:

PHP Code:
formatex(szTextcharsmax(szText), "Terrorist \R [ %d ]"GetPlayersNumiFlags[ ] = "h" iTeam[ ] = "TERRORIST" ) ); 
Mucx is offline
Mucx
Member
Join Date: Mar 2011
Location: Estonia
Old 01-14-2012 , 10:24   Re: Player count.
Reply With Quote #6

I think my problem is with

PHP Code:
GetPlayersNumiFlags[ ] = "h" iTeam[ ] = "TERRORIST" 
and

PHP Code:
GetPlayersNumiFlags[ ] = "" iTeam[ ] = "" ) {
    new 
iPlrs32 ] , iNum;
    
get_playersiPlrs iNum iFlags iTeam );
    
    return 
iNum;

Mucx is offline
Pastout
Senior Member
Join Date: Dec 2010
Location: 1337 Street LeetTown
Old 01-14-2012 , 11:18   Re: Player count.
Reply With Quote #7

Try new edit version!

Sorry forgot something

Last edited by Pastout; 01-14-2012 at 11:42.
Pastout is offline
Mucx
Member
Join Date: Mar 2011
Location: Estonia
Old 01-15-2012 , 08:29   Re: Player count.
Reply With Quote #8

Meanwhile i discovered this, but i have no clue what version is better.

PHP Code:
stock GetPlayersNumCsTeams:iTeam ) {
    new 
iNum;
    for( new 
1<= get_maxplayers( ); i++ ) {
        if( 
is_user_connected) && cs_get_user_team) == iTeam )
            
iNum++;
    }
    return 
iNum;

Mucx is offline
makavelli
Senior Member
Join Date: Nov 2006
Location: Belgium
Old 01-15-2012 , 09:07   Re: Player count.
Reply With Quote #9

this may sound stopit but why do you add "return iNum;" at the end
makavelli is offline
Mucx
Member
Join Date: Mar 2011
Location: Estonia
Old 01-15-2012 , 09:36   Re: Player count.
Reply With Quote #10

So it return the value to the needed place. : ))

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

public plugin_init( ) {
    
register_plugin"PLUGIN" "VERSION" "AUTHOR" );
    
    
register_clcmd"say /test"        "cmdTest" );
    
register_clcmd"say_team /test"    "cmdTest" );
}

public 
cmdTestid ) {
    
client_printid print_chat "There are '%i' Terrorist's."        GetPlayersNumCsTeams:CS_TEAM_T ) );
    
client_printid print_chat "There are '%i' Counter-Terrorist's."    GetPlayersNumCsTeams:CS_TEAM_CT ) );
    
client_printid print_chat "There are '%i' Spectactor's."        GetPlayersNumCsTeams:CS_TEAM_SPECTATOR ) );
}

stock GetPlayersNumCsTeams:iTeam ) {
    new 
iNum;
    for( new 
1<= get_maxplayers( ); i++ ) {
        if( 
is_user_connected) && cs_get_user_team) == iTeam )
            
iNum++;
    }
    return 
iNum;

Mucx 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 18:58.


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