Author Topic: Detecting Attacker  (Read 836 times)

Is there a function for when a player kills another player?
Or if not, it should be possible to detect the attacker when a player dies, correct?
Basically, how would I manipulate an attacker when he kills a player?

I have this in Block City.

The function I packaged is:
function GameConnection::onDeath(%killedUser, %b, %userKiller, %d, %e)

This function will also detect if you killed yourself by relaying the userKiller as the killedUser. Be sure to check for that if you don't want something like that from happening.

K, thanks. What are %b, %d, and %e arguments?

are you gonna use this for a city rp?(if so then it would be cool if the cops were alerted when someone died so that they could get the guy)

are you gonna use this for a city rp?(if so then it would be cool if the cops were alerted when someone died so that they could get the guy)
No, this is for my medieval RPG, to receive experience when you kill someone if your a warrior.

GameConnection::onDeath(%this,%sourceObject,%sourceClient,%damageType,%damageArea)

This - player who died
Source Object - projectile or player who killed you
Source Client - client who killed you
Damage Type - type of damage that killed you
Damage Area - "Body". All the time, for some reason.

Deaths by falling damage have no source object. Use this to detect the "X [slam] Y" deaths caused by shooting a rocket near somebody's feet and blasting them into a wall for a kill:
Code: [Select]
if(isObject(%player.lastpusher))
{
   if(%player.lastpushtime - getSimTime() < 1000)
      //player was thrown into a wall by someone
   else
      //player was thrown by someone, but too long ago to count as a kill
}
else
{
   //player crashed into wall on his own
}

To stop all damage to a target, package/edit minigameCanDamage(%obj1,%obj2). Look at Team Deathmatch for an example, I detect various kinds of attacks and prevent team damage if Friendly Fire is off.

Awesome, thanks Space Guy.