Hello! I am wondering how could i retrieve global id saved variable to a public whom doesn't have the typical id index.
Example :
PHP Code:
#include <amxmodx>
#include <hamsandwich>
new g_Example[33]
public plugin_init()
{
RegisterHam(Ham_Spawn, "player", "player_spawn", 1)
register_logevent("ev_round_end", 2, "1=Round_End")
}
public player_spawn(id)
{
g_Example[id] += 1
}
public ev_round_end() // no id index
{
if(g_Example[id] >= 2)
{
client_print(id, print_chat, "Retrieved player's variable")
}
}
It has nothing specific in the example that i want, i am just curious.
I have seen some plugins which used get_players for retrieving gobal data like that but it seemed pretty much situational, since in this example i don't see logic on how get_players will work.
Although i guess i could set a variable to hold the player's Id i guess.
Like so
PHP Code:
#include <amxmodx>
#include <hamsandwich>
new g_Example[33]
new temp_id
public plugin_init()
{
RegisterHam(Ham_Spawn, "player", "player_spawn", 1)
register_logevent("ev_round_end", 2, "1=Round_End")
}
public player_spawn(id)
{
temp_id = id
g_Example[temp_id] += 1
}
public ev_round_end()
{
if(g_Example[temp_id] >= 2)
{
client_print(temp_id, print_chat, "Retrieved player's variable")
}
}
But is there any other more modern-like way of doing this?