ULX

Author Topic: PlayerDeath for multiple kills  (Read 1859 times)

0 Members and 1 Guest are viewing this topic.

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
PlayerDeath for multiple kills
« on: July 11, 2017, 04:37:54 PM »

In one of my addons I'm currently writing, I'm trying to figure out how to use the GM:PlayerDeath hook to figure out if someone kills multiple people at once (like a C4 in TTT). However, I'm not quite sure how to go about doing this, as to my knowledge this hook only passes one victim and one attacker through each time, not multiple, even if the hook is called multiple times. In my function that this hook calls, I am tracking the amount of kills that a person gets during each round, so I was thinking of using a Think hook or some other timer to see if this number changes drastically at one point, but I'm wondering if there's another way to do this?
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: PlayerDeath for multiple kills
« Reply #1 on: July 11, 2017, 06:23:03 PM »
What I would do is inside the PlayerDeath hook, store the last kill time on the killer. Then if it gets run again very quickly you can check CurTime vs the last kill time and if it's say... less than 0.5 seconds or whatever you can increment a counter.

If you want it to announce or something, you can create a timer when a player kills someone and just remove and overwrite the timer each time the player kills someone. The timer would only need to be about 1 second to catch all the kills inside your 0.5 second window.

I hope this made sense. It does in my head. :D

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: PlayerDeath for multiple kills
« Reply #2 on: July 11, 2017, 07:00:35 PM »
Yes that actually does make sense. Basically I'm writing an experience addon so you can get levels, xp, things like that, and a mass kill (4 or more kills, configurable) is what I'm trying to see, if someone gets that amount of kills or more at once, they can get bonus xp
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: PlayerDeath for multiple kills
« Reply #3 on: July 11, 2017, 10:57:01 PM »
Hm, now that I think about it I don't think that'd work. For things like C4/Jihad, all the kills are instant, so I don't think there's any delay in-between them.
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: PlayerDeath for multiple kills
« Reply #4 on: July 12, 2017, 01:26:25 AM »
You'd have to do some testing.. but even though they're all killed simultaneously, I'm pretty sure the hooks would be called sequentially. I don't think lua is threaded in the sense that it could call multiple PlayerDeath hooks at the exact same time.

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: PlayerDeath for multiple kills
« Reply #5 on: July 12, 2017, 02:12:54 AM »
Yeah I guess that would be the case. Even the slightest difference would still be a difference... I'll try it out.
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.