Amount of drugs to buy
#5

pawn Код:
stock IsNumeric(const string[])
{
    new i;
    while(string[i] != '\0') //end of string
    {
        if (string[i] > '9' || string[i] < '0'){return 0;}
        i++;
    }
    return 1;
}
// OnDialogResponse
if(dialogid == DRUG_SHOP_MENU && response == 1)
{
    if(strlen(inputtext) <= 0) { ShowPlayerDialog(playerid, DRUG_SHOP_MENU, DIALOG_STYLE_INPUT,"Buy drugs","Enter the amount of grams you would like to buy:","Buy","Close"); }
    else if(!IsNumeric(inputtext)) { ShowPlayerDialog(playerid, DRUG_SHOP_MENU, DIALOG_STYLE_INPUT,"Buy drugs","Enter the amount of grams you would like to buy:","Buy","Close"); }
    else
    {
        new
            str[128],
            amount = strval(inputtext),
            cash = amount * 1000;
        if(GetPlayerCash(playerid) < cash) { ShowPlayerDialog(playerid, DRUG_SHOP_MENU, DIALOG_STYLE_INPUT,"Buy drugs","Enter the amount of grams you would like to buy:","Buy","Close"); }
        else
        {
            GivePlayerCash(playerid, - cash);
            format(str, sizeof(str), "You bought %d grams of drugs for %d $", amount, cash);
            SendClientMessage(playerid, -1, str);
        }
    }

}
Reply


Messages In This Thread
Amount of drugs to buy - by friezakinght - 05.07.2014, 12:49
Re: Amount of drugs to buy - by BroZeus - 05.07.2014, 12:55
Re: Amount of drugs to buy - by friezakinght - 05.07.2014, 12:59
Re: Amount of drugs to buy - by friezakinght - 05.07.2014, 13:04
Re: Amount of drugs to buy - by rickisme - 05.07.2014, 13:06
Re: Amount of drugs to buy - by friezakinght - 05.07.2014, 13:29

Forum Jump:


Users browsing this thread: 1 Guest(s)