Jump to content
RAGE Multiplayer Community

Help regarding PlayerDamage & hasBeenDamagedBy


Recommended Posts

Hello guys,
I used to make some simple scripts on SAMP/MTA and I would like you to take a look at those two events :

http://wiki.sa-mp.com/wiki/OnPlayerTakeDamage
https://wiki.multitheftauto.com/wiki/OnPlayerDamage

As you can see when someone gets injured we get interesting parameters such as the player that caused the damage and the weapon that he used.
I would like to get the same infos on RAGE:MP (when a player gets injured I want to know who is the other player that injured him).

From what I understand I will have to play around with those two things :
https://wiki.rage.mp/index.php?title=PlayerDamage
https://wiki.rage.mp/index.php?title=Entity::hasBeenDamagedBy
But to be honest I have no clue how to use hasBeenDamagedBy, and it also looks like PlayerDamage is a server side-event and hasBeenDamagedBy is a client-side function so there are some tricky stuff to do to make them work together and I have no clue how to do it.

It would have been nice if there was an "attacker" parameter in the PlayerDamage event, just like PlayerDeath has a "killer" parameter.
Some help regarding what I want to achieve would be very nice !

Thank you ! ^_^

Link to post
Share on other sites
  • 3 weeks later...

Sup,

i would consider rage mp's PlayerDamage event more like some kind of 'PlayerHealthChange' event. It is emitted when players health decreases. There is an idea to be tested(i am not sure if available functions work) once PlayerDamage triggered

  • entity.hasBeenDamagedBy(entity2, p2);  - cycle through all players/vehicle entities used by players eventually and try to find entity that damaged the player for who is PlayerDamage event triggered
  • player.getLastDamageBone(outBone); - optionally get last damaged bone

and work with obtained data, then always clear damage data with these:

  • player.clearLastDamageBone();
  • entity.clearLastDamage();

 

This is just an idea how you could achieve this, i do not have time to test it in game currently. Good luck

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...