View Single Post
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-09-2021 , 05:19   Re: Getting global data from non-id publics
Reply With Quote #4

Quote:
Originally Posted by Crackhead69 View Post
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_ExampleMAX_PLAYERS ];

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_aliveid ) )
    {
        
g_Exampleid ] += 1;
    }
}

public 
ev_round_end()
{
    new 
iPlayers32 ] , iNum iPlayer;
    
    
get_playersiPlayers iNum );
    
    for ( new 
iNum i++ )
    {
        
player_round_end(iPlayers[i]);
    } 


player_round_end(id)
{
       if ( 
g_Example[id] >= )
       {
           
client_print(idprint_chat"Retrieved player's variable")
       }

__________________

Last edited by HamletEagle; 08-09-2021 at 05:23.
HamletEagle is offline