Server sided health & armour
#1

Hey guys, I am scripting an Anti GodMode along with an Assists system, so I tried to make the HP&AP server sided, although, for example if I have those variables:
PHP код:
new Float:Health[MAX_PLAYERS];
new 
Float:Armour[MAX_PLAYERS]; 
And I am using
PHP код:
public OnPlayerGiveDamage(playeriddamagedidFloat:amountweaponidbodypart
Since amount = health & armour
How can I know where to start reducing health if I don't know where the armour is lost ?
That's the code I am planning to script
PHP код:
public OnPlayerGiveDamage(playeriddamagedidFloat:amountweaponidbodypart)
{
    
// Here the health & armour are reduced from the array
    
new Float:hpFloat:ap;
    
GetPlayerHealth(playeridhp);
    
GetPlayerArmour(playeridap);
    if(
Health[playerid] != hp || Armour[playerid] != ap) return AddBan(playeridRPN(playerid), "Anti Cheat""Health Hacking"RPIP(playerid));
    return 
1;

How can I detect if the armour is gone and start reducing HP ?
Reply
#2

I guess you want to do it like this?
Код:
if (Armour[playerid] > amount) Armor[playerid] -= amount;
else if (Armour[playerid])
{
    amount - Armour[playerid];

    Armour[playerid] = 0.0;

    if (amount)
    {
        if (Health[playerid] > amount) Health[playerid] -= amount;
        else Health[playerid] = 0.0;
    }
}
else if (Health[playerid] > amount) Health[playerid] -= amount;
else Health[playerid] = 0.0;
That will work just like the default damages. I got a similiar thing in my script as well. :P
Reply
#3

Quote:
Originally Posted by GoldenLion
Посмотреть сообщение
I guess you want to do it like this?
Код:
if (Armour[playerid] > amount) Armor[playerid] -= amount;
else if (Armour[playerid])
{
    amount - Armour[playerid];

    Armour[playerid] = 0.0;

    if (amount)
    {
        if (Health[playerid] > amount) Health[playerid] -= amount;
        else Health[playerid] = 0.0;
    }
}
else if (Health[playerid] > amount) Health[playerid] -= amount;
else Health[playerid] = 0.0;
That will work just like the default damages. I got a similiar thing in my script as well. :P
Took me a few moments to realize and understand everything, exactly what I needed, thank you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)