06.12.2017, 11:54
So, I'm trying to create a potency and endurance system. The rate of a player's potency affects his unarmed damage(fist) while the rate of a player's endurance affects how much damage is reduced from getting hit from unarmed damage(fist). I was getting through complex(at least it is for me) lines of code, and I kinda got lost while doing it. Am I doing it right or...?
PHP код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
if(PlayerInfo[issuerid][Potency] >= 10 && weaponid == 0)
{
new Float:damage, Float:currenth;
damage = PlayerInfo[issuerid][Potency]+5;
if(PlayerInfo[playerid][Endurance] >= 10 && weaponid == 0)
{
new Float:health, Float:curhealth;
health = PlayerInfo[playerid][Endurance]+5-damage;
GetPlayerHealth(playerid, curhealth);
SetPlayerHealth(playerid, curhealth+health);
}
else
{
GetPlayerHealth(playerid, currenth);
SetPlayerHealth(playerid, (currenth+amount)-damage);
}
}
else
{
if(PlayerInfo[playerid][Endurance] >= 10 && weaponid == 0)
{
new Float:health, Float:curhealth;
health = PlayerInfo[playerid][Endurance]-5;
GetPlayerHealth(playerid, curhealth);
SetPlayerHealth(playerid, curhealth+health);
}
}
return 1;
}