SA-MP Forums Archive
Dialog problem - 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 problem (/showthread.php?tid=493728)



Dialog problem - Jimmy0wns - 09.02.2014

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!


Re: Dialog problem - Smileys - 09.02.2014

try this

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



Re: Dialog problem - Jimmy0wns - 09.02.2014

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


Re: Dialog problem - Jimmy0wns - 10.02.2014

bump


Re: Dialog problem - PowerPC603 - 10.02.2014

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.


Re: Dialog problem - Jimmy0wns - 10.02.2014

Ah thanks, that did the job!