Character List
#1

PHP код:
stock ListCharacters(playerid)
{
    new 
sz_Query[128], DBResult:resultname[MAX_PLAYER_NAME], count;
    
format(sz_Querysizeof(sz_Query), "SELECT * FROM `chars` WHERE `userid` = %d"PlayerInfo[playerid][pUserID]);
    
result db_query(Databasesz_Query);
    for (
count 0count db_num_rows(result); count ++)
    {
        
db_get_field_assoc(result"char_name"nameMAX_PLAYER_NAME);
        
format(sz_Querysizeof(sz_Query), "%s\n"name);
        
db_next_row(result);
    }
    
db_free_result(result);
    
    if(
count 0
        
SendClientMessage(playeridCOLOR_LIGHTRED"(( Choose a character. ))") &&
        
format(sz_Querysizeof(sz_Query), "Create Character\n%s"sz_Query) &&
        
Dialog_Show(playeridLoadCharacterDIALOG_STYLE_LIST""COL_GREEN"Characters List"sz_Query"Load""");
    else
        
SendClientMessage(playeridCOLOR_LIGHTRED"(( You have not created a character yet, Create one!") &&
        
Dialog_Show(playeridCreateCharacterDIALOG_STYLE_INPUT""COL_RED"Character Name""* You have not created a character yet, Create one!\nPlease input the name of your character:""Create""");
    return 
1;

For some reason the code above only lists one character even though the player owns two or more characters, What is with the code?
Reply
#2

pawn Код:
format(sz_Query, sizeof(sz_Query), "%s\n", name);
You are overwriting sz_Query with each new row.
pawn Код:
format(sz_Query, sizeof(sz_Query), "%s%s\n", sz_Query, name);
Reply
#3

Ah, didn't noticed that. Thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)