Raised This Month: $ Target: $400
 0% 

get_players/cs_get_user_team command


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Revelation
Junior Member
Join Date: Jan 2005
Old 01-25-2005 , 18:46   get_players/cs_get_user_team command
Reply With Quote #1

Code:
***for (j=1; j<=3; j++)     {         num_to_str(j,sTemp,1)         get_players(sPlayers, iPlayerCount,"ce",sTemp)***         for (i=0; i<iPlayerCount; i++)         {             uid = sPlayers[i]             get_user_info(uid,"name",sName,31)             get_user_authid(uid,sSteamID,31)             sLong=""             add(sLong,255,sName)             add(sLong,255,"  ")             add(sLong,255,sSteamID)             add(sLong,255,"^n")             client_print(id,print_console,sLong)             }         }     }
Im trying to get a function to list everybodys SteamID's in the server. I want it so it does a team at a time, terrorist, ct and then spectaters. Just so when its printed its easy to check the enemy teams id's etc. What happens is that it compiles fine, it just doesn't display anyones steamID's on the server. I have tried it without splitting the steamids up by team and it worked. But i then added more code, specifically inbetween the asterisks - i believe the error lies in there somewhere. I just cant figure out whats up.
Revelation is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 01-25-2005 , 19:57  
Reply With Quote #2

The last parameter for get_players needs to be "TERRORIST" or "CT". Seeing as how you use "1" and "2", it won't work. I'm not sure if anyone knows the "team name" for spectator, some have tried "SPEC" and "SPECTATOR" but I have heard that it does not work.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Revelation
Junior Member
Join Date: Jan 2005
Old 01-26-2005 , 02:52  
Reply With Quote #3

ok thanks, avalanche. I thought it was 1,2 or 3, ill give it a shot though.
Revelation is offline
Revelation
Junior Member
Join Date: Jan 2005
Old 01-26-2005 , 12:22  
Reply With Quote #4

ok i reworked on the code abit and really wanted all 3 teams to be processed upon. I tried using the command cs_user_get_team command, but im still not having much look. i get argument type mismatch in the compiler but its only a warning. tried to run it on the server and its not printing anything. heres the code
Code:
/*  Lists players names and steamids in console, one team at a time     */ public cmd_listids(id,level,cid) {     if (!cmd_access(id, level, cid, 1))         return PLUGIN_HANDLED         new sPlayers[32]     new iPlayerCount     new i     new j     new uid     new sLong[256]     new sSteamID[20]     new sName[32]     for (j=1; j<=3; j++)     {         get_players(sPlayers, iPlayerCount,"e")         for (i=0; i<iPlayerCount; i++)         {             uid = sPlayers[i]             if (cs_get_user_team(uid) == j)             {                 get_user_info(uid,"name",sName,31)                 get_user_authid(uid,sSteamID,31)                 sLong=""                 add(sLong,255,sName)                 add(sLong,255,"  ")                 add(sLong,255,sSteamID)                 add(sLong,255,"^n")                 client_print(id,print_console,sLong)             }         }     }     return PLUGIN_HANDLED }
Revelation is offline
Da Bishop
Senior Member
Join Date: Aug 2004
Location: Chester County PA
Old 01-26-2005 , 14:46  
Reply With Quote #5

Would like to make one comment... haven't read the code just kind of scimmed along. My advise is that the add() command should be gotten rid of... add() is ugly. Just my advise.
__________________
Anything that is done can only be done better by urself - since life is a opinion make it the way urs feel its best

~live by it
Da Bishop is offline
Send a message via MSN to Da Bishop
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 01-26-2005 , 15:34  
Reply With Quote #6

What Da Bishop was saying is...
Code:
add(sLong,255,sName) add(sLong,255,"  ") add(sLong,255,sSteamID) add(sLong,255,"^n") // or format(sLong,255,"%s %s^n",sName,sTeamID);

Anyway, cs_get_user_team technically returns CS_TEAM_T, CS_TEAM_CT, or CS_TEAM_SPECTATOR, so you have to compare it to that instead of an integer (even though they are in essence integers). This code works:

Code:
public cmd_listids(id,level,cid) {     if (!cmd_access(id, level, cid, 1))         return PLUGIN_HANDLED           new sPlayers[32]     new iPlayerCount     new i     new j     new uid     new sLong[256]     new sSteamID[20]     new sName[32]     get_players(sPlayers, iPlayerCount,"e")     for (j=1; j<=3; j++)     {         new CsTeams:team;         switch(j) {             case 1: { team = CS_TEAM_T; }             case 2: { team = CS_TEAM_CT; }             case 3: { team = CS_TEAM_SPECTATOR; }         }                 for (i=0; i<iPlayerCount; i++)         {             uid = sPlayers[i]             if (cs_get_user_team(uid) == team)             {                 get_user_info(uid,"name",sName,31)                 get_user_authid(uid,sSteamID,31)                 sLong=""                 add(sLong,255,sName)                 add(sLong,255,"  ")                 add(sLong,255,sSteamID)                 add(sLong,255,"^n")                 client_print(id,print_console,sLong)             }         }     }     return PLUGIN_HANDLED }
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Revelation
Junior Member
Join Date: Jan 2005
Old 01-26-2005 , 16:08  
Reply With Quote #7

excellent, thank you both for your help, works like a charm
Revelation is offline
Reply


Thread Tools
Display Modes

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 19:26.


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