Quote:
Originally Posted by Crackhead69
I see, but won't that trigger the client print to everybody if just One player has the value?
|
Code:
client_print( iPlayer , print_chat, "Retrieved player's variable")
No. If you used 0 instead of
iPlayer, then yes.
Maybe this will help clear your confusion. The code below is functionally equivalent to what Bugsy did, but now you have an explicit function, player_round_end(id), that takes the player index as an argument. Hope it will help you see why this works just fine. The loop is over all players, but you still execute the code over one player at a time.
(I'm not saying you should use the code below, I just provided it for intuition)
PHP Code:
#include <amxmodx>
#include <hamsandwich>
new g_Example[ MAX_PLAYERS + 1 ];
public plugin_init()
{
RegisterHam(Ham_Spawn, "player", "player_spawn", 1)
register_logevent("ev_round_end", 2, "1=Round_End")
}
public player_spawn(id)
{
if ( is_user_alive( id ) )
{
g_Example[ id ] += 1;
}
}
public ev_round_end()
{
new iPlayers[ 32 ] , iNum , iPlayer;
get_players( iPlayers , iNum );
for ( new i = 0 ; i < iNum ; i++ )
{
player_round_end(iPlayers[i]);
}
}
player_round_end(id)
{
if ( g_Example[id] >= 2 )
{
client_print(id, print_chat, "Retrieved player's variable")
}
}
__________________