When to use 'else'...
#1

Can someone tell me when to use else for this situation I'm in.
Quote:

case 0:
{
SetPlayerFightingStyle(playerid, FIGHT_STYLE_BOXING);
GivePlayerMoney(playerid, -100);
SendClientMessage(playerid, COLOR_WHITE, "You've learnt Boxing!");
}

I want to use else so if they don't have enough money it will say "You don't have enough money!", please help.
Reply
#2

pawn Код:
case 0:
{
    if(GetPlayerMoney(playerid) < 100) return SendClientMessage(playerd, RED, "You don't have enough money!");
    SetPlayerFightingStyle(playerid, FIGHT_STYLE_BOXING);
    GivePlayerMoney(playerid, -100);
    SendClientMessage(playerid, COLOR_WHITE, "You've learnt Boxing!");
}
Or..

pawn Код:
case 0:
{
    if(GetPlayerMoney(playerid) > 100)
    {
        SetPlayerFightingStyle(playerid, FIGHT_STYLE_BOXING);
        GivePlayerMoney(playerid, -100);
        SendClientMessage(playerid, COLOR_WHITE, "You've learnt Boxing!");
    }
    else SendClientMessage(playerd, RED, "You don't have enough money!");
}
Reply
#3

Thanks a lot, repped.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)