Array must be indexed
#1

hello
i cant just figure how to solve this

erroe:
Код:
error 033: array must be indexed (variable "ammount")
on line:
pawn Код:
if(GetPlayerMoney(playerid) < ammount)
command:
pawn Код:
CMD:givecash(playerid, params[])
{
    GetPlayerName(ID, pname, sizeof(pname));
    new ammount[128], str0[128];


    {
        if(sscanf(params, "us", ID, ammount))
            {
                SendClientMessage(playerid, red, "Usage: /givecash [playerid] [ammount]");
                return 1;
            }

        if(!IsPlayerConnected(ID))
            {
                SendClientMessage(playerid, red, "Invalid ID");
                return 1;
            }
        if(GetPlayerMoney(playerid) < ammount)
            {
                SendClientMessage(playerid, red, "You don't ahve that much money!");
                return 1;
            }
        else
        {
            GetPlayerName(playerid, aname, sizeof(aname));

            format(str, sizeof(str), "You have transferred %%d to %s(%d)!", ammount, pname, ID);
            SendClientMessage(playerid, blue, str);
            format(str0, sizeof(str0), "%s(%d) has transferred $%d to you!", aname, playerid, ammount);
            SendClientMessage(playerid, blue, str0);
            GivePlayerMoney(playerid, (0 - ammount));
            GivePlayerMoney(ID, ammount);
        }
        return 1;
    }
}
Reply
#2

if(GetPlayerMoney(playerid) < ammount)

What are you trying to make it do ?

GetPlayerMoney but what amount? Possible try changing Amount to a figure?
Reply
#3

uhm its a givecash command,, so it would not be a constant but a variable

let me post whole command on first comment please check it..
Reply
#4

It's must be like this:
pawn Код:
new ammount;
Reply
#5

ohk!thnx!
Reply
#6

ammount isn't string :S
it's int(integer)..
Код:
  new ammount, str0[128];


    {
        if(sscanf(params, "ui", ID, ammount))
Reply
#7

Quote:
Originally Posted by _Aleksandar
Посмотреть сообщение
ammount isn't string :S
it's int(integer)..
will keep that in mind next time
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)