AddMenu Convert to ShowPlayerDialog
#1

Hi!


How to convert Addmenu to dialog?


Old(addmenu)
pawn Код:
createVote()
{
    for (new i;i<4;i++) gVoteItems[i] = "RESET";
    DestroyMenu(voteMenu);
    voteMenu = CreateMenu("Vote",1, 50.0, 200.0, 120.0, 250.0);
    print("Creating Votemenu");
    for (new i=0;i<4;i++)
    {
        randomRaceName(i,gRaces);
        AddMenuItem(voteMenu,0,gVoteItems[i]);   // HOW TO USE THIS IS DIALOG ??
        printf("VoteOption%d: %s",i,gVoteItems[i]);
    }
    for (new i=0;i<4;i++)gVotes[i]=0;

}
Reply
#2

https://sampwiki.blast.hk/wiki/How_to_Create_a_Dialog
Reply
#3

I converted dialog just bugs

Please help

pawn Код:
new pmsg[128];
        format(pmsg,256,"%s %s");
        ShowPlayerDialog(i, tdialog, DIALOG_STYLE_LIST, "Racing vote",gVoteItems[i],gVoteItems[i], "Vote", "");
Reply
#4

pawn Код:
ShowPlayerDialog(playerid,1,2,"Racing vote",gVoteItems[i],gVoteItems[i],"Vote","");
Reply
#5

Not good.

1 race show out of 4


AddMenu:

This is a good, just i need a dialog

Reply
#6

Quote:
Originally Posted by pista
Посмотреть сообщение
Not good.

1 race show out of 4


AddMenu:

This is a good, just i need a dialog

PLEASE HELP!!!!!!!!!!
Reply
#7

pawn Код:
#define MAX_RACING_MAPS 4 //You can define here yourself the amount of racing maps you own.
#define VOTEMAP_DIALOGID    1 //You should change it if you are using another dialogs with the same ID.

stock createVote()
{
    new dstr[512], bool:check = false;
    for (new i = 0; i < MAX_RACING_MAPS; i++)
    {
        if(!check)
        {
            format(dstr, sizeof(dstr), "%s", gVoteItems[i]);
            check = true;
        }
        else format(dstr, sizeof(dstr), "%s\r\n%s", dstr, gVoteItems[i]);
    }
    ShowPlayerDialog(playerid, VOTEMAP_DIALOGID, DIALOG_STYLE_LIST, "Racing Vote", dstr, "Vote", "Cancel");
}
Reply
#8

If not added
pawn Код:
for (new i;i<4;i++) gVoteItems[i] = "RESET";
server crashes..

else

Reply
#9

pawn Код:
stock createVote()
{

    for (new i;i<4;i++) gVoteItems[i] = "RESET";
    new dstr[256], bool:check = false;
   // for (new i;i<4;i++) gVoteItems[i] = "RESET";
    for (new i = 0; i < MAX_RACING_MAPS; i++)
    {
        if(!check)
        {
            randomRaceName(i,gRaces);
            format(dstr, sizeof(dstr), "%s", gVoteItems[i]);
           
            check = true;
        }
        else format(dstr, sizeof(dstr), "%s\r\n%s", dstr, gVoteItems[i]);
    }
    for (new i=0;i<4;i++)gVotes[i]=0;
    for(new i=0;i<MAX_PLAYERS;i++)
    {

    ShowPlayerDialog(i, VOTEMAP_DIALOGID, DIALOG_STYLE_LIST, "Racing Vote", dstr, "Vote", "Cancel");
 }
}
Reply
#10

Quote:
Originally Posted by pista
Посмотреть сообщение
If not added
pawn Код:
for (new i;i<4;i++) gVoteItems[i] = "RESET";
server crashes..

else

That might be because the strings were null before. You need to make sure they're parsing correctly (make sure you actually assign some data to them), as thats a big deal lol.


For dialogs lists you want to use strcat which will concatenate two strings together. The goal is to loop through your array of races (race name strings rather) and concatenate them all together (making sure a "\n" is added to the end, so it doesnt for a sentence like "Race1Race2Race3", but makes a list).

The wiki artcile i linked you to shows a static implementation of it, but the dynamic implementation is pretty much the same (expect its inside a loop, and uses arrays).
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)