Raised This Month: $ Target: $400
 0% 

how to prevent registerhamfromentity being called for whole classname


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
avril-lavigne
Banned
Join Date: Apr 2009
Old 11-12-2014 , 00:38   how to prevent registerhamfromentity being called for whole classname
Reply With Quote #1

RegisterHamFromEntity(Ham_Killed, ent, "fw_killed",1)
RegisterHamFromEntity(Ham_TakeDamage, ent, "fw_takedamage_ent",1)

in ent create func

when I do damage or kill ent
forward(s) calls as many times as many entities in the world

example there are two ents. 1 hit to ent makes two fwd calls
4 ents - 8 fwd calls.

how to filter it to have 1 forward call per one entity ?
I want to spawn entity again after kill .

So now I have 2 ents instead of 1
than 4 instead of 2 and so on .

engfunc(EngFunc_AllocString, "info_target"))
I Know I can register it for info_target than filter for classname
but not sure

also I cant give weapon to ent
entity_set_string(ent, EV_SZ_weaponmodel, knifemdl)
doesnt work
__________________
VDS in Europe 1 gb/s unmetered.Any configurations.
I accept Paypal, Moneybookers,etc

Last edited by avril-lavigne; 11-12-2014 at 02:33.
avril-lavigne is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 11-12-2014 , 04:31   Re: how to prevent registerhamfromentity being called for whole classname
Reply With Quote #2

why do you register hamkilled? It's not necessary, hook damage pre and if damage > health, hook a death event for entities where you do all you need when the entity must be removed.
__________________
Jhob94 is online now
avril-lavigne
Banned
Join Date: Apr 2009
Old 11-12-2014 , 06:41   Re: how to prevent registerhamfromentity being called for whole classname
Reply With Quote #3

Ive already tried that

I have Two bots-entities.
look at the log

1st hit produce TWO lines instead of ONE , for EACH entity in the world

L 11/12/2014 - 13:28:09: [soccer.amxx] damage 65.00 victim health 35.00
L 11/12/2014 - 13:28:09: [soccer.amxx] damage 65.00 victim health 35.00

second hit also 2 lines

L 11/12/2014 - 13:28:12: [soccer.amxx] damage 65.00 victim health -30.00
L 11/12/2014 - 13:28:12: [soccer.amxx] damage 65.00 victim health -30.00

So condition below makes TWO entities instead of "killed" one

PHP Code:
public fw_takedamage_ent(victiminflictorattackerFloat:damagedamage_type)
{
  if(
damage >= entity_get_float(victim,EV_FL_health))
 {
              
               
emit_sound(victimCHAN_AUTOdeath_sound[random_num(0sizeof death_sound 1)], 1.0ATTN_NORM0PITCH_NORM)
        switch(
entity_get_int(victimEV_INT_team))
        {
            case 
1:create_bott()
            case 
2:create_botct()
        }
   }

After killing entity I have 4 bots instead of 1
2 calls of forward multiply 2 entities = 4

If I have 4 bots-entities. killing just ONE makes over 8 new bots....

I need to filter just one ent being damaged to prevent multiple fwd calls
__________________
VDS in Europe 1 gb/s unmetered.Any configurations.
I accept Paypal, Moneybookers,etc

Last edited by avril-lavigne; 11-12-2014 at 06:47.
avril-lavigne is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 11-12-2014 , 07:06   Re: how to prevent registerhamfromentity being called for whole classname
Reply With Quote #4

Man that must not be a real problem. Just check amount of entities that exists and return if already have the necessary ents.
__________________
Jhob94 is online now
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-12-2014 , 07:36   Re: how to prevent registerhamfromentity being called for whole classname
Reply With Quote #5

Why do you need this forward? Why you don't register with classname? Explain better, give a context.
__________________
Arkshine is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 11-12-2014 , 08:58   Re: how to prevent registerhamfromentity being called for whole classname
Reply With Quote #6

Quote:
Originally Posted by Arkshine View Post
Why do you need this forward? Why you don't register with classname? Explain better, give a context.
I think he is registering with classname, the problem is that there is more than 1 entity with same classname so it revives 2 times. Verify the amount of entities and return if is complete is a good option.
__________________
Jhob94 is online now
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 11-12-2014 , 10:35   Re: how to prevent registerhamfromentity being called for whole classname
Reply With Quote #7

Hamsandwich registers callbacks on entity classes, always. RegisterHamFromEntity gets the virtual table from an entity, but still registers the callback on the whole class of that entity. Registering a Ham callback on a single entity is not possible, and you have to do such filtering in your plugin code. Registering from two different entities that have the same class will register two callbacks onto that class, and as such the callback will be called twice. All of this is expected with the design of Hamsandwich.
__________________
In Flames we trust!
Nextra is offline
avril-lavigne
Banned
Join Date: Apr 2009
Old 11-12-2014 , 19:18   Re: how to prevent registerhamfromentity being called for whole classname
Reply With Quote #8

thanks, I will make different classes for both ents . [solved]
__________________
VDS in Europe 1 gb/s unmetered.Any configurations.
I accept Paypal, Moneybookers,etc
avril-lavigne 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 17:35.


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