SA-MP Forums Archive
error 028: invalid subscript (not an array or too many subscripts) - 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)
+--- Thread: error 028: invalid subscript (not an array or too many subscripts) (/showthread.php?tid=600576)



error 028: invalid subscript (not an array or too many subscripts) - AnoTek - 09.02.2016

I have an error when i compile the script: error 028: invalid subscript (not an array or too many subscripts): "drugdj"

The line is this:
Code:
if(drugdj[playerid] == 1) return SendClientMessage(playerid,COLOR_WHITE,"{999999}Wait until you can share the pizza again.");
and the command is this:
Code:
CMD:work(playerid, params[])
{
	new rand = random(sizeof(CursaRandomDrug));
    if(IsPlayerInRangeOfPoint(playerid,7.0,-2546.0862,9.2330,16.4219))
   	{
		if(PlayerInfo[playerid][pJob] >= 1)
	    {
			if(drugdj[playerid] == 1) return SendClientMessage(playerid,COLOR_WHITE,"{999999}Asteapta pana cand face o alta cursa.");
			{
				new Float:x, Float:y, Float:z, Float:a;
				GetPlayerPos(playerid, x,y,z); 
				GetPlayerFacingAngle(playerid, a);
				new vehicleid = CreateVehicle(459, x+3,y,z, a, -1, -1, -1);
				SetPlayerCheckpoint(playerid, CursaRandomDrug[rand][0], CursaRandomDrug[rand][1], CursaRandomDrug[rand][2], CursaRandomDrug[rand][3]);
				PutPlayerInVehicle(playerid, vehicleid, 0);
				SendClientMessage(playerid, COLOR_LIGHTBLUE, "JOB: Livreaza drogurile la destinatia setata pe harta!");
				drugdj[playerid] = 1;
				CP[playerid] = 0;
			}	
		}
	}
	return 1;
}



Re: error 028: invalid subscript (not an array or too many subscripts) - Joron - 09.02.2016

Whats Cmd to do? Explain what it should do Please.


Re: error 028: invalid subscript (not an array or too many subscripts) - Vince - 09.02.2016

The error message clearly states that "drugdj" is not an array. So make it an array.


Re: error 028: invalid subscript (not an array or too many subscripts) - Joron - 09.02.2016

Quote:
Originally Posted by Vince
View Post
The error message clearly states that "drugdj" is not an array. So make it an array.
He dont know how are he would of do it wouldnt he?


Re: error 028: invalid subscript (not an array or too many subscripts) - Joron - 09.02.2016

I did the same thing in a script and got no errors
Quote:

new drugdj[MAX_PLAYERS];

Is your answer


Re: error 028: invalid subscript (not an array or too many subscripts) - Vince - 09.02.2016

Quote:
Originally Posted by Joron
View Post
He dont know how are he would of do it wouldnt he?
An array is a basic element of most, if not all, high level programming languages. Understanding the terminology is part one in understanding the language as a whole.