SA-MP Forums Archive
Dialog Response, Get Duel ID - 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 Response, Get Duel ID (/showthread.php?tid=570557)



Dialog Response, Get Duel ID - AlexBlack - 11.04.2015

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");
                } 



AW: Dialog Response, Get Duel ID - Mencent - 11.04.2015

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


Re : Dialog Response, Get Duel ID - AlexBlack - 11.04.2015

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.


Re: Dialog Response, Get Duel ID - SickAttack - 11.04.2015

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


AW: Dialog Response, Get Duel ID - Mencent - 11.04.2015

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


Re: AW: Dialog Response, Get Duel ID - SickAttack - 11.04.2015

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.


AW: Dialog Response, Get Duel ID - Mencent - 11.04.2015

@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


Re: AW: Dialog Response, Get Duel ID - SickAttack - 11.04.2015

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.


Re : Dialog Response, Get Duel ID - AlexBlack - 11.04.2015

@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?


Re : Dialog Response, Get Duel ID - AlexBlack - 11.04.2015

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");
                }
            }
        }