Thanks guys, with your help, i made it work
Here is my final code (wepon giving is only example)
Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <fun>
#include <hamsandwich>
new bool: g_random[33]
public plugin_init()
{
register_plugin("Random Player", "0.1", "padilha007")
RegisterHam(Ham_Spawn, "player", "bacon_spawn", 1);
}
public bacon_spawn()
{
new player;
if((player = GetRandomPlayer("a")) > 0)
{
g_random[player] = true
set_task(0.0, "give_weapon")
}
}
public give_weapon(id)
{
if(g_random[id])
{
give_item(id, "weapon_m4a1");
}
}
GetRandomPlayer(const flags[]="", const teamORname[]="")
{
new players[32], pnum;
get_players(players, pnum, flags, teamORname);
new selected = 0;
while( is_user_alive((players[(selected = random(pnum))])))
{
return players[selected];
}
return 0;
}