SA-MP Forums Archive
[QUESTION] Is it possible to return a function an 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [QUESTION] Is it possible to return a function an array? (/showthread.php?tid=78766)



[QUESTION] Is it possible to return a function an array? - Ignas1337 - 23.05.2009

well, the tite pretty much says it. I am working here on a funcion and it'd be best if I not use any values in the include, and i'd like to return an array. Is it possibe? and if yes - how? Else, I'll just make a new array in the include and assing what is needed to it


Re: [QUESTION] Is it possible to return a function an array? - Double-O-Seven - 23.05.2009

You mean something like this?
pawn Код:
new Test[4];

stock TestFunc()
{
for(new i=0;i<sizeof(Test);i++)
Test[i]=random(1337)+1;
return Test;
}




Re: [QUESTION] Is it possible to return a function an array? - Ignas1337 - 23.05.2009

exactly. But I wonder how could be handled with the function? I mean it returnas an array but how to assign an new array to the returning array ?

pawn Код:
new array1 = FunctionReturningArray();



Re: [QUESTION] Is it possible to return a function an array? - boylett - 23.05.2009

Both the arrays have to be the same size.

pawn Код:
new array[5];

array = ReturnArray();

ReturnArray()
{
  new array2[5];
  return array2;
}



Re: [QUESTION] Is it possible to return a function an array? - Ignas1337 - 23.05.2009

ok. what about muti-dimensional arrays? is that possible too if the arrays have same size?

f.e.
new array[8][8];


Re: [QUESTION] Is it possible to return a function an array? - Masj - 23.05.2009

yes, why not?


Re: [QUESTION] Is it possible to return a function an array? - Ignas1337 - 23.05.2009

ok, thanks