Quote:
Originally Posted by WATCH_DOGS UNITED
Hi! We were able to make our code work with bots. But this required to duplicate the code (1 for humans and 1 for bots). Could you show us the code registering with RegisterHamFromEntity?
|
Here
PHP Code:
#include <amxmodx>
#include <hamsandwich>
new bool:registeredHamForBots
public plugin_init()
{
RegisterHam(Ham_Spawn, "player", "SpawnHook", 1)
}
public client_putinserver(id)
{
if(is_user_bot(id) && !registeredHamForBots)
{
registeredHamForBots = true
set_task(0.1, "registerHamForBots", id)
}
}
public registerHamForBots(id)
{
RegisterHamFromEntity(Ham_Spawn, id, "SpawnHook", true)
}
public SpawnHook(id)
{
if(is_user_alive(id))
{
//do stuff for both players and bots here
}
}
No need to duplicate any code.
__________________