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=259814)



Array Must Be Indexed? - ScottCFR - 06.06.2011

Not sure what this means..

Код:
(1029) : error 033: array must be indexed (variable "inputtext")
(1030) : error 033: array must be indexed (variable "inputtext")
(1031) : error 035: argument type mismatch (argument 2)
(1032) : error 033: array must be indexed (variable "inputtext")
(1045) : error 033: array must be indexed (variable "inputtext")
(1046) : error 033: array must be indexed (variable "inputtext")
(1047) : error 035: argument type mismatch (argument 2)
(1048) : error 033: array must be indexed (variable "inputtext")
Код:
		case 8:
		{
		    if(response)
		    {
		        if(!isnum(inputtext)) return SendClientMessage(playerid, COLOR_RED, "ERROR: You must enter a number!");
		        if(inputtext <= 0) return SendClientMessage(playerid, COLOR_RED, "ERROR: You must enter more then 1 dollar!");
		        if(GetPlayerMoney(playerid) < inputtext) return SendClientMessage(playerid, COLOR_RED, "ERROR: You don't have that much cash!");
				GivePlayerMoney(playerid, -inputtext);
				new pBank = GetPVarInt(playerid, "Bank")+inputtext;
				SetPVarInt(playerid, "Bank", pBank);
				new string[64];
				format(string, sizeof(string), "You have put %d into your account, your new balance is: %d",inputtext,GetPVarInt(playerid, "Bank"));
				SendClientMessage(playerid, COLOR_GREEN, string);
		        
			}
		}
		case 9:
		{
		    if(response)
		    {
		        if(!isnum(inputtext)) return SendClientMessage(playerid, COLOR_RED, "ERROR: You must enter a number!");
		        if(inputtext <= 0) return SendClientMessage(playerid, COLOR_RED, "ERROR: You must enter more then 1 dollar!");
		        if(GetPVarInt(playerid, "Bank") < inputtext) return SendClientMessage(playerid, COLOR_RED, "ERROR: You don't have that much cash in your account!");
				GivePlayerMoney(playerid, inputtext);
				new pBank = GetPVarInt(playerid, "Bank")-inputtext;
				new string[64];
				SetPVarInt(playerid, "Bank", pBank);
				format(string, sizeof(string), "You have withdrawn %d from your account, your new balance is: %d",inputtext,GetPVarInt(playerid, "Bank"));
				SendClientMessage(playerid, COLOR_GREEN, string);
			}
		}



Re: Array Must Be Indexed? - cessil - 06.06.2011

you can't add a string to an integer like that, you need to use strval to find out the value of the string and then add them


Re: Array Must Be Indexed? - ScottCFR - 06.06.2011

Worked like a charm, thanks a lot!