[TUT] Registering hams on bots
Posted: Sun Oct 04, 2026 2:10 pm
[TUT] Registering hams on bots.
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.
Now, let's create some variables.
Now, let's store in varialvel cvar_botquota, the value of bots found in the game and register a test Ham_TakeDamage.
Now, let's call a task when the bot enter the game to register the hams.
Now let's create our function to log ham in bots.
Last, but not least, let's create our Ham_TakeDamage.
And at the end we get this:
If you are in any doubt about what should, or not use, check the module hamsandwich. All the forwards that contain classes geared players, can be registered with the code that I taught you.
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;
}