+ & - Confusion
#1

Hello guys, so I'm trying to configure a code it, I'm asking you guys how do you detect for example like if you're decreasing the player's money, using
pawn Код:
GivePlayerMoneyEx(playerid, -5000);
and if you like increase the player's money you're using
pawn Код:
GivePlayerMoneyEx(playerid, 5000);
Since the +(plus) sign is already on the stock I made, does any one have an idea, like detecting the player's money if it is decrasing or increasing, this is a quick sketch or example of it

pawn Код:
stock GivePlayerMoneyEx(playerid, ammount)
{
    new string[24];
    OldMoney[playerid] = GetPlayerMoney(playerid);
    NewMoney[playerid] += ammount;
    GivePlayerMoney(playerid, ammount);

    //if it is +(plus) sign
    format(string, sizeof(string), "+%d", ammount);
    // else
    // if it is -(minus) sign
    format(string, sizeof(string), "-%d", ammount);
    GameTextForPlayer(playerid, string, 2000, 1);
    return 1;
}
Reply
#2

pawn Код:
if(ammount > 0) format(string, sizeof(string), "+%d", ammount);
else if(ammount < 0) format(string, sizeof(string), "-%d", ammount);
PS: I think it's spelled "amount".
Reply
#3

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
pawn Код:
if(ammount > 0) format(string, sizeof(string), "+%d", ammount);
else if(ammount < 0) format(string, sizeof(string), "-%d", ammount);
PS: I think it's spelled "amount".
Thanks about it tho', corrected the spellings too.

But.

pawn Код:
public OnPlayerDeath(...)
{
GivePlayerMoneyEx(playerid, -5000);
return 1;
}

//I'd rather use this
if(amount > 0) format(string, sizeof(string), "+%d", amount);
else if(amount < 0) format(string, sizeof(string), "%d", amount);
//since the function already gives a minus sign.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)