Help - Command
#1

Hello. I need some help to make a command.

The comand is /get mats [amount].

Now lets say that 1 mats is 5 dollars. and i buy it 200, that is 200 X 5 = 1000 dollars. How can i make so that it will take the right amount of money depending on how many mats you buy...

Thanks 4 help and sorry for my engilsh :P
Reply
#2

Something like this would work:

pawn Код:
CMD:get(playerid, params[])
{
    new
        str[64],
        name[24],
        amount;

    if (sscanf(params, "s[24]d", name, amount))
        return SendClientMessage(playerid, -1, "Usage: /get <name> <amount>");

    if (!strcmp(name, "mats", true))
    {
        if (amount < 1 || amount > 100000)
            return 1;

        new price = amount * 5;
 
        if (GetPlayerMoney(playerid) < price)
            return SendClientMessage(playerid, -1, "You don't have enough money.");

        GivePlayerMoney(playerid, -price);
        PlayerInfo[playerid][pMats] += amount;

        format(str, sizeof(str), "You have purchased %d materials for $%d.", amount, price);
        SendClientMessage(playerid, -1, str);
    }
    return 1;
}
Adjust it to your needs.
Reply
#3

Thanks, it works

You are awsome :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)