18.03.2015, 03:12
I didn't test it, but here you go:
I'm pretty sure you can add the rest, just try!
pawn Код:
#define isnull(%1) ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
#define DIALOG_COINS 500
new pCoins[MAX_PLAYERS];
CMD:convert(playerid, params[]) return ShowCoinsDialog(playerid);
CMD:mycoins(playerid, params[])
{
new string[144];
format(string, sizeof(string), "You have %d coins!", pCoins[playerid]);
SendClientMessage(playerid, -1, string);
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_COINS)
{
if(!response) return 1;
else if(response)
{
if(isnull(inputtext) || !IsNumeric(inputtext)) return ShowCoinsDialog(playerid);
else
{
new coins = strval(inputtext);
if(GetPlayerMoney(playerid) < (1000 * coins)) return SendClientMessage(playerid, -1, "You don't have enough money.");
pCoins[playerid] += coins;
GivePlayerMoney(playerid, -(1000 * coins));
}
}
}
return 1;
}
stock ShowCoinsDialog(playerid) return ShowPlayerDialog(playerid, DIALOG_COINS, DIALOG_STYLE_INPUT, "{FF8000}Coins", "How much coins do you want?", "Submit", "Close");
stock IsNumeric(string[])
{
for(new i = 0; i < strlen(string); i ++) if (string[i] > '9' || string[i] < '0') return false;
return true;
}