Raised This Month: $51 Target: $400
 12% 

Solved Custom Fakemeta entity touch not working?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 12-24-2019 , 17:42   Custom Fakemeta entity touch not working?
Reply With Quote #1

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?

Last edited by redivcram; 12-25-2019 at 08:52.
redivcram is offline
DarthMan
Veteran Member
Join Date: Aug 2011
Old 12-25-2019 , 06:13   Re: Custom Fakemeta entity touch not working?
Reply With Quote #2

Quote:
Originally Posted by redivcram View Post
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.
DarthMan is offline
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 12-25-2019 , 08:13   Re: Custom Fakemeta entity touch not working?
Reply With Quote #3

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.

Last edited by redivcram; 12-25-2019 at 08:16.
redivcram is offline
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 12-25-2019 , 08:51   Re: Custom Fakemeta entity touch not working?
Reply With Quote #4

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.

Last edited by redivcram; 12-25-2019 at 08:52.
redivcram is offline
DarthMan
Veteran Member
Join Date: Aug 2011
Old 12-25-2019 , 09:36   Re: Custom Fakemeta entity touch not working?
Reply With Quote #5

Quote:
Originally Posted by redivcram View Post
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.

Last edited by DarthMan; 12-25-2019 at 09:37.
DarthMan is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:52.


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