SA-MP Forums Archive
[HELP REQUEST] ShowPlayerDialog (list) - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP REQUEST] ShowPlayerDialog (list) (/showthread.php?tid=268268)



[HELP REQUEST] ShowPlayerDialog (list) - Micheal_ - 11.07.2011

[Highly code needed, take your time. I NEED -YOUR- HELP.]

Hey guys.

I'm just trying to create a showplayerdialog (list) that will read the items from a file.
But when I'm running the script there are no errors or warnings but there is no items in the list box.

This is my code:
pawn Код:
new getItems[256];
format(getItems, 256, "%s\r\n%s\r\n%s", DOF2_GetString(User, "item2", "section"), DOF2_GetString(User, "item2", "section"), DOF2_GetString(User, "item3", "section"));

ShowPlayerDialog(playerid, 0, DIALOG_STYLE_LIST, "List", getItems , "Go", "Cancel");
Thanks for anyone who'll try to help me with this. another code will be very helpful.


Re: [HELP REQUEST] ShowPlayerDialog (list) - Rickye - 12.07.2011

try increase string lenght


Re: [HELP REQUEST] ShowPlayerDialog (list) - Micheal_ - 12.07.2011

Anyone?


Re: [HELP REQUEST] ShowPlayerDialog (list) - Toreno - 12.07.2011

Did you check these items on a regular chat? are they even working?


Re: [HELP REQUEST] ShowPlayerDialog (list) - Micheal_ - 12.07.2011

Yes, they are.
I think that the way that I created the format of them (see above) is just incorrect.
Someone got another sugesstion? maybe write for me just a code like as you doing this?

Let's leave my code from now, I need you to write for me your way to make a list dialog with strings from file.

Thanks.


Re: [HELP REQUEST] ShowPlayerDialog (list) - Toreno - 12.07.2011

Try this, that might work for you.
pawn Код:
new getItems[256];
new str[256];
format(getItems, 256, "%s\r\n%s\r\n%s", DOF2_GetString(User, "item2", "section"), DOF2_GetString(User, "item2", "section"), DOF2_GetString(User, "item3", "section"));
strcat(str, getItems, sizeof(str));
ShowPlayerDialog(playerid, 0, DIALOG_STYLE_LIST, "List", str , "Go", "Cancel");
You need to do something with your string size, or calculate anything since 256 is higher. However, try this first.


Re: [HELP REQUEST] ShowPlayerDialog (list) - PotH3Ad - 12.07.2011

This is the way I do it, might be helpful.

pawn Код:
format(diagstr, sizeof(diagstr), "ID\tDuel Name\n");
                    for(new x=0; x<MAX_DUELS; x++)
                    {
                        format(dFile, sizeof(dFile), DUELFILES, x);
                        if(strlen(dini_Get(dFile, "duelName")) > 0) format(diagstr, sizeof(diagstr), "%s%d\t%s\n", diagstr, x, dini_Get(dFile, "duelName"));
                        else format(diagstr, sizeof(diagstr), "%s%d\tEmpty Slot\n", diagstr, x);
                    }
                    ShowPlayerDialog(playerid, DUELDIAG+2, DIALOG_STYLE_LIST, "Duel List", diagstr, "Select", "Exit");
It formats the string until the loop is over, then it shows the resulting string.


Re: [HELP REQUEST] ShowPlayerDialog (list) - Micheal_ - 12.07.2011

Quote:
Originally Posted by PotH3Ad
Посмотреть сообщение
This is the way I do it, might be helpful.

pawn Код:
format(diagstr, sizeof(diagstr), "ID\tDuel Name\n");
                    for(new x=0; x<MAX_DUELS; x++)
                    {
                        format(dFile, sizeof(dFile), DUELFILES, x);
                        if(strlen(dini_Get(dFile, "duelName")) > 0) format(diagstr, sizeof(diagstr), "%s%d\t%s\n", diagstr, x, dini_Get(dFile, "duelName"));
                        else format(diagstr, sizeof(diagstr), "%s%d\tEmpty Slot\n", diagstr, x);
                    }
                    ShowPlayerDialog(playerid, DUELDIAG+2, DIALOG_STYLE_LIST, "Duel List", diagstr, "Select", "Exit");
It formats the string until the loop is over, then it shows the resulting string.
Can you make your code compatible with mine? I tried with no success.
I mean that I got 3 items that I need to get from a file.

item 1: DOF2_GetString(User, "item1", "ITEMS");
item 2: DOF2_GetString(User, "item2", "ITEMS");
item 3: DOF2_GetString(User, "item3", "ITEMS");

Thanks (!)

EliranPesahov - Your code returns an empty list. thanks anyway.


Re: [HELP REQUEST] ShowPlayerDialog (list) - PotH3Ad - 12.07.2011

Try this. Make sure you are using the file functions correctly and make sure you are formatting the string that stores the file directory.

pawn Код:
new items[250], key[8];
//Make sure you are formatting the "User" string before this
//-format(User, sizeof(User), USER_FILE, pName); //replace with ur file code..
for(new x=0; x<3; x++) //Starts with 0.  (Loop 0-2)
{
    format(key, sizeof(key), "item%d", x+1);
    format(items, sizeof(items), "%s%s\n", items, DOF2_GetString(User, key, "ITEMS")); //Continue formatting the string with the file value's until the loop ends
}
ShowPlayerDialog(playerid, 0, DIALOG_STYLE_LIST, "List", items, "Go", "Cancel");