Problem mixing up two things in a if function
#4

Yes, it would work. However, you're creating unnecessary variables where you don't need them, and too much cell size.

A shorter more efficient version would be:
pawn Код:
if(strcmp("/heal", cmdtext, true) == 0)
    {
        new Float:Health;
        GetPlayerHealth(playerid, Health);
        if(Health < 50.0) return SendClientMessage(playerid, 0xD10000FF, "You are too low on health to heal yourself!");
        new cash = GetPlayerMoney(playerid);
        if(cash < 1000)
        {
            new str[90];
            format(str, sizeof(str), "You haven't got enough money to heal yourself (Your money: $%d Needed: $1000)", cash);
            return SendClientMessage(playerid, 0xD10000FF, str);
        }
        SetPlayerHealth(playerid, 100.0);
        SendClientMessage(playerid, 0x009900FF, "You have healed yourself for $1000!");
        GivePlayerMoney(playerid, -1000);
        return 1;
    }
Reply


Messages In This Thread
Problem mixing up two things in a if function - by Amsterdam - 13.03.2014, 19:59
Re: Problem mixing up two things in a if function - by Matess - 13.03.2014, 20:09
Re: Problem mixing up two things in a if function - by RenSoprano - 13.03.2014, 20:10
Re: Problem mixing up two things in a if function - by Threshold - 13.03.2014, 23:24

Forum Jump:


Users browsing this thread: 1 Guest(s)