AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   get_players/cs_get_user_team command (https://forums.alliedmods.net/showthread.php?t=9632)

Revelation 01-25-2005 18:46

get_players/cs_get_user_team command
 
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.

XxAvalanchexX 01-25-2005 19:57

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.

Revelation 01-26-2005 02:52

ok thanks, avalanche. I thought it was 1,2 or 3, ill give it a shot though.

Revelation 01-26-2005 12:22

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 }

Da Bishop 01-26-2005 14:46

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.

XxAvalanchexX 01-26-2005 15:34

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 }

Revelation 01-26-2005 16:08

excellent, thank you both for your help, works like a charm :)


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

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