AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Ham_TakeDamage Pre issues (https://forums.alliedmods.net/showthread.php?t=233283)

striker07 01-12-2014 13:31

Ham_TakeDamage Pre issues
 
I got a lil problem with this when i try to ignore the damage dealt to the victim, using SetHamParamFloat(4, 0.0) doesnt work, all normal damage is still being performed so then i tried to change the attackerid to the victimid so that zombie plague could not process this whole event as a possible infection. but this doesnt work neither.
Is it possible to change the damagebits to DMG_FALL and change the attackerid to the victimid? unless some1 can see why the damage would still be the normal damage, i dont see any other options.

Also the hamhook is not being executed on bots

PHP Code:

public plugin_init()
{
 
RegisterHam(Ham_TakeDamage"player""player_hurt_pre")
}
public 
player_hurt_pre(victiminflictorattackerFloat:damage)
{
 if( 
attacker <= || !pev_valid(attacker) || victim == attacker || !is_user_connected(attacker))
 {
  return 
HAM_IGNORED
 
}
 
 
//client_print(attacker, print_chat, "playerhurt_pre called, vic: %i & att: %i, vic zombie: %i, vic survivor: %i", victim, attacker, zp_get_user_zombie(victim), zp_get_user_survivor(victim))
 
new uspid get_weaponid("weapon_usp")
 new 
attweaponid get_user_weapon(attacker)
 
client_print(attackerprint_chat"good here 9, you need: %i, you have: %i"uspidattweaponid)
  
 if((
attweaponid == CSW_USP) && zp_get_user_zombie(attacker) )
 {
  
SetHamParamFloat(40.0)
  if ( !
zp_get_user_zombie(victim) && !zp_get_user_survivor(victim))
  {
   new 
cl_name[46]
   
get_user_name(victimcl_namesizeof(cl_name))
    
   
client_print(attackerprint_chat"good here 9.2, bool: %i, your zombie class: %i, you need: %i"g_bHas_T_pistol[attacker], zp_get_user_zombie_class(attacker), g_zclass_cell)
   
   if( 
g_bHas_T_pistol[attacker] && zp_get_user_zombie_class(attacker) == g_zclass_cell) )
   {
    
client_print(attackerprint_chat"good here 10")
    if( 
g_bHasImmunity[victim] )
    {
     
client_print(victimprint_chat"[ZP] Your Immunity against sleeper cell mutagens has succesfully warded off a mutagen attack.")
     
client_print(attackerprint_chat"[ZP] %s has immunity against your sleeper cell mutagens"cl_name)
     return 
HAM_SUPERCEDE
    
}
    
    if( !
task_exists(victim TASK_CHECKHITS) )
    {
     
set_task(3.0"Check_vichits",victim TASK_CHECKHITS)
    }
    
g_Thits[victim]++
    
g_Thitsattacker[victim] = attacker
        
    client_print
(attackerprint_chat"[ZP] Your T-Virus cell has hit %s, total hits on this player: %i"cl_nameg_Thits[victim])
   
   }
  }
  
SetHamParamInteger(3victim)
  return 
HAM_SUPERCEDE
 
}
 
 return 
HAM_HANDLED



NiHiLaNTh 01-12-2014 14:34

Re: Ham_TakeDamage Pre issues
 
for bots you have to use RegisterHamFromEntity

ConnorMcLeod 01-13-2014 01:17

Re: Ham_TakeDamage Pre issues
 
If you want that another plugin than the one you are showing can detect that your plugin has blocked the function, then you have to declare your plugin before the second one in plugins.ini

And in the other plugin (main ZP plugin from what i understand), you have to check the return status when the forward is called

if( GetHamReturnStatus() == HAM_SUPERCEDE ) return;

Something like that.



Also, in your code, 1st return should be HAM_IGNORED (you don't do anything), seconde return is correct (you want to block damage), and last return should be HAM_HANDLED (you have changed something but you don't want to block).

striker07 01-13-2014 11:23

Re: Ham_TakeDamage Pre issues
 
Quote:

Originally Posted by NiHiLaNTh (Post 2085043)
for bots you have to use RegisterHamFromEntity

in client_authorized forward right?

Quote:

Originally Posted by ConnorMcLeod (Post 2085203)
If you want that another plugin than the one you are showing can detect that your plugin has blocked the function, then you have to declare your plugin before the second one in plugins.ini

so zombie_plague.amxx should come after my zombieclass in plugins.ini, that wont give problems?

Quote:

Originally Posted by ConnorMcLeod (Post 2085203)
And in the other plugin (main ZP plugin from what i understand), you have to check the return status when the forward is called

if( GetHamReturnStatus() == HAM_SUPERCEDE ) return;

Something like that.

But I am using a forward from hamsandwich, not a forward from ZP so how can i do that?
In Ham_TakeDamage pre hook from zombieplague? will the main zp be able to pick up on the returned value from my zombieclass because my class loaded first, then zp?


Quote:

Originally Posted by ConnorMcLeod (Post 2085203)
Also, in your code, 1st return should be HAM_IGNORED (you don't do anything), seconde return is correct (you want to block damage), and last return should be HAM_HANDLED (you have changed something but you don't want to block).

Ok ill try to keep that in mind. but when the forward comes from a custom plugin, the coder should still implement the possible return vallues to act on them? the return vallues are not by default in every plugin if it uses hamsandwich?

Thanks for the help so far guys

striker07 01-13-2014 20:27

Re: Ham_TakeDamage Pre issues
 
I did what you said connor and everything works now, also thanks to your ham_register_czbots plugin you gave me a while ago the ham is also being activated for bots, everything finnally works as it should.
thanks for the help !


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

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