Dialog list showing strange character
#1

Hello guys,

Just got a small problem which has only just started to appear, I am trying to display the character names and if there is no row, then it just shows "Create Character" however it shows a strange character for the middle item.

Код:
public OnPlayerCharacterSelection(playerid)
{
	Debug(DEBUG_CALLBACK_SQL, "OnPlayerCharacterSelection(%i)", playerid);
	print("OnPlayerCharacterSelection Called.");

	MySQL::getData(rows, fields);

	for(new i = 0; i < rows+1; i++)
	{
		MySQL::storeString(i, 0, Temp[i]);
		if(strfind(Temp[i], "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);
}
Reply
#2

Bump
Reply
#3

PHP код:
public OnPlayerCharacterSelection(playerid)
{
    
Debug(DEBUG_CALLBACK_SQL"OnPlayerCharacterSelection(%i)"playerid);
    print(
"OnPlayerCharacterSelection Called.");

    
MySQL::getData(rowsfields);

    for(new 
0rowsi++)
    {
        
MySQL::storeString(i0Temp[i]);
        if(
strfind(Temp[i], "null"true) != -1strcat((Temp[i][0] = EOSTemp[i]), "Create Character"17);
    }

    
format(strsizeof(str), "%s\n%s\n%s"Temp[0], Temp[1], Temp[2]);
    
ShowPlayerDialog(playeridDIALOG_ACCOUNTDIALOG_STYLE_LIST""SVR_NAME" - Account"strDIALOG_BUTTON_SELECTDIALOG_BUTTON_EXIT);

as you started from 0 here
Код:
for(new i = 0; i < rows+1; i++)
You don't need +1 thingy so it should be
PHP код:
for(new 0rowsi++) 
Reply
#4

Put a print under format(str, sizeof(str), "%s\n%s\n%s", Temp[0], Temp[1], Temp[2]); and check if it's same thing on the console. (print : printf("%s - %s - %s", Temp[0], Temp[1], Temp[2]);

EDIT : Don't do that if jlalt solved the problem. :$
Reply
#5

There are few things that can be improved though:

- Getting fields when not used (not necessary).
- Using isnull instead of strfind.
- Using strcat instead of format (jlalt used it).

I find this way better:
pawn Код:
new tmp_str[MAX_PLAYER_NAME + 1];

rows = cache_num_rows();

if (!rows) str = "Create Character";
else
{
    str[0] = EOS;
 
    for (new i = 0; i < rows; i++)
    {
        cache_get_row(i, 0, tmp_str);
        strcat(str, tmp_str, sizeof str);
        strcat(str, "\n", sizeof str);
    }
}

ShowPlayerDialog(...);
Reply
#6

Thanks guys, I don't really know why I had rows+1 :/ I must have done it by accident or something, but yeah; I've also adapted it differently and took into consideration Konstantinos' reply.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)