Array length - 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: Array length (
/showthread.php?tid=532928)
Array length -
arad55 - 21.08.2014
Hey, I was wondering if there's a function to get an array's length.
Like if I create an array size 5, is there a function that returns the length?
Re: Array length -
MicroD - 21.08.2014
https://sampwiki.blast.hk/wiki/Keywords:Operators#sizeof
Re: Array length -
arad55 - 21.08.2014
Thank you. Another question: Why can't I create an array using another variable? Like this:
pawn Код:
new variable = 5, array[variable];
Re: Array length -
MicroD - 21.08.2014
https://sampwiki.blast.hk/wiki/Scripting_Basics#Arrays
Re: Array length -
arad55 - 21.08.2014
Can I have an array that has links? Building a radio system but it returns errors:
pawn Код:
new list[2] = {
"www.link1.com",
"www.link2.com",
};
ERROR:
pawn Код:
error 018: initialization data exceeds declared size
Re: Array length -
[XST]O_x - 21.08.2014
pawn Код:
new list[ 2 ][ ] = {
{"www.link1.com"},
{"www.link2.com"},
} ;
Re: Array length -
arad55 - 21.08.2014
Quote:
Originally Posted by [XST]O_x
pawn Код:
new list[ 2 ][ ] = { {"www.link1.com"}, {"www.link2.com"}, } ;
|
Thanks. Is it possible to save the radio's name too in this array? Without changing the size of the array.
EDIT: Nevermind, managed to do it.
Re: Array length -
arad55 - 21.08.2014
Another question regarding this: I want the server to create the dialog using the list array, but it doesn't work properly;
pawn Код:
new dialogmsg[1024] = "{FF0000}Turn off{FFFFFF}";
for(new i=0; i<sizeof(radiolist); i++)
{
new tmp[1024];
format(tmp, sizeof(tmp), dialogmsg, "%s\n%s", dialogmsg, radiolist[i][1]);
dialogmsg = tmp;
}
When I type the command, it opens a dialog only with "Turn off" and nothing else. The for doesn't add the radio list to the string. Please help!
EDIT: Found my mistake, thanks anyway!