SA-MP Forums Archive
string question - 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: string question (/showthread.php?tid=336944)



string question - Whizion - 24.04.2012

So this does not work:

pawn Код:
new string[15][];
format(string[0], sizeof(string[0]), "lol");
What is the proper way to do this? So don't need something like string_1, string_2 ... string_15?

Thanks.


Re: string question - Claude - 24.04.2012

Have you tried this?
pawn Код:
new string[15][128];



Re: string question - Whizion - 24.04.2012

Yup, still doesn't work. It displays 3 errors on one line...


Re: string question - Claude - 24.04.2012

What are the errors?


Re: string question - Whizion - 24.04.2012

(31724) : error 001: expected token: "]", but found "-integer value-"
(31724) : warning 215: expression has no effect
(31724) : error 001: expected token: ";", but found "]"
(31724) : error 029: invalid expression, assumed zero
(31724) : fatal error 107: too many error messages on one line


Re: string question - mkr - 24.04.2012

pawn Код:
new string[15][128];
format(string[0], 128, "lol");
That works. sizeof() seems to not work past the first level of multidimensional arrays.

Although you can just assign the string values and avoid a bunch of formats:

pawn Код:
new string[15][128] = {
    "line 1",
    "line 2",
    ...,
    "line 15"
};



Re: string question - BlackBank - 24.04.2012

Quote:
Originally Posted by Whizion
Посмотреть сообщение
(31724) : error 001: expected token: "]", but found "-integer value-"
(31724) : warning 215: expression has no effect
(31724) : error 001: expected token: ";", but found "]"
(31724) : error 029: invalid expression, assumed zero
(31724) : fatal error 107: too many error messages on one line
Instead of this:
pawn Код:
new string[15][128];
    format(string[0], string[0], "lol");
It need to be like this:
pawn Код:
new string[15][128];
    format(string[0], sizeof(string[]), "lol");
    format(string[1], sizeof(string[]), "lol");
EDIT:
without the [], sizeof will print 15.
With the [], sizeof will print 128.


Re: string question - Whizion - 24.04.2012

Thank you.