Formatting and adding MySQL cache'd values wont work properly
#1

Basically, what I'm trying to do is make the dialog show as:
Quote:
TEXT AS TABHEADER
35
Michael
Griffin
Alive
ID
Firstname
Surname
Status
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(dialog524"{A6856A}Please select your character to spawn");
        if(
cache_num_rows()) {
            for(new 
id 0id cache_num_rows(); id++) {
                new 
sqlidstring[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(string144"\n%i\t%s\t%s\t%s"sqlidfirstnamesurnameCharStatus[status]);
                
strcat(dialogstring);
            }
            if(
cache_num_rows() < 6)
                
strcat(dialog"\n \n{A1724C}Create a new character");
        }
        else
            
strcat(dialog"\n{A1724C}Create a new character");
        
ShowPlayerDialog(playeridDIALOG_CHARACTERSDIALOG_STYLE_TABLIST_HEADERSDIALOG_TITLEdialog"Select""Cancel");
    } 
What am I doing wrong here?




Reply
#2

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
Reply
#3

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)