18.02.2013, 15:08
Humm no, i know.
My script its...
My problem its when a player has a weapon rapid(MP5,AK, other...) the script doesnt have the time for check the Heal/Armor and recover sometimes the heal or armor, MP2 as explained.
Someone found a solution?
My script its...
PHP код:
switch(weaponid)
{
case 15: amount = 12;
case 5: amount = 12;
case 22: amount = 18;
case 28: amount = 8;
case 29: amount = 10;
case 32: amount = 9;
case 33: amount = 40;
case 34: amount = 50;
}
armour = armour - amount;
if(armour < 0.0)
{
health += armour;
if(health <= 0.0)
{
health = 0.0;
}
armour = 0.0;
}
SetPlayerHealth(playerid, health);
SetPlayerArmour(playerid, armour);
Quote:
Introduction
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?! |
Quote:
I just did some basic testing and it turns out my theory was (unfortunately) correct. OnPlayerUpdate isn't called between every call of OnPlayerGive/TakeDamage. I'm still not sure if the health/armour are synced separately to OPU though, more testing is needed. It should be okay for any damage apart from fire (which removes health faster than OPU!).
I don't really want to hook OPU though, so I may just store players' health in two arrays and deduct the health/armour loss manually instead of relying on the syncing. But then again, some factors (which I can't think of right at this moment) may interfere such as vending machines. I will leave this how it is for now, as it only affects (I think) fire. |