Code:
#include <amxmodx>
#define PLUGIN "Steam players"
#define VERSION "1.0"
#define AUTHOR "Alka"
#define CHAT_MAX_PRINT 10
#define CHAT_LEN_MAX 106
new lstSteam[CHAT_MAX_PRINT][CHAT_LEN_MAX]
new g_txtFullList[] = "Full list:"
new g_txtFullListNext[] = "(next):"
new g_txtFullListEnd[] = "(end):"
new g_txtSeparation[] = ", "
new showsteamplayers;
public plugin_init()
{
register_plugin( PLUGIN, VERSION, AUTHOR );
register_clcmd( "say /steamppl", "Cmd_Steamppl" );
showsteamplayers = register_cvar( "amx_showsteamplayers", "1" );
}
public Cmd_Steamppl( id )
{
if( !get_pcvar_num( showsteamplayers ) )
return PLUGIN_HANDLED;
new pid, iNum, count, nTab ,lenUserName;
static iPlayers[32], userName[32], authid[12];
for( new i = 0; i < CHAT_MAX_PRINT; i++ ) // clean up array
lstSteam[i][0] = '^0';
get_players( iPlayers, iNum );
for( new i = 0; i < iNum; i++ )
{
pid = iPlayers[i];
get_user_authid( pid, authid, 11 );
if( authid[8] == '1' || authid[8] == '0' /*|| is_user_bot( pid )*/ ) // "STEAM_0:1" or "STEAM_0:0"
{
get_user_name( pid, userName, 31 );
format( userName, 31, "%s%s", userName, i < iNum - 1 ? g_txtSeparation : "." );
lenUserName = strlen( userName );
if( ( strlen( lstSteam[nTab] ) + lenUserName > CHAT_LEN_MAX - 1 ) )
nTab++;
strcat( lstSteam[nTab], userName, CHAT_LEN_MAX - 1 );
count++;
}
}
client_print( id, print_chat, "On server %s %d player%s with STEAM!", count == 1 ? "is" : "are", count, count == 1 ? "" : "s");
client_print( id, print_chat, "%s %s", g_txtFullList, lstSteam[0] );
if( nTab > 0 )
{
for( new i = 1; i <= nTab; i++ )
client_print( id, print_chat, "%s %s %s", g_txtFullList, i < nTab - 1 ? g_txtFullListNext : g_txtFullListEnd, lstSteam[i] );
}
return PLUGIN_HANDLED;
}