[Tutorial] Custom Playerdamage system
#30

Quote:
Originally Posted by oMa37
View Post
Amazing one man, This helped me!

EDIT:

PHP Code:
public OnPlayerTakeDamage(playeriddamagedidFloatamountweaponidbodypart)
// playerid = The person that gave the damage.
// damagedid = The player that got damaged.
// Float: amount = The amount of damage given.
// weaponid = The weapon ID that dealt the damage.
// bodypart = The bodypart that was hit. 
Isn't this must be OnPlayerGiveDamage?
Whoops, fixed.

Quote:
Originally Posted by Manyula
View Post
Hm, maybe a couple of suggestions for you to consider:
1. You should also include armor since the current version will only work with the standard health bar.
2. As far as I know, you can't set a player's health to an exact floating point value which means that in this case it is slightly inaccurate. Declare the player's health and armor globally, then check for the last value of the respective variable and set the new value right into it. Lastly, set the player's health to that specific value. The function itself will set the health to a rounded integer value, so the HP bar might be slightly off, but the variables that store the health and armor are always accurate.

Let me give you an example of what your implementation does:
- A player has 49.50 health
- The player receives 49.01 damage
- SetPlayerHealth tries to set the health of that particular player to 0.49. However, it rounds the damage up to 50.0 damage, which means that the player would have actually survived that hit, but SetPlayerhealth chose to kill him right away.
Armour is just the same as health, just that you put it under "default" in the switch, as i explained in the last line:
Quote:

And then you do the same under "default", just change SetPlayerHealth to SetPlayerArmour, and health - (value) to armour - (value).

And infact i think he would be left with 0.99 health in your example, since GetPlayerHealth rounds the health, while SetPlayerHealth does not.
Atleast that's what it said on the wiki, but even if SetPlayerHealth rounds too, the player would need to receive 49.5 damage to round up to 50.

But if you want to be that accurate you can, it wouldn't differ more than 0.5 at most though.
Reply


Messages In This Thread
Custom Playerdamage system - by CalvinC - 19.01.2015, 12:17
Re: Custom Playerdamage system - by Rudy_ - 19.01.2015, 13:24
Re: Custom Playerdamage system - by nezo2001 - 19.01.2015, 13:29
Re: Custom Playerdamage system - by PaulDinam - 20.01.2015, 05:06
Re: Custom Playerdamage system - by CalvinC - 22.01.2015, 08:47
Re: Custom Playerdamage system - by JaydenJason - 11.02.2015, 14:20
Re: Custom Playerdamage system - by Lordzy - 11.02.2015, 14:26
Re: Custom Playerdamage system - by CalvinC - 12.02.2015, 19:29
Re: Custom Playerdamage system - by JaydenJason - 17.02.2015, 16:18
Re: Custom Playerdamage system - by ZombieNest - 17.02.2015, 16:51
Re: Custom Playerdamage system - by kamiliuxliuxliux - 17.02.2015, 17:33
Re: Custom Playerdamage system - by CalvinC - 17.02.2015, 20:31
Re: Custom Playerdamage system - by De4dpOol - 20.02.2015, 08:24
Re: Custom Playerdamage system - by AndySedeyn - 20.02.2015, 09:16
Re: Custom Playerdamage system - by Cookland - 23.02.2015, 21:34
Re: Custom Playerdamage system - by Antoniohl - 24.02.2015, 09:28
Re: Custom Playerdamage system - by MikE1990 - 27.02.2015, 13:54
Re: Custom Playerdamage system - by rappy93 - 22.09.2015, 16:54
Re: Custom Playerdamage system - by Tamer - 22.09.2015, 21:49
Re: Custom Playerdamage system - by karemmahmed22 - 23.09.2015, 10:41
Re: Custom Playerdamage system - by Colonel - 24.09.2015, 19:41
Re: Custom Playerdamage system - by ahameed4755 - 24.09.2015, 19:59
Re: Custom Playerdamage system - by CalvinC - 29.09.2015, 15:45
Re: Custom Playerdamage system - by Slaughters - 21.04.2016, 19:31
Re: Custom Playerdamage system - by Micko123 - 27.04.2016, 10:49
Re: Custom Playerdamage system - by N0FeaR - 28.04.2016, 14:14
Re: Custom Playerdamage system - by CalvinC - 28.04.2016, 15:39
Re: Custom Playerdamage system - by oMa37 - 28.04.2016, 16:38
Re: Custom Playerdamage system - by Manyula - 29.04.2016, 13:29
Re: Custom Playerdamage system - by CalvinC - 29.04.2016, 15:20
Re: Custom Playerdamage system - by Manyula - 01.05.2016, 19:58
Re: Custom Playerdamage system - by oSAINTo - 15.08.2016, 22:26
Re: Custom Playerdamage system - by oSAINTo - 16.08.2016, 02:28
Re: Custom Playerdamage system - by GameOvr - 18.06.2018, 15:55

Forum Jump:


Users browsing this thread: 1 Guest(s)