Storing text data in a variable with 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)
+--- Thread: Storing text data in a variable with an array (
/showthread.php?tid=569101)
Storing text data in a variable with an array -
Juvanii - 28.03.2015
How to store text data in a variable with an array?
I tried to make this but didn't work!
pawn Code:
new text[15];
text[0] = "text1";
text[1] = "text2";
Re: Storing text data in a variable with an array -
ball - 28.03.2015
Code:
new text[2][15];
text[0] = "text1";
text[1] = "text2";
Re: Storing text data in a variable with an array -
Juvanii - 28.03.2015
I already tried this also and the compiler became with:
Code:
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
Header size: 17132 bytes
Code size: 1228336 bytes
Data size: 28176116 bytes
Stack/heap size: 16384 bytes; estimated max. usage: unknown, due to recursion
Total requirements:29437968 bytes
Re: Storing text data in a variable with an array -
CalvinC - 28.03.2015
Quote:
Originally Posted by Juvanii
How to store text data in a variable with an array?
I tried to make this but didn't work!
pawn Code:
new text[15]; text[0] = "text1"; text[1] = "text2";
|
You can only store 1 bit of information in each cell of the array.
When using format, or text[15] = "string" it's practically just:
pawn Code:
text[0] = "s";
text[1] = "t";
text[2] = "r";
text[3] = "i";
text[4] = "n";
text[5] = "g";
text[6] = "";
The last character will be taken up by "null".
So you have to use ball's method, which works fine for me.
I don't think there's a problem in using it, even though it gives that result, unless your server crashes or something ofcourse.
Re: Storing text data in a variable with an array -
Juvanii - 28.03.2015
Quote:
Originally Posted by CalvinC
You can only store 1 bit of information in each cell of the array.
|
I know that, i created this thread to see if there is a method to store text data or not!
consider i have 30 text data wanna use it in formatting a msg under one function, it's impossible to make 30 local variables such as:
pawn Code:
new variable1[50];
new variable2[50];
new variable3[50];
new variable4[50];
new variable5[50];
...
...
...
EDIT: FIXED