AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Help] Count player connecting ,etc.... (https://forums.alliedmods.net/showthread.php?t=126684)

5c0r-|3i0 05-12-2010 10:39

[Help] Count player connecting ,etc....
 
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...:oops: :oops:
Can anybody help me , thanks in advance....

Exolent[jNr] 05-12-2010 16:12

Re: [Help] Count player connecting ,etc....
 
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     } }

5c0r-|3i0 05-13-2010 07:08

Re: [Help] Count player connecting ,etc....
 
Okay...Thanks for your help :D . I got the idea :D

SpeeDeeR 05-13-2010 10:45

Re: [Help] Count player connecting ,etc....
 
There is an already made plugin for this purpose.Check it if you want http://forums.alliedmods.net/showpost.php?p=1116423&postcount=13

K.K.Lv 05-13-2010 11:30

Re: [Help] Count player connecting ,etc....
 
Quote:

Originally Posted by Exolent[jNr] (Post 1178552)
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
    
}



Exolent[jNr] 05-13-2010 18:10

Re: [Help] Count player connecting ,etc....
 
Quote:

Originally Posted by K.K.Lv (Post 1179173)
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.

K.K.Lv 05-14-2010 00:35

Re: [Help] Count player connecting ,etc....
 
Quote:

Originally Posted by Exolent[jNr] (Post 1179446)
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"

grimvh2 05-14-2010 04:53

Re: [Help] Count player connecting ,etc....
 
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


All times are GMT -4. The time now is 00:23.

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