Question: OnPlayerTakeDamage
#1

I was wondering in which cases OnPlayerTakeDamage is being called, perhaps you guys can help me get more information on that.

I know that it is being called whenever takes fall damage or gets shot at.
Reply
#2

Quote:
Originally Posted by SA-MP Wiki
This callback is called when a player takes damage.
As far as I can see on the wiki, it's called whenever the player takes damage. Falling, getting hit by a car, player hitting a player, player shooting a player, all that stuff. So, to answer your question, it is called by anything you can come up with to inflict damage on a player.
Reply
#3

Quote:
Originally Posted by Jstylezzz
Посмотреть сообщение
As far as I can see on the wiki, it's called whenever the player takes damage. Falling, getting hit by a car, player hitting a player, player shooting a player, all that stuff. So, to answer your question, it is called by anything you can come up with to inflict damage on a player.
What about nearby vehicle explosions? stepping into fire? grenade explosion? and so on...
I would test that IG but I don't really have the option to do it ATM.
Reply
#4

As those do inflict damage on the player, I do believe it's called in these situations.
Reply
#5

Quote:
Originally Posted by Maxips2
Посмотреть сообщение
What about nearby vehicle explosions? stepping into fire? grenade explosion? and so on...
I would test that IG but I don't really have the option to do it ATM.
Debug player health in OnPlayerTakeDamage and check your console is it get called or not. Probably, as callback says, it's getting called everytime when player gets a damage.
Reply
#6

well the way i think it works is: when the health of a player changed to something less that it was. The OnPlayerTakeDamage is called.
Reply
#7

Quote:
Originally Posted by dusk
Посмотреть сообщение
well the way i think it works is: when the health of a player changed to something less that it was. The OnPlayerTakeDamage is called.
This. I wonder.. I will test a few things and get back to this thread. I'm curious in which situations it's called.
Reply
#8

Quote:
Originally Posted by Jstylezzz
Посмотреть сообщение
As those do inflict damage on the player, I do believe it's called in these situations.
Quote:
Originally Posted by Riddick94
Посмотреть сообщение
Debug player health in OnPlayerTakeDamage and check your console is it get called or not. Probably, as callback says, it's getting called everytime when player gets a damage.
I will test that when I get the chance to.

Quote:
Originally Posted by dusk
Посмотреть сообщение
well the way i think it works is: when the health of a player changed to something less that it was. The OnPlayerTakeDamage is called.
It probably does work this way.

It actually makes me curious why has no one made a working health hack anti-cheat yet.

It could be done quite simply by making shooting synced (putting all players on the same team and dealing with damage on OnPlayerGiveDamage), disabling vending machines and updating a variable whenever health changes.


EDIT:

Quote:
Originally Posted by Jstylezzz
Посмотреть сообщение
This. I wonder.. I will test a few things and get back to this thread. I'm curious in which situations it's called.
If you do, please check suffocating in water as well.
Reply
#9

Alright, so I tested a few things, and I noticed the following:
  • When jumping out of a car while driving, it is not called
  • When drowning, it's called
  • When standing near an explosion (losing health), it's called
  • When on fire, it's called
  • When shot, it's called
  • When lowering the health with SetPlayerHealth, it's NOT called
I thought this was enough to see when OnPlayerTakeDamage is called. If you need any more tests now, ask me, since I have some free time : )
Reply
#10

Quote:
Originally Posted by Jstylezzz
Посмотреть сообщение
Alright, so I tested a few things, and I noticed the following:
  • When jumping out of a car while driving, it is not called
  • When drowning, it's called
  • When standing near an explosion (losing health), it's called
  • When on fire, it's called
  • When shot, it's called
  • When lowering the health with SetPlayerHealth, it's NOT called
I thought this was enough to see when OnPlayerTakeDamage is called. If you need any more tests now, ask me, since I have some free time : )
This one:
[*]When jumping out of a car while driving, it is not called

Did you lose any health when jumping out?
As far as I remember jumping out while driving (in GTA SA) doesn't give you any damage unless you do it from a high point and then you lose health from falling down.

About SetPlayerHealth it is quite obvious that it isn't being called.

This list actually surprised me a little bit, I didn't think that this callback is that effective!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)