SA-MP Forums Archive
Returning string from 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: Returning string from array (/showthread.php?tid=588064)



Returning string from array - IllidanS4 - 05.09.2015

Code:
new strArr[][] = {
    "one",
    "two",
    "three"
};

stock GetStringArray(index)
{
    return strArr[index];
}
Why does print(GetStringArray(0)); show "(null)"?


Re: Returning string from array - Freezo - 05.09.2015

I don't know what the hell is that, but its printed $one $one $one for me, but i see that your stock function is pointless, you can use it directly or using a define.

Code:
#define getNum(%0)	numberPrint[%0]

new const numberPrint[][] = {
	"one",
	"two",
	"three"
}
getNum(0), getNum(1), getNum(2)