Dialog Response, Get Duel ID
#1

Hi everyone, i have a small question about Dialogs, i have make a dynamic Dialog and i need to know how to make the response , i mean when i click on the Duel i want to get another Dialogs with 2 choice "Join Duel\nSpectate Duel" , but idk how to get the duel id from the dialog, if anyone can help

PHP код:
                if(listitem == 1)
                {
                    new 
DuelList[750];
                    
                    for (new 
iMAX_DUELSi++)
                    {
                        if(
Duel[i][DuelExiste])
                        {
                               
format(DuelListsizeof(DuelList), "Createur: {00FF00}%s{FFFFFF}, Nom : {00FF00}%s{FFFFFF}\n"Duel[i][DuelLeader], Duel[i][DuelName]);
                        }
                    }
                    
ShowPlayerDialog(playerid5000DIALOG_STYLE_LIST"Choisissez un Duel:"DuelList"Ok""Annuler");
                } 
Reply
#2

Hello!

I have a small example for you.
PHP код:
new count;
for(new 
i;i<MAX_DUELS;i++)
{
    if(
Duel[i][DuelExiste])
    {
        if(
listitem == count)
        {
            
// i = ID of the Duel
            
break;
        }
        
count ++;
    }

If you have questions you can post it here.

Mencent
Reply
#3

Nop, i don't mean this , i'am talking about DialogResponse, when i choice one of the duel liste , how can i get the duel ID , thank you anyway.
Reply
#4

Just save the option you picked in a variable and then perform an action with it afterwards.
Reply
#5

Yes look at my example:
PHP код:
if(dialogid == 5000)
{
    if(
response)
    {
        new 
count,i;
        for(;
i<MAX_DUELS;i++)
        {
            if(
Duel[i][DuelExiste])
            {
                if(
listitem == count)
                {
                    
//i = ID of the Duel
                    
break;
                }
                
count ++;
            }
        }
    }
    return 
1;

It's right
For me it works i had tested it.

Mencent
Reply
#6

Quote:
Originally Posted by Mencent
Посмотреть сообщение
Yes look at my example:
PHP код:
if(dialogid == 5000)
{
    if(
response)
    {
        new 
count,i;
        for(;
i<MAX_DUELS;i++)
        {
            if(
Duel[i][DuelExiste])
            {
                if(
listitem == count)
                {
                    
//i = ID of the Duel
                    
return 1;
                }
                
count ++;
            }
        }
    }
    return 
1;

It's right

Mencent
No, don't ever return a value in a loop, break the loop first and then return the value afterwards. Plus this is totally unnecessary, just store the option in a variable and then use it somewhere else.
Reply
#7

@SickAttack:
That's all it should be. I finish the loop, because the passage does not have to keep running, I have tested everything and it works flawlessly.

Mencent
Reply
#8

Quote:
Originally Posted by Mencent
Посмотреть сообщение
@SickAttack:
That's all it should be. I finish the loop, because the passage does not have to keep running, I have tested everything and it works flawlessly.

Mencent
It's bad practice, you shouldn't return a value in a loop.
Reply
#9

@Mencent for the moment your solution is work but i haven't finish the script so i'am not sure

@SickAttack what's the difference "break" or not?
Reply
#10

i'am back , with another problem, so when i have create the duel , my friend have create another one , but when he do it , my duel will not appear in the duel liste check my code :

PHP код:
        case DIALOG_DUEL_NAME:
        {
            if(
response)
            {
                if(!
strlen(inputtext) || strlen(inputtext) > 32)
                {
                      
ShowPlayerDialog(playeridDIALOG_DUEL_NAMEDIALOG_STYLE_INPUT""COL_RED"Duel - Crйation""Veillez entrer le nom du duel""Confirmer""Annuler");
                }
                else
                {
                    
Total_Duels_Created++;
                    
Duel[Total_Duels_Created][DuelID] = Total_Duels_Created;
                    
Duel[Total_Duels_Created][DuelExiste] = 1;
                    
Duel[Total_Duels_Created][DuelMembers] = 0;
                    
Duel[Total_Duels_Created][LeaderID] = playerid;
                    
Duel[Total_Duels_Created][DuelVW] = playerid;
                    
                    
format(Duel[Total_Duels_Created][DuelName], 32inputtext);
                    
format(Duel[Total_Duels_Created][DuelLeader], 32pName(playerid));
                    
                    
ShowPlayerDialog(playeridDIALOG_DUEL_MAPDIALOG_STYLE_LIST""COL_RED"Duel - Crйation""Jefferson Motel\nJE RAJOUTE APRES...""Confirmer""Annuler");
                }
            }
        } 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)