AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Change suicide to regular kill (https://forums.alliedmods.net/showthread.php?t=163600)

B3N4K 08-01-2011 05:23

Change suicide to regular kill
 
Hello,

I tried to search, but i didn't found any specific way how to change suicide to regular kill. I mean lets say i have a plugin that poison enemy when he gets shot. And then it takes him 3 HP/s. And when it reaches zero he just die.

In death messages it shows up like suicide etc. But i want it to show like kill (show name who killed him and give him frag).

Thanks for help!

Hunter-Digital 08-01-2011 06:54

Re: Change suicide to regular kill
 
The plugin must store the killer and then parse it into the deathmsg or to the function that deals the damage.

Show your code if you want real help.

fysiks 08-01-2011 08:06

Re: Change suicide to regular kill
 
I think I would execute ham_takedamage when damage is given to the victim with the killer's id as attacker (and probably inflictor). That way, the killer get's teh kill.

B3N4K 08-01-2011 11:45

Re: Change suicide to regular kill
 
Hunter-Digital: Sorry but i don't have any code yet. Thats what i am asking for ;-)

fysiks: Thanks
So it should look like this?
Code:

g_player_killed_by[MAXPLAYERS+1] = 0;
RegisterHam("Ham_TakeDamage", "player", "event_player_damage");

public event_player_damage(victim, inflictor, attacker, dmg, dmgbits)
{
  if (g_player_killed_by[victim] != 0) //if this is takedmg that kills user, change attacker id
  {
    setHamParamInteger(3,
g_player_killed_by[victim]);
   
g_player_killed_by[victim] = 0;
  }
}

public doPoison(id, attacker)
{
  if (is_user_alive(id))
  {
    new health, args[2];
    health =
get_user_health(id);
    if (health-3 <= 0) // If this is takedmg that kills user, tell event_player_damage to change attacker
    {
      g_player_killed_by[id] = attacker;
    }
    set_user_health(id, (health-3));
    args[0] = id;
    args[1] = attacker;
    set_task(1.0, "doPoison", id, args, 1);
  }
}

Or do i have to do something with executeHam(Ham_TakeDamage, ... ... ? ??) ? I Never worked with executeHam, so if it is necessary to do this this way where can i find some documentation?

Hunter-Digital 08-01-2011 11:59

Re: Change suicide to regular kill
 
If you're making it, you don't need to store the attacker then if you'll use ExecuteHam().
Input for ExecuteHam() is like the callback's inputs:
Quote:

event_player_damage(victim, inflictor, attacker, dmg, dmgbits)
Those beeing Ham_TakeDamage's params, ExecuteHam would be:
Code:

ExecuteHam(Ham_TakeDamage, victim, inflictor, attacker, 3.0, DMG_POISON)
You should look into ham_const.inc for future ham related hooks.

Also your "doPoison" is not called by anything... and registering Ham_TakeDamage doesn't really do anything there, unless that's the way you're triggering poison, but I can't see it be called.

B3N4K 08-01-2011 12:08

Re: Change suicide to regular kill
 
Oh i see. Thank you very much for your help ;-)

PS: doPoison is not called because it was there just for demonstration. It will be part of greater plugin ;-)
And about Ham_TakeDamage - i thought that it's triggered when i use set_user_health, but it really doesn't make sense (i am setting user's health, not dealing damage to him, so really no reason to trigger ham_takedamage) :-D

Thank you very much ;-)

B3N4K 08-01-2011 12:32

Re: Change suicide to regular kill
 
Last question: What should inflictor be? :-)

drekes 08-01-2011 14:51

Re: Change suicide to regular kill
 
Inflictor is the entity that caused the damage. Like a weapon or another entity (Damage block in bm for example)

Exolent[jNr] 08-01-2011 15:09

Re: Change suicide to regular kill
 
Quote:

Originally Posted by drekes (Post 1523564)
Inflictor is the entity that caused the damage. Like a weapon or another entity (Damage block in bm for example)

If it is a gun, then the inflictor is the same as the attacker.

B3N4K 08-01-2011 15:22

Re: Change suicide to regular kill
 
So what should it be if i want to show skull image in deathmsg? I knew that all you wrote, but i don't know what should it be now.. Because he wasn't killed by any weapon.. Or by any other entity.. He just died because of "poison"..


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

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