05.07.2014, 13:06
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);
}
}
}

