String not being set
#1

Hello all,

So I am trying to store three different values into a two-dimensional array, the strings are taken from the database and then stored in the array so that the user is then able to see them in a dialog.
Код:
new Temp[4][];
Код:
public OnPlayerCharacterSelection(playerid) {
	MySQL::getData(rows, fields);
	for(new i = 0; i < rows; i++) {
		MySQL::storeString(i, 0, Temp[i][0]);
		if(strfind(Temp[i][0], "null", true) != -1) strcat((Temp[i][0] = EOS, Temp[i]), "Create Character", 17);
	}
	format(str, sizeof(str), "%s\n%s\n%s", Temp[0], Temp[1], Temp[2]);
	ShowPlayerDialog(playerid, DIALOG_ACCOUNT, DIALOG_STYLE_LIST, ""SVR_NAME" - Account", str, DIALOG_BUTTON_SELECT, DIALOG_BUTTON_EXIT);
}
What actually happens is when the data is taken from the database, it tries to store in the array but fails.. and it only displays one value out of two but value is displays is "Create Character".

I'm not really sure what is happening here so if you can see, please let us know.
Reply
#2

I have no idea how you managed to compile that...
Try these:
new Temp[4][24];
Reply
#3

Quote:
Originally Posted by DRIFT_HUNTER
Посмотреть сообщение
I have no idea how you managed to compile that...
Try these:
new Temp[4][24];
Oh yeah, sorry; that was an edited version; it used to have values in..
Код:
new Temp[4][] = {
	"Create Character",		// Character Slot 1
	"Create Character",		// Character Slot 2
	"Create Character",		// Character Slot 3
	0
};
Reply
#4

pawn Код:
new Temp[4][24] = {
    "Create Character",     // Character Slot 1
    "Create Character",     // Character Slot 2
    "Create Character",     // Character Slot 3
    0
};
Reply
#5

Quote:
Originally Posted by Lynn
Посмотреть сообщение
pawn Код:
new Temp[4][24] = {
    "Create Character",     // Character Slot 1
    "Create Character",     // Character Slot 2
    "Create Character",     // Character Slot 3
    0
};
That seems to make it display none of the values.
Reply
#6

Remove that zero at the end of array, or put it in quote if you want to show it.

if(strfind(Temp[i][0], "null", true) != -1) -> Unless mysql returns string with value "null" (4 characters) than it wont work. If so, try replacing:
pawn Код:
if(strfind(Temp[i][0], "null", true) != -1) strcat((Temp[i][0] = EOS, Temp[i]), "Create Character", 17);
//With these
if(strlen(Temp[i]) > 0) format(Temp[i], 17, "Create Character");
First we check if mysql string was empty, and if it was then we put Create Character string in it. (I guess that is what you want)
Reply
#7

Quote:
Originally Posted by DRIFT_HUNTER
Посмотреть сообщение
Remove that zero at the end of array, or put it in quote if you want to show it.

if(strfind(Temp[i][0], "null", true) != -1) -> Unless mysql returns string with value "null" (4 characters) than it wont work. If so, try replacing:
pawn Код:
if(strfind(Temp[i][0], "null", true) != -1) strcat((Temp[i][0] = EOS, Temp[i]), "Create Character", 17);
//With these
if(strlen(Temp[i]) > 0) format(Temp[i], 17, "Create Character");
First we check if mysql string was empty, and if it was then we put Create Character string in it. (I guess that is what you want)
Hm.. I believe I have fixed it now; I changed both values below and it seems to work now...
Код:
MySQL::storeString[i];
Temp[4][MAX_PLAYER_NAME] = { ... };
So I believe it was just setting the string.. but setting it with 0 letters.. which is strange as I wouldn't think it would do that, the rest of the code is fine.
Rep++ anyway!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)