SA-MP Forums Archive
Array must be indexed - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Array must be indexed (/showthread.php?tid=274624)



Array must be indexed - emokidx - 06.08.2011

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;
    }
}



Re: Array must be indexed - PhoenixB - 06.08.2011

if(GetPlayerMoney(playerid) < ammount)

What are you trying to make it do ?

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


Re: Array must be indexed - emokidx - 06.08.2011

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..


Re: Array must be indexed - =WoR=Varth - 06.08.2011

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



Re: Array must be indexed - emokidx - 06.08.2011

ohk!thnx!


Re: Array must be indexed - _Aleksandar - 06.08.2011

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


    {
        if(sscanf(params, "ui", ID, ammount))



Re: Array must be indexed - emokidx - 06.08.2011

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