SA-MP Forums Archive
Dialog list showing strange character - 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: Dialog list showing strange character (/showthread.php?tid=606823)



Dialog list showing strange character - MotherDucker - 09.05.2016

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);
}



Re: Dialog list showing strange character - MotherDucker - 10.05.2016

Bump


Re: Dialog list showing strange character - jlalt - 10.05.2016

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++) 



Re: Dialog list showing strange character - Dayrion - 10.05.2016

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. :$


Re: Dialog list showing strange character - Konstantinos - 10.05.2016

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(...);



Re: Dialog list showing strange character - MotherDucker - 10.05.2016

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.