SA-MP Forums Archive
Error - 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 (/showthread.php?tid=372767)



Error - deimantas1 - 28.08.2012

Hi all, I get error: error 032: array index out of bounds (variable "kod")
line:
Код:
if(kod[10] == adalis)
All code:
Код:
	if(dialogid == 250)
	{
	    if(response)
	    {
			adalis = strval(inputtext);
			new zin[20],querys[100],kod[10];
			format(zin,sizeof(zin),"%d ir %d",pdalis,adalis);
			SendClientMessage(playerid,BALTA,zin);
			format( querys, 128, "SELECT Kodas FROM `namai` WHERE id = '%i'",pdalis);
			mysql_query( querys );
			mysql_store_result();
			mysql_retrieve_row();
			mysql_fetch_field_row( querys, "Kodas" );
			format( kod, 10, "%d", querys ) ;

	        mysql_free_result();
	        SendClientMessage(playerid,BALTA,querys);
	        if(kod[10] == adalis)
	        {
	            SendClientMessage(playerid,BALTA,"Sutinka");
	        }
	        else
	        {
	            SendClientMessage(playerid,BALTA,"Nesutinka");
	        }
	    }
	    if(!response)
	    {
	    }
	}



Re: Error - Cjgogo - 28.08.2012

I suposse that's a string,AND you cannot compare 2 strings like that,use strcmp.That stands for string compare.


Re: Error - deimantas1 - 28.08.2012

Please example.


Respuesta: Error - Siralos - 28.08.2012

The problem is that if you do: kod[10], the system believes that you are trying to access position 10 in the string, and you only have 0-9 positions in a 10 char string.

you should do this:
if(strval(kod) == adalis)


Re: Error - Cjgogo - 28.08.2012

Removed,due to unuseful answer,sorry.


Respuesta: Re: Error - Siralos - 28.08.2012

He is trying to compare two integers, not two strings, just check his code


Re: Respuesta: Re: Error - Cjgogo - 28.08.2012

My bad,you're right,sorry deimantas,and yes,Siralos is right...