SA-MP Forums Archive
[Help] Passing a 2d array (a string array) into fwrite? - 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: [Help] Passing a 2d array (a string array) into fwrite? (/showthread.php?tid=311266)



[Help] Passing a 2d array (a string array) into fwrite? - ]SB[Matt - 15.01.2012

I've got some formatting error were only certain characters of my string are successfully passed into fwrite..

I'm working on a statistics script where it stores the top 5 results in a text file, I started by reading from the text file and copying each line of the file into a 2d array:

Code:
new highscore[4][30];

while(fread(read, string))
{
  		strdel(highscore[hsCount], 0, 30);
                strcat(highscore[hsCount], string);
                hsCount++;
}
Now this works fine and when I go to print a line from the file using SendClientMessage it will works perfectly and prints the entire word:

Code:
SendClientMessageToAll(red, highscore[0]);
However whenever I try to pass my 2d array it into fwrite or format another string:

Code:
fwrite(location, highscore[0]);
format(text,sizeof(text),"%s", highscore[0]);
SendClientMessageToAll(orange, text);
it only includes the every 4th character in the string and not the entire word??

I only have this problem when using 2d arrays but it's the easiest way to sort and re-order each word into alphabetical order

Any help would be appreciated