SA-MP Forums Archive
Health / Armour addition - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Health / Armour addition (/showthread.php?tid=603991)



Health / Armour addition - eikzdej - 30.03.2016

Hi! How can i make a script like this? For example, I have 10 Remaining Armour, then i buy 50 Additional armour from Ammunition, how can i make it become to 60? instead of 50, because in SetPlayerArmour(playerid, 50), it will set your armour to 50 even you have 100 Armour. And also, if i have 90 Armour, then i buy 50 armour, it will add only 10 to your armour.

Thanks!


Re: Health / Armour addition - SickAttack - 30.03.2016

Use "GivePlayerArmour(playerid, 10.0);" and it will give the player 60.0 armour if the player has 50.0 armour.
pawn Код:
stock GivePlayerArmour(playerid, Float:armour)
{
    new Float:current_armour;
    GetPlayerArmour(playerid, current_armour);

    SetPlayerArmour(playerid, (current_armour + armour));
    return 1;
}



Re: Health / Armour addition - itsCody - 30.03.2016

SetPlayerArmour(playerid, +amount);

Edit: Sick beat me to it :P


Re: Health / Armour addition - eikzdej - 30.03.2016

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
Use "GivePlayerArmour(playerid, 10.0);" and it will give the player 60.0 armour if the player has 50.0 armour.
pawn Код:
stock GivePlayerArmour(playerid, Float:armour)
{
    new Float:current_armour;
    GetPlayerArmour(playerid, current_armour);

    SetPlayerArmour(playerid, (current_armour + armour));
    return 1;
}
So if i have a limit of only 100 armour, then i have currently 60 armour, if i use this command, it will not over my limit?


Re: Health / Armour addition - SickAttack - 30.03.2016

It's not a command... Anyway, here:
pawn Код:
stock GivePlayerArmour(playerid, Float:armour)
{
    new Float:current_armour;
    GetPlayerArmour(playerid, current_armour);

    if((current_armour + armour) > 100.0)
    {
        current_armour = 100.0;
        armour = 0.0;
    }

    SetPlayerArmour(playerid, (current_armour + armour));
    return 1;
}



Re: Health / Armour addition - eikzdej - 30.03.2016

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
It's not a command... Anyway, here:
pawn Код:
stock GivePlayerArmour(playerid, Float:armour)
{
    new Float:current_armour;
    GetPlayerArmour(playerid, current_armour);

    if((current_armour + armour) > 100.0)
    {
        current_armour = 100.0;
        armour = 0.0;
    }

    SetPlayerArmour(playerid, (current_armour + armour));
    return 1;
}
Thanks!


Re: Health / Armour addition - iKevin - 30.03.2016

That's the stock, now you shall use GivePlayerArmour in your command. I can do it for you, if you want.