24.09.2015, 19:41
I'm new to this scripting, okay I see all of these codes but how to add them to my script? just copy & paste them under each other? please help.
I'm new to this scripting, okay I see all of these codes but how to add them to my script? just copy & paste them under each other? please help.
|
error 025: function heading differs from prototype
public OnPlayerTakeDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
// 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.
Amazing one man, This helped me!
EDIT: PHP Code:
|
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. |
And then you do the same under "default", just change SetPlayerHealth to SetPlayerArmour, and health - (value) to armour - (value). |
Armour is just the same as health, just that you put it under "default" in the switch, as i explained in the last line.
|
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. |