Array length
#1

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?
pawn Код:
new array[5];
Reply
#2

https://sampwiki.blast.hk/wiki/Keywords:Operators#sizeof
Reply
#3

Thank you. Another question: Why can't I create an array using another variable? Like this:
pawn Код:
new variable = 5, array[variable];
Reply
#4

https://sampwiki.blast.hk/wiki/Scripting_Basics#Arrays
Reply
#5

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
Reply
#6

pawn Код:
new list[ 2 ][ ]    =    {
    {"www.link1.com"},
    {"www.link2.com"},
}   ;
Reply
#7

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.
Reply
#8

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!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)