SA-MP Forums Archive
Two Dimensional String Problem - 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: Two Dimensional String Problem (/showthread.php?tid=652748)



Two Dimensional String Problem - NoteND - 18.04.2018

So, thats my code..

Quote:

new string[2][128];
format(string[0],sizeof(string[0]), "{10F441}[VIP] {10F441}%s's {FFFFFF}VIP level has been set to {10F441}%d.", pInfo[pID][pName], vlevel);
SendClientMessage(playerid, -1, string[0]);
format(string[1],sizeof(string[1]), "{10F441}[VIP] {FFFFFF}Your VIP level has been set to {10F441}%d. {FFFFFF}Use {10F441}/vcmds {FFFFFF}to see available commands.", vlevel);
SendClientMessage(pID, -1, string[1]);

I get these errors:
https://i.gyazo.com/f48e142b213b4b3d...c5d6e9035f.png

In this line

format(string[0],sizeof(string[0]), "{10F441}[VIP] {10F441}%s's {FFFFFF}VIP level has been set to {10F441}%d.", pInfo[pID][pName], vlevel);


Re: Two Dimensional String Problem - Eoussama - 18.04.2018

The red coloured characters represent the danger area, that's what's causing the problem.
Код:
new string[2][128];
format(string[0],sizeof(string[0]), "{10F441}[VIP] {10F441}%s's {FFFFFF}VIP level has been set to {10F441}%d.", pInfo[pID][pName], vlevel);
SendClientMessage(playerid, -1, string[0]);
format(string[1],sizeof(string[1]), "{10F441}[VIP] {FFFFFF}Your VIP level has been set to {10F441}%d. {FFFFFF}Use {10F441}/vcmds {FFFFFF}to see available commands.", vlevel);
SendClientMessage(pID, -1, string[1]);
to fix that, consider removing the number values from the array's bracket, just like the following.
PHP код:
new string[2][128];
format(string[0],sizeof(string[]), "{10F441}[VIP] {10F441}%s's {FFFFFF}VIP level has been set to {10F441}%d."pInfo[pID][pName], vlevel);
SendClientMessage(playerid, -1string[0]);
format(string[1],sizeof(string[]), "{10F441}[VIP] {FFFFFF}Your VIP level has been set to {10F441}%d. {FFFFFF}Use {10F441}/vcmds {FFFFFF}to see available commands."vlevel);
SendClientMessage(pID, -1string[1]); 
In order to get the size of an array, you just have to pass in the array as a parameter on sizeof() which is actually not a function, it's a compiler directive, that's why we can only get array sizes at compile time, (imagine having this on runtime, how awesome would that be?).
Let's look at these few examples:
PHP код:
new array[3][5][8];
printf("%d"sizeof(array));
printf("%d"sizeof(array[]));
printf("%d"sizeof(array[][])); 
Witch outputs:
Код:
3
5
8



Re: Two Dimensional String Problem - NoteND - 18.04.2018

Thanks Eoussama learned new thing again