Hartmann, your code worked but i have one bug.
Sometimes give a extra item after 20, 30, 40 seconds, how to fix?
PHP Code:
#include < amxmodx >
#include < zombieplague >
#define PRIMARY_WEAPONS_BIT_SUM ((1<<CSW_SCOUT) | (1<<CSW_XM1014) | (1<<CSW_MAC10) | (1<<CSW_AUG) | (1<<CSW_UMP45) | (1<<CSW_SG550) | (1<<CSW_GALIL) | (1<<CSW_FAMAS) | (1<<CSW_AWP) | (1<<CSW_MP5NAVY) | (1<<CSW_M249) | (1<<CSW_M3) | (1<<CSW_M4A1) | (1<<CSW_TMP) | (1<<CSW_G3SG1) | (1<<CSW_SG552) | (1<<CSW_AK47) | (1<<CSW_P90))
new const VERSION[] = "0.1";
new g_has_extra[33];
new human_extraid[][] =
{
"Rock Guitar",
"AKM 12",
"[Balrog] Ethereal"
}
public plugin_init()
{
register_plugin("[ZP] Bot Addon: Auto Buy Extras", VERSION, "CrazY");
set_task(10.0, "buy_extra", .flags="b");
}
public buy_extra()
{
new sizeof_extras = random(sizeof human_extraid);
new players[32], iPnum , sName[32];
get_players(players, iPnum, "a");
new player;
if(iPnum) player = players[random(iPnum)];
if(is_user_bot(player) && !g_has_extra[player] && !zp_get_user_zombie(id))
{
get_user_name(player, sName, 31);
drop_primary(player);
g_has_extra[player] = true;
zp_force_buy_extra_item(player, zp_get_extra_item_id(human_extraid[sizeof_extras]), 1);
set_hudmessage(random(255), random(255), random(255), -1.0, 0.7, 0, 2.0, 4.0, 1.0, 1.0);
show_hudmessage(0, "O bot %s ganhou uma %s.", sName, human_extraid[sizeof_extras]);
}
}
stock drop_primary(id)
{
new weapons[32], num;
get_user_weapons(id, weapons, num);
for (new i = 0; i < num; i++)
{
if (PRIMARY_WEAPONS_BIT_SUM & (1<<weapons[i]))
{
static wname[32];
get_weaponname(weapons[i], wname, sizeof wname - 1);
engclient_cmd(id, "drop", wname);
}
}
}
__________________