Dialog problem
#1

I'm trying to show player's banks, but also on top "Create Bank" and "Remove Bank", problem is, it doubles, how do i fix it?

Code:
pawn Код:
public ShowBankAccounts(playerid)
{
    new query[512],results[400],title[64];
    format(title,sizeof(title),"{1B8AE4}Your Bank Accounts");
    Num1[playerid] = 0;
    Num2[playerid] = 12;
    format(query,sizeof(query),"SELECT ID, Name, Balance FROM `bankaccounts` WHERE `Owner`='%s' ORDER BY `ID` DESC LIMIT %d, %d", PlayerName(playerid), Num1[playerid], Num2[playerid]);
    mysql_query(query);
    mysql_store_result();
    new tRows = mysql_num_rows();
    if(tRows == 0) { SCM(playerid, COLOR_RED, "You do not have any bank accounts!"); return 1; }
    new pID, pName[MAX_PLAYER_NAME], bBalance;
    while(mysql_fetch_row(query))
    {
        sscanf(query, "p<|>ds[24]d", pID, pName, bBalance);
        format(results,sizeof(results),"Create Bank Account\nRemove Bank Account\n%s%s%d | %s | $%d\n", results,pID,pName,bBalance);
    }
    mysql_free_result();
    ShowPlayerDialog(playerid, mybankaccounts1, DIALOG_STYLE_LIST,title, results,"Select", "Back");
    return 1;
}
Image:

Please DO NOT post if you haven't got any experience with this!
Reply
#2

try this

pawn Код:
format(results,sizeof(results),"Create Bank Account\nRemove Bank Account\n%d | %s | $%d\n", pID,pName,bBalance);
Reply
#3

That worked, but now it only shows 1 bank instead of 2.
Reply
#4

bump
Reply
#5

pawn Код:
public ShowBankAccounts(playerid)
{
    new query[512],results[400],title[64];
    format(title,sizeof(title),"{1B8AE4}Your Bank Accounts");
    Num1[playerid] = 0;
    Num2[playerid] = 12;
    format(query,sizeof(query),"SELECT ID, Name, Balance FROM `bankaccounts` WHERE `Owner`='%s' ORDER BY `ID` DESC LIMIT %d, %d", PlayerName(playerid), Num1[playerid], Num2[playerid]);
    mysql_query(query);
    mysql_store_result();
    new tRows = mysql_num_rows();
    if(tRows == 0) { SCM(playerid, COLOR_RED, "You do not have any bank accounts!"); return 1; }
    new pID, pName[MAX_PLAYER_NAME], bBalance;

    format(results,sizeof(results),"Create Bank Account\nRemove Bank Account\n");

    while(mysql_fetch_row(query))
    {
        sscanf(query, "p<|>ds[24]d", pID, pName, bBalance);
        format(results,sizeof(results),"%s%d | %s | $%d\n", results,pID,pName,bBalance);
    }
    mysql_free_result();
    ShowPlayerDialog(playerid, mybankaccounts1, DIALOG_STYLE_LIST,title, results,"Select", "Back");
    return 1;
}
First create the 2 headers (Create bank account, Delete bank account) outside the loop.
Then after that, loop through the rows and add only the rows.

If you had 10 entries, you would have all of it 10 times.

Also, you had one "%s" too many in that format line.
Reply
#6

Ah thanks, that did the job!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)