I'm not sure, but it seems to me that some of those acquisitions module hamsandwich whose entityClass is "player" are not understood by bots, it ends up causing a certain headache who used to test your plugins in local mode.
Well, it's very simple. We just need to register the ham directly in the entity of the bot.
First of all, let's add some includes.
Code: Select all
#include <amxmodx>
#include <hamsandwich> Code: Select all
new g_hambots; // This variable will check if the hams have been recorded
new cvar_botquota; // This variable will check if there is bots in the game Code: Select all
public plugin_init()
{
register_plugin("Register Ham Bots", "v0.1", "Crazy");
// Get bot_quota number
cvar_botquota = get_cvar_pointer("bot_quota");
// Register Ham_TakeDamage
RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage");
} Code: Select all
public client_putinserver(id)
{
// If the ID dont is bot
if (!is_user_bot(id))
return;
// If the ham already registered
if (g_hambots)
return;
// If dont have any bot in game
if (!cvar_botquota)
return;
// Set a register ham bots task into bot id
set_task(0.1, "fw_RegisterHamBots", id);
} Code: Select all
public fw_RegisterHamBots(id)
{
// Ham Forwards
RegisterHamFromEntity(Ham_TakeDamage, id, "fw_TakeDamage"); // In this case, Ham_TakeDamage
// Here you add any Ham you need
// Register complete
g_hambots = true;
} Code: Select all
public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
{
// If dont is alive attacker
if (!is_user_alive(attacker))
return HAM_IGNORED;
// Do something...
return HAM_SUPERCEDE;
} Code: Select all
#include <amxmodx>
#include <hamsandwich>
new g_hambots; // This variable will check if the hams have been recorded
new cvar_botquota; // This variable will check if there is bots in the game
public plugin_init()
{
register_plugin("Register Ham Bots", "v0.1", "Crazy");
// Get bot_quota number
cvar_botquota = get_cvar_pointer("bot_quota");
// Register Ham_TakeDamage
RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage");
}
public client_putinserver(id)
{
// If the ID dont is bot
if (!is_user_bot(id))
return;
// If the ham already registered
if (g_hambots)
return;
// If dont have any bot in game
if (!cvar_botquota)
return;
// Set a register ham bots task into bot id
set_task(0.1, "fw_RegisterHamBots", id);
}
public fw_RegisterHamBots(id)
{
// Ham Forwards
RegisterHamFromEntity(Ham_TakeDamage, id, "fw_TakeDamage"); // In this case, Ham_TakeDamage
// Here you add any Ham you need
// Register complete
g_hambots = true;
}
public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
{
// If dont is alive attacker
if (!is_user_alive(attacker))
return HAM_IGNORED;
// Do something...
return HAM_SUPERCEDE;
} 