[HELP]How to convert money into coins?
#4

I didn't test it, but here you go:
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;
}
I'm pretty sure you can add the rest, just try!
Reply


Messages In This Thread
[HELP]How to convert money into coins? - by fuckingcruse - 17.03.2015, 17:04
Re: [HELP]How to convert money into coins? - by CalvinC - 17.03.2015, 17:16
Re: [HELP]How to convert money into coins? - by fuckingcruse - 18.03.2015, 02:56
Re: [HELP]How to convert money into coins? - by SickAttack - 18.03.2015, 03:12

Forum Jump:


Users browsing this thread: 1 Guest(s)