Raised This Month: $ Target: $400
 0% 

[SOLVED] find entity by "gibmodel" value


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kNowo
Senior Member
Join Date: Apr 2011
Location: Malaysia
Old 08-31-2013 , 14:30   [SOLVED] find entity by "gibmodel" value
Reply With Quote #1

Is it possible to find entities by their gibmodel value?

The code below is the properties of a func_breakable entity in a map. I'd like to do some stuff to these entities and they all share one same property, which is the "gibmodel".
Code:
{
  "model" "*1"
  "rendercolor" "0 0 0"
  "gibmodel" "models/metalplategibs_green.mdl"
  "targetname" "targetb"
  "explodemagnitude" "100"
  "material" "2"
  "health" "1"
  "spawnflags" "1"
  "classname" "func_breakable"
}
Let's say I'm trying to delete those entities and I used the code below but it return those entities as invalid
PHP Code:
while((aEnt engfunc(EngFunc_FindEntityByStringaEnt"gibmodel""models/metalplategibs_green.mdl")))
{
    
engfunc(EngFunc_RemoveEntityaEnt)


Last edited by kNowo; 08-31-2013 at 14:31.
kNowo is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-31-2013 , 15:28   Re: find entity by "gibmodel" value
Reply With Quote #2

PHP Code:
const XO_CBREAKABLE 4;
const 
m_iszGibModel 40;

{
    while( (
aEnt find_breakable_by_gibmodel(aEnt,  "models/metalplategibs_green.mdl")) )
    {
        
remove_entity(aEnt);
    }
}
find_breakable_by_gibmodel(startent, const gibmodel[])
{
    static 
entiszGibModelszGibModel[128];
    
ent startent;
    while( (
ent find_ent_by_class(ent"func_breakable")) )
    {
        
iszGibModel get_pdata_int(entm_iszGibModelXO_CBREAKABLE);
        if( 
iszGibModel )
        {
            
global_get(glb_pStringBaseiszGibModelszGibModelcharsmax(szGibModel));
            if( 
equal(szGibModelgibmodel) )
            {
                return 
ent;
            }
        }
    }
    return 
ent;

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 08-31-2013 at 15:29.
ConnorMcLeod is offline
kNowo
Senior Member
Join Date: Apr 2011
Location: Malaysia
Old 08-31-2013 , 15:42   Re: find entity by "gibmodel" value
Reply With Quote #3

Thanks ConnorMcLeod, it works flawlessly

EDIT: I need one more thing, I'd like to get all the trigger_hurt entities indexes in a map that has "damagetype" of DMG_FALL (32)

Bad English. Let me rephrase: I'd like to loop all trigger_hurt entities, and if their damagetype is 32, then do something to them. Right now I'm stuck at getting the damagetype value.

Last edited by kNowo; 08-31-2013 at 15:48.
kNowo is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-31-2013 , 16:15   Re: find entity by "gibmodel" value
Reply With Quote #4

You are in the scripting section, it's a good idea to show what you've done, so people can correct you and you can learn from that.
__________________
Arkshine is offline
kNowo
Senior Member
Join Date: Apr 2011
Location: Malaysia
Old 08-31-2013 , 16:56   Re: find entity by "gibmodel" value
Reply With Quote #5

Quote:
Originally Posted by Arkshine View Post
You are in the scripting section, it's a good idea to show what you've done, so people can correct you and you can learn from that.
It's just the same engine native
PHP Code:
while((ent find_ent_by_class(ent"trigger_hurt")))
{
    
//check if "damagetype" equal to 32


Last edited by kNowo; 08-31-2013 at 16:57.
kNowo is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-31-2013 , 17:11   Re: find entity by "gibmodel" value
Reply With Quote #6

check pdata m_bitsDamageInflict if it contains DMG_FALL, but i doubt it can be possible

PHP Code:
const XO_CBASETOGGLE2 5;
const 
m_bitsDamageInflict 71
PHP Code:
    if( get_pdata_int(entm_bitsDamageInflictXO_CBASETOGGLE2) & DMG_FALL 
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
kNowo
Senior Member
Join Date: Apr 2011
Location: Malaysia
Old 08-31-2013 , 17:33   Re: find entity by "gibmodel" value
Reply With Quote #7

Yea, it's not working. Do you have another way that you think could pull it off?
kNowo is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-31-2013 , 17:45   Re: find entity by "gibmodel" value
Reply With Quote #8

Code is ok, it's just that i don't think that DMG_FALL is set on trigger_hurt
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
kNowo
Senior Member
Join Date: Apr 2011
Location: Malaysia
Old 08-31-2013 , 17:54   Re: find entity by "gibmodel" value
Reply With Quote #9

#define DMG_FALL (1<<5)
1<<5 equals to 32 (assuming my calculation is correct)

What I think is the pdata 71 is for something else (totally a blind guess).
kNowo is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-01-2013 , 02:53   Re: find entity by "gibmodel" value
Reply With Quote #10

You don't understand, seems that damage is different from DMG_FALL, also i've never seen a trigger_hurt with DMG_FALL so far.
Which map it is ?
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 09-01-2013 at 02:54.
ConnorMcLeod 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 18:59.


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