SA-MP Forums Archive
Help navigating through array. - 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: Help navigating through array. (/showthread.php?tid=356901)



Help navigating through array. - ReneG - 05.07.2012


Why is it outputting random numbers instead of what's in the array? I've never worked with arrays until now.


Re: Help navigating through array. - Roko_foko - 05.07.2012

pawn Код:
gArray[][]={
{"Ganton", 1 ,2 ,3},
//...
What did you actually do?
pawn Код:
gArray[0][0]='G';
gArray[0][1]='a';
gArray[0][2]='n';
gArray[0][3]='t';
gArray[0][4]='o';
gArray[0][5]='n';
gArray[0][6]='\0'; // same as gArray[0][7]= 0
gArray[0][7]='1';
gArray[0][8]='2';
gArray[0][9]='3';
Do you get it now?
pawn Код:
printf("%s",gArray[0][0])//will print the string from place gArray[0][0] to the last place where it sees '\0'
printf("%i",gArray[0][0])// this will print Iniger value of a char( form ascii table)
so printf("%i",gArray[0][1]) will put out Intiger value of 'a' which is 97


Re: Help navigating through array. - ReneG - 05.07.2012

I get it, arrays have always been a grey area for me.

I was trying to make an array that holds fire info, the name, and location. I'll just use the array for co-ordinates, and use the zone script to get the location name.