Formatting and adding MySQL cache'd values wont work properly - 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: Formatting and adding MySQL cache'd values wont work properly (
/showthread.php?tid=641347)
Formatting and adding MySQL cache'd values wont work properly -
Meller - 14.09.2017
Basically, what I'm trying to do is make the dialog show as:
Quote:
TEXT AS TABHEADER
35MichaelGriffinAlive IDFirstnameSurnameStatus
|
But it's only providing me with the SQLID, but nothing else.. Here's my current callback code;
PHP код:
forward public OnPlayerLoadCharacters(playerid);
public OnPlayerLoadCharacters(playerid) {
new dialog[524];
format(dialog, 524, "{A6856A}Please select your character to spawn");
if(cache_num_rows()) {
for(new id = 0; id < cache_num_rows(); id++) {
new sqlid, string[144], firstname[MAX_PLAYER_NAME], surname[MAX_PLAYER_NAME], status;
cache_get_value_name_int(id, "id", sqlid);
cache_get_value_name(id, "firstname", firstname);
cache_get_value_name(id, "surname", surname);
cache_get_value_name_int(id, "status", status);
format(string, 144, "\n%i\t%s\t%s\t%s", sqlid, firstname, surname, CharStatus[status]);
strcat(dialog, string);
}
if(cache_num_rows() < 6)
strcat(dialog, "\n \n{A1724C}Create a new character");
}
else
strcat(dialog, "\n{A1724C}Create a new character");
ShowPlayerDialog(playerid, DIALOG_CHARACTERS, DIALOG_STYLE_TABLIST_HEADERS, DIALOG_TITLE, dialog, "Select", "Cancel");
}
What am I doing wrong here?
Re: Formatting and adding MySQL cache'd values wont work properly -
IstuntmanI - 15.09.2017
You are using your header for this:
pawn Код:
format(dialog, 524, "{A6856A}Please select your character to spawn");
that's the first listitem, for DIALOG_STYLE_TABLIST_HEADERS the first listitem is the header (each column, separated with '\t' - you had no '\t' in that header, so it means that it only has one column, so it only showed the ID, while the rest columns were cut out). You have to make it like
pawn Код:
format(dialog, 32, "ID\tFirstname\tSurname\tStatus");
You can see an example for each dialog style here:
https://sampwiki.blast.hk/wiki/Dialog_Styles
Re: Formatting and adding MySQL cache'd values wont work properly -
Meller - 15.09.2017
Quote:
Originally Posted by IstuntmanI
You are using your header for this:
pawn Код:
format(dialog, 524, "{A6856A}Please select your character to spawn");
that's the first listitem, for DIALOG_STYLE_TABLIST_HEADERS the first listitem is the header (each column, separated with '\t' - you had no '\t' in that header, so it means that it only has one column, so it only showed the ID, while the rest columns were cut out). You have to make it like
pawn Код:
format(dialog, 32, "ID\tFirstname\tSurname\tStatus");
You can see an example for each dialog style here: https://sampwiki.blast.hk/wiki/Dialog_Styles
|
Ah yes! Figured the issue was gonna be something to do with the columns.. I just added blank tabs and now it's working perfectly fine, thank you.