So, I'm spawning my own handmade entity via command and player's aiming end origin and I wanna create specific events on touch. I've been working with ents long time ago, there are great tutorials and threads regarding entities, I thought I've done everything properly, but some diodes in the circuit do not emit the brightest light.
I'm spawning my entity as so:
PHP Code:
public SpawnEnt(Float:fOrigin[3]) {
new iEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));
if(!iEnt) return FMRES_IGNORED;
static const Float:fMins[] = {-50.0, -50.0, -50.0};
static const Float:fMaxes[] = {50.0, 50.0, 50.0};
set_pev(iEnt, pev_classname, "bottle_o_wine");
engfunc(EngFunc_SetOrigin, iEnt, fOrigin);
engfunc(EngFunc_SetModel, iEnt, "models/winebottle.mdl");
set_pev(iEnt, pev_solid, SOLID_TRIGGER);
engfunc(EngFunc_SetSize, iEnt, fMins, fMaxes);
dllfunc(DLLFunc_Spawn, iEnt);
return FMRES_IGNORED;
}
The ent spawns at the exact origin as I wanted. Now here's the touch hooking function and how I've summoned it.
PHP Code:
public FMHookTouch(ptr, ptd) {
new szPlayerClassname[32];
pev(ptd, pev_classname, szPlayerClassname, charsmax(szPlayerClassname));
if(!equal(szPlayerClassname, "player"))
return FMRES_IGNORED;
if(!is_user_alive(ptd) || !is_user_connected(ptd))
return FMRES_IGNORED;
new szEntClassname[32];
pev(ptr, pev_classname, szEntClassname, charsmax(szEntClassname));
client_print(ptd, print_chat, "Touched: %s", szEntClassname);
}
PHP Code:
public plugin_init() {
register_forward(FM_Touch, "FMHookTouch");
}
The function works; func_buyzone, worldspawn and weaponbox (dropped weapon) as a test show up, but my entity does not when I'm going through it. Also, for some reason, SOLID_BBOX does not make my entity solid, I can still go through it (doesn't even trigger the touch). I want it to remain SOLID_TRIGGER, that was only a test, however, could the solidity be an issue? What else might I be doing wrong?