[Include] [BETA] OnPlayerGive/TakeDamage Health/Armour loss reporting
#1

Introduction
This include reports the amount of health and armour lost to OnPlayerGive/TakeDamage. In the default callback it's just 'amount' which is just the amount of damage - it doesn't tell you how much health or armour was lost.

All you need to do is use the new callbacks, with 'Ex' added at the end (and new parameters of course):

pawn Код:
public OnPlayerTakeDamageEx(playerid, issuerid, Float:healthloss, Float:armourloss, weaponid)
{
    // Stuff
}

public OnPlayerGiveDamageEx(playerid, damagedid, Float:healthloss, Float:armourloss, weaponid)
{
    // Stuff
}
NOTE: It's armour, not armor; I'm British!

I made this at like 4AM so it may not be perfect. I went through many (at least 5) different systems before I found one that worked perfectly, and here it is. I have no idea if there's a better way; believe me I tried. I figured it'd just be a bit of simple maths, not requiring any variables, but I was under the assumption that if they took more damage than health they didn't have, they lost armour, but then I realised they could have < 100 health and still have armour (i.e. they took damage to the health THEN got armour).

You may be thinking 'why not just save their old armour AND health, then use GetPlayerHealth + GetPlayerArmour under OnPlayerGive/Take damage to see what was lost? Well. GetPlayerHealth/Armour doesn't work under OnPlayerGive/TakeDamage because they don't sync with the server until the next OnPlayerUpdate call, which would involve pretty much the same amount of code as this did, but you'd have to have a variable to store their health also. Why waste memory?!

This is also well commented so you can figure out my thought process.

DOWNLOAD: http://pastebin.com/jvFZFEqv

Known Issues:
- Players lose 3 health on spawn for some reason. SA:MP bug most likely.
- If a player has 5 health and are shot with a gun that does 10 damage, the healthloss is reported as 10, not 5 (as it should be IMO).
- When players have armour and lose health (i.e. falling and hitting the ground or on fire) it will report an armour loss, as if they were hit with a bullet.

Please report any issues.
Reply
#2

this is so nice man
Reply
#3

Cleverly done. Good work!
Reply
#4

What is different from this than wups.inc?

"- If a player dies instantly (such as suicide/explosions) their armour may be 'remembered' as being 100, so next time they take damage it will report an armour loss of 100. I'm not sure about this one as I forgot to test it (PC is off now)."

Can't you clear it OnPlayerDeath?
Reply
#5

I did search before releasing this to see if anything similar existed and found nothing at all. If you could link me I'd appreciate it.

Also, thanks for that idea. It was 4AM at the time!
Reply
#6

Quote:
Originally Posted by MP2
Посмотреть сообщение
I did search before releasing this to see if anything similar existed and found nothing at all. If you could link me I'd appreciate it.

Also, thanks for that idea. It was 4AM at the time!
https://sampforum.blast.hk/showthread.php?pid=937824#pid937824
Reply
#7

Wups himself clearly said that his OPSP was clearly outdated and it was scripted MUCH before OnPlayerTake/GiveDamage came into existence. You're comparing timers with hooking, ob...viously hooking will be FASTER because OPT/GD is called natively.
Reply
#8

What the the guy above me said: that is NOT using OnPlayerGive/TakeDamage.
Reply
#9

Quote:
Originally Posted by MP2
Посмотреть сообщение
What the the guy above me said: that is NOT using OnPlayerGive/TakeDamage.
Maybe so, but you did ask for similar stuff. So I posted it, no need to hate, appreciate.

Edit: Did you upload the fix when it clears when OnPlayerDeath is called?
Reply
#10

- Players lose 3 health on spawn for some reason. SA:MP bug probably. doubtful about this
- If a player has 5 health and are shot with a gun that does 10 damage, the healthloss is reported as 10, not 5 (as it should be IMO). Not sure how to go about fixing this, or if I need to. easy, if there health goes less than 0, then take it away the negative values, E.G if he has 5 health and it does 10 damage, then remove the -5 and make it 0 if you get what i mean
- If a player dies instantly (such as suicide/explosions) their armour may be 'remembered' as being 100, so next time they take damage it will report an armour loss of 100. I'm not sure about this one as I forgot to test it (PC is off now). if(newstate == PLAYER_STATE_WASTED) armour = 0;
- Setting armour in a filterscript may fuck things up probably hooks?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)