@Foxa
1. The steam ID will not always be available at client_connect(). I recommend using client_authorized() if you require the steam ID.
2. Your code is written to print to only those who have the specified admin status/flags but then you use 0 in client_print, which prints to everyone. So everyone would see the same print <number of players> number of times. Change this to the player id.
3. Capture the steam id in a global variable so it can be re-used when the player disconnects. No sense in calling a native that returns the same value twice.
4. Your code would not work if the Flag variable held more than 1 flags.
5. I would add "ch" flags to get_players() to exclude bots/HLTV.
6. 'stock' should not be used within a plugin, only include files.
@1M1e - I would avoid printing the 'connecting' and 'connected' messages, use connected only since you are guaranteed to have steam ID at authorized(). It would be annoying to see the same message back to back for each player.
Spoiler
PHP Code:
#include <amxmodx>
#define PLUGIN "ConnectDisconnect Message"
#define VERSION "1.0"
#define AUTHOR "AlliedMods"
#define MAX_PLAYERS 32
new const Flag[] = "d"; //Change the flag to whatever you want
new g_szAuthID[ MAX_PLAYERS + 1 ][ 34 ];
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
}
public client_authorized( id )
{
new szName[ 32 ] , players[ 32 ], num , iPlayer;
get_user_authid(id, g_szAuthID[ id ] , charsmax( g_szAuthID[] ))
get_user_name(id, szName, charsmax(szName))
get_players(players, num , "ch" )
for(new i=0; i<num; i++)
{
iPlayer = players[ i ]
if ( is_admin( iPlayer ) )
{
client_print( iPlayer , print_chat , "%s has connected SteamID (%s)" , szName , g_szAuthID[ id ] );
}
}
}
public client_disconnected(id)
{
new szName[32] , players[ 32 ] , num , iPlayer;
get_user_name(id, szName, charsmax(szName))
get_players(players, num , "ch" )
for(new i=0; i<num; i++)
{
iPlayer = players[ i ]
if ( is_admin( iPlayer ) )
{
client_print( iPlayer , print_chat , "%s has disconnected SteamID (%s)" , szName , g_szAuthID[ id ] );
}
}
}
bool:is_admin( id )
{
new iFlags = read_flags( Flag );
return bool:( ( get_user_flags( id ) & iFlags ) == iFlags );
}
__________________