OnPlayerDeath help
#1

my player death message:
PHP код:
    format(stringsizeof(string), "%s (%d) Has Been Killed By %s (%d) - %s"PlayerInfo[playerid][pName], playerid PlayerInfo[killerid][pName], killeridwepname);
    
SendClientMessageToAll(COLOR_DEATHstring); 
what ineed to add ? // body parts and meters away.
Reply
#2

pls help me
Reply
#3

The distance is quite easy to calculate.

You get the position of one player (either of them) and then use GetPlayerDistanceFromPoint between the other player and the coords you just retrieved.

To get the last hit bodypart you must keep track of the bodyparts a player gets injured by.

For this you'll need a global array (one slot per Player) and in OnPlayerGiveDamage you save the bodypart ID to the slot of the injured player. If you save it for the player inflicting the damage, it might happen that he hits another player before the killed player is actually dead for the server which may result in the wrong bodypart getting shown. Furthermore with weapons like Minigun you can kill many people quite fast and that might be too fast for the value to be correct in OnPlayerDeath.

Small example:

PHP код:
//The Array:
new LastInjuredBodypart[MAX_PLAYERS];
//In OnPlayerGiveDamage
LastInjuredBodypart[damagedid] = bodypart;
//In OnPlayerDeath
new bodypart LastInjuredBodypart[playerid]; // Retrieve it from playerid since it is saved for him, not killerid 
You might want to add a little check to the code in OnPlayerGiveDamage to prevent the code to execute if the damagedid is already dead (health <= 0.0) - sometimes the callback will still get called even if he is already dead (due to lag).

Read this for the bodypart descriptions.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)