I'm trying to make a plugin that spawns entities that behave like buttons, let's say it that way.
But whenever I spawn it and try to use it, nothing happens. (Simply stand close to it, press my use key "e" like to any other button/entity, and It's supposed to print out "Button Press", but nothing)
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fakemeta>
#include <fakemeta_util>
new g_Classname[] = "wboxexample";
new g_Model[] = "models/w_weaponbox.mdl";
public plugin_init()
{
register_plugin("Button Entity", "1.0", "redivcram");
RegisterHam(Ham_Use, "func_button", "EvUse", 0);
register_clcmd("say /wb", "CmdWB");
}
public plugin_precache()
{
precache_model(g_Model);
}
public CmdWB(id)
{
new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));
new Float:origin[3];
fm_get_aim_origin(id, origin);
set_pev(ent, pev_classname, g_Classname);
engfunc(EngFunc_AllocString, "func_button");
set_pev(ent, pev_target, "weaponbox_test");
engfunc(EngFunc_SetModel, ent, g_Model);
engfunc(EngFunc_SetSize, ent, Float:{-25.0, -25.0, -25.0}, Float:{25.0, 25.0, 25.0});
set_pev(ent, pev_solid, SOLID_BBOX);
engfunc(EngFunc_SetOrigin, ent, origin);
}
public EvUse(ent, id)
{
if(!is_user_alive(id))
return HAM_IGNORED;
new target[33];
pev(ent, pev_target, target, sizeof (target) - 1);
if(equali(target, "weaponbox_test"))
{
client_print(id, print_chat, "Button Press");
}
return HAM_IGNORED;
}