AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Using get_user_team in a loop, returns (-1) (https://forums.alliedmods.net/showthread.php?t=139837)

HLM 10-05-2010 19:35

Using get_user_team in a loop, returns (-1)
 
PHP Code:

new iPlayers[32], iNum
get_players
(iPlayersiNum)
for(new 
0iNumi++)
{
    
client_print(0print_chat"%d",  get_user_team(i))


what am I doing wrong? also: I tested this with and without bots, it reports correct team numbers for bots, but human players have a -1.

alan_el_more 10-05-2010 19:37

Re: Using get_user_team in a loop, returns (-1)
 
Try cs_get_user_team( )

Hx7r 10-05-2010 19:55

Re: Using get_user_team in a loop, returns (-1)
 
Try get_user_team(iPlayers[i])

fysiks 10-05-2010 19:59

Re: Using get_user_team in a loop, returns (-1)
 
Quote:

Originally Posted by Hx7r (Post 1316604)
Try get_user_team(iPlayers[i])

Yep, that should fix it.

HLM 10-05-2010 20:57

Re: Using get_user_team in a loop, returns (-1)
 
Quote:

Originally Posted by alan_el_more (Post 1316584)
Try cs_get_user_team( )

im not using CS, thanks though

Quote:

Originally Posted by fysiks (Post 1316611)
Yep, that should fix it.

Okay.. but WHY should that fix it? I understand i=id in loop, so what is iplayers[i] is that the userid?

Exolent[jNr] 10-05-2010 21:04

Re: Using get_user_team in a loop, returns (-1)
 
i is the index of the array iPlayers which holds player ids.
i is not a player id.

GXLZPGX 10-05-2010 21:20

Re: Using get_user_team in a loop, returns (-1)
 
PHP Code:

new iPlayers[32], iNumplr;
get_players(iPlayersiNum)

for(new 
0iNumi++) 
{
    
plr iPlayers[i]
    
client_print(0print_chat"%d",  get_user_team(plr)) 



fysiks 10-05-2010 22:31

Re: Using get_user_team in a loop, returns (-1)
 
Quote:

Originally Posted by GXLZPGX (Post 1316665)
PHP Code:

new iPlayers[32], iNumplr;
get_players(iPlayersiNum)

for(new 
0iNumi++) 
{
    
plr iPlayers[i]
    
client_print(0print_chat"%d",  get_user_team(plr)) 



echo . . . echo . . . . . . echo . . . . . .

Bugsy 10-05-2010 23:30

Re: Using get_user_team in a loop, returns (-1)
 
LOL fysiks I was thinking the same thing.

Exolent[jNr] 10-05-2010 23:33

Re: Using get_user_team in a loop, returns (-1)
 
Quote:

Originally Posted by Bugsy (Post 1316716)
LOL fysiks I was thinking the same thing.



All times are GMT -4. The time now is 10:19.

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