Question: OnPlayerTakeDamage -
Maxips2 - 08.04.2013
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.
Re: Question: OnPlayerTakeDamage -
Jstylezzz - 08.04.2013
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.
Re: Question: OnPlayerTakeDamage -
Maxips2 - 08.04.2013
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.
Re: Question: OnPlayerTakeDamage -
Jstylezzz - 08.04.2013
As those do inflict damage on the player, I do believe it's called in these situations.
Re: Question: OnPlayerTakeDamage -
Riddick94 - 08.04.2013
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.
Re: Question: OnPlayerTakeDamage -
dusk - 08.04.2013
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.
Re: Question: OnPlayerTakeDamage -
Jstylezzz - 08.04.2013
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.
Re: Question: OnPlayerTakeDamage -
Maxips2 - 08.04.2013
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.
Re: Question: OnPlayerTakeDamage -
Jstylezzz - 08.04.2013
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 : )
Re: Question: OnPlayerTakeDamage -
Maxips2 - 08.04.2013
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!