Health / Armour addition
#1

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!
Reply
#2

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;
}
Reply
#3

SetPlayerArmour(playerid, +amount);

Edit: Sick beat me to it :P
Reply
#4

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?
Reply
#5

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;
}
Reply
#6

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!
Reply
#7

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


Forum Jump:


Users browsing this thread: 2 Guest(s)