PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <engine>
new ent_name[] = "new_ent";
public plugin_init()
{
register_clcmd("create", "create");
RegisterHam(Ham_Touch, "player", "ent_touch");
//register_touch(ent_name, "player", "ent_touch")
}
public plugin_precache()
precache_model("some model.mdl");
public create(id)
{
new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString,"info_target"));
new Float:StartOrigin[3], Float:Angle[3];
pev(id, pev_origin, StartOrigin);
pev(id, pev_angles, Angle);
set_pev(ent, pev_classname, ent_name);
set_pev(ent, pev_mins, {-1.0, -1.0, -1.0});
set_pev(ent, pev_maxs, {1.0, 1.0, 1.0});
//set_pev(entid, pev_gravity, 0.0)
//set_pev(entid, pev_movetype, MOVETYPE_BOUNCE)
set_pev(ent, pev_movetype, MOVETYPE_BOUNCEMISSILE);
set_pev(ent, pev_solid, SOLID_BBOX);
set_pev(ent, pev_owner, id);
engfunc(EngFunc_SetOrigin, ent, StartOrigin);
engfunc(EngFunc_SetModel, ent, "some model.mdl");
new Float:nVelocity[3];
velocity_by_aim(id, 10, nVelocity);
set_pev(ent, pev_velocity, nVelocity);
}
public ent_touch(player, ent)
{
if(!pev_valid(ent) || !pev_valid(player))
return HAM_IGNORED;
new ent_class[33];
pev(ent, pev_classname, ent_class, 32)
if(equali(ent_class, ent_name))
client_print(0, print_chat, "Someone touches my entity")
return HAM_IGNORED
}