AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Custom Fakemeta entity touch not working? (https://forums.alliedmods.net/showthread.php?t=320492)

redivcram 12-24-2019 17:42

Custom Fakemeta entity touch not working?
 
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_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"));
    
    if(!
iEnt) return FMRES_IGNORED;
    
    static const 
Float:fMins[] = {-50.0, -50.0, -50.0};
    static const 
Float:fMaxes[] = {50.050.050.0};
    
    
set_pev(iEntpev_classname"bottle_o_wine");
    
engfunc(EngFunc_SetOriginiEntfOrigin);
    
engfunc(EngFunc_SetModeliEnt"models/winebottle.mdl");
    
set_pev(iEntpev_solidSOLID_TRIGGER);
    
engfunc(EngFunc_SetSizeiEntfMinsfMaxes);
    
dllfunc(DLLFunc_SpawniEnt);
    
    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(ptrptd) {
    
    new 
szPlayerClassname[32];
    
pev(ptdpev_classnameszPlayerClassnamecharsmax(szPlayerClassname));
    
    if(!
equal(szPlayerClassname"player"))
        return 
FMRES_IGNORED;
    
    if(!
is_user_alive(ptd) || !is_user_connected(ptd))
        return 
FMRES_IGNORED;
    
    new 
szEntClassname[32];
    
pev(ptrpev_classnameszEntClassnamecharsmax(szEntClassname));
    
    
client_print(ptdprint_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?

DarthMan 12-25-2019 06:13

Re: Custom Fakemeta entity touch not working?
 
Quote:

Originally Posted by redivcram (Post 2677943)
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_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"));
    
    if(!
iEnt) return FMRES_IGNORED;
    
    static const 
Float:fMins[] = {-50.0, -50.0, -50.0};
    static const 
Float:fMaxes[] = {50.050.050.0};
    
    
set_pev(iEntpev_classname"bottle_o_wine");
    
engfunc(EngFunc_SetOriginiEntfOrigin);
    
engfunc(EngFunc_SetModeliEnt"models/winebottle.mdl");
    
set_pev(iEntpev_solidSOLID_TRIGGER);
    
engfunc(EngFunc_SetSizeiEntfMinsfMaxes);
    
dllfunc(DLLFunc_SpawniEnt);
    
    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(ptrptd) {
    
    new 
szPlayerClassname[32];
    
pev(ptdpev_classnameszPlayerClassnamecharsmax(szPlayerClassname));
    
    if(!
equal(szPlayerClassname"player"))
        return 
FMRES_IGNORED;
    
    if(!
is_user_alive(ptd) || !is_user_connected(ptd))
        return 
FMRES_IGNORED;
    
    new 
szEntClassname[32];
    
pev(ptrpev_classnameszEntClassnamecharsmax(szEntClassname));
    
    
client_print(ptdprint_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?

You have to set the solidity after setting the size. Set model, size, origin then set the solidity and then spawn the entity.

redivcram 12-25-2019 08:13

Re: Custom Fakemeta entity touch not working?
 
PHP Code:

    set_pev(iEntpev_classname"bottle_o_wine");
    
engfunc(EngFunc_SetModeliEnt"models/winebottle.mdl");
    
engfunc(EngFunc_SetSizeiEntfMinsfMaxes);
    
engfunc(EngFunc_SetOriginiEntfOrigin);
    
set_pev(iEntpev_solidSOLID_TRIGGER);
    
dllfunc(DLLFunc_SpawniEnt); 

Nope.
SOLID_BBOX does not make it solid as I can still walk through it and the touch function still does not get called on either SOLID_ attribute.

redivcram 12-25-2019 08:51

Re: Custom Fakemeta entity touch not working?
 
https://forums.alliedmods.net/showpo...4&postcount=11

Goddamn, sorry for creating this thread, I did not know that each property should be in a particular order, this is from one of my oldest threads.
Thanks for your reply.

DarthMan 12-25-2019 09:36

Re: Custom Fakemeta entity touch not working?
 
Quote:

Originally Posted by redivcram (Post 2677985)
https://forums.alliedmods.net/showpo...4&postcount=11

Goddamn, sorry for creating this thread, I did not know that each property should be in a particular order, this is from one of my oldest threads.
Thanks for your reply.

Yeah, that's more like it. Seems that the solidity is set after spawn.


All times are GMT -4. The time now is 02:43.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.