Raised This Month: $ Target: $400
 0% 

[Help] Count player connecting ,etc....


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
5c0r-|3i0
Veteran Member
Join Date: Nov 2008
Location: Việt Nam
Old 05-12-2010 , 10:39   [Help] Count player connecting ,etc....
Reply With Quote #1

I) Title
PHP Code:
    new Playersnum
    
new Count
    
new Num
    Playersnum 
get_playersnum()
            
    for(
Count 0;Count <= Playersnum;Count++)
        if(
is_user_connected(Count))
            
Num++        
            
Playersnum Num 
Is that correct ??
II)
1) I want to add points into 2 variables , like this ..:
Quote:
g_Tpoints
g_CTpoints
When a player in a team killed , point is added to his team's variables..
3)But points start counting only when the number of players connecting (not including SPECTATOR) is bigger than "cvar_playerrequired" <- that's not difficult for me...
Can anybody help me , thanks in advance....
5c0r-|3i0 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 05-12-2010 , 16:12   Re: [Help] Count player connecting ,etc....
Reply With Quote #2

1. You can use get_playersnum() without all that extra nonsense.
Code:
new iPlayerCount = get_playersnum( ); // or new iPlayers[ 32 ], iNum; get_players( iPlayers, iNum ); // iNum = connected players

2. Check the player team, then change the variable accordingly.

Code:
switch( get_user_team( iPlayer ) ) {     case 0:     {         // unassigned     }     case 1:     {         // terrorist     }     case 2:     {         // counter-terrorist     }     case 3:     {         // spectator     } } // or switch( cs_get_user_team( iPlayer ) ) {     case CS_TEAM_UNASSIGNED:     {         // unassigned     }     case CS_TEAM_T:     {         // terrorist     }     case CS_TEAM_CT:     {         // counter-terrorist     }     case CS_TEAM_SPECTATOR:     {         // spectator     } }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
5c0r-|3i0
Veteran Member
Join Date: Nov 2008
Location: Việt Nam
Old 05-13-2010 , 07:08   Re: [Help] Count player connecting ,etc....
Reply With Quote #3

Okay...Thanks for your help . I got the idea
5c0r-|3i0 is offline
SpeeDeeR
Veteran Member
Join Date: Mar 2010
Location: Bulgaria
Old 05-13-2010 , 10:45   Re: [Help] Count player connecting ,etc....
Reply With Quote #4

There is an already made plugin for this purpose.Check it if you want http://forums.alliedmods.net/showpost.php?p=1116423&postcount=13

Last edited by SpeeDeeR; 05-13-2010 at 10:47.
SpeeDeeR is offline
K.K.Lv
Veteran Member
Join Date: Aug 2008
Location: GameFolder
Old 05-13-2010 , 11:30   Re: [Help] Count player connecting ,etc....
Reply With Quote #5

Quote:
Originally Posted by Exolent[jNr] View Post
PHP Code:
switch( get_user_team(iPlayer ))
{
    case 
0: {
        
// unassigned
    
}
    case 
1: {
        
// terrorist
    
}
    case 
2: {
        
// counter-terrorist
    
}
    case 
3: {
        
// spectator
    
}

I think should be like this :
PHP Code:
switch( get_user_team(iPlayer ))
{
    case 
0: {
        
// unassigned,spectator
    
}
    case 
1: {
        
// terrorist
    
}
    case 
2: {
        
// counter-terrorist
    
}

__________________
QQ:116268742
K.K.Lv is offline
Send a message via MSN to K.K.Lv
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 05-13-2010 , 18:10   Re: [Help] Count player connecting ,etc....
Reply With Quote #6

Quote:
Originally Posted by K.K.Lv View Post
I think should be like this :
PHP Code:
switch( get_user_team(iPlayer ))
{
    case 
0: {
        
// unassigned,spectator
    
}
    case 
1: {
        
// terrorist
    
}
    case 
2: {
        
// counter-terrorist
    
}

You think wrong.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
K.K.Lv
Veteran Member
Join Date: Aug 2008
Location: GameFolder
Old 05-14-2010 , 00:35   Re: [Help] Count player connecting ,etc....
Reply With Quote #7

Quote:
Originally Posted by Exolent[jNr] View Post
You think wrong.
can you tell me why my think is wrong ?

i have remembered Arkshine had shown a example, and I test it !

PHP Code:
register_clcmd("say test""CmdTest")
 
public 
CmdTest(id)
{
    new 
team get_user_team(id)
    
client_print(idprint_chat"you team is %i"team)

so, when my team is on unassigned or spectator , team is equal "0"
__________________
QQ:116268742
K.K.Lv is offline
Send a message via MSN to K.K.Lv
grimvh2
Veteran Member
Join Date: Nov 2007
Location: Fishdot Nation
Old 05-14-2010 , 04:53   Re: [Help] Count player connecting ,etc....
Reply With Quote #8

When you join the game ur 0, when you actually choose spectator on the menu ( wich is option 3 ) you will also be in team 3
__________________
I am out of order!
grimvh2 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 00:04.


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