Dialog response always the same?!
#1

PHP код:
enum GradeInfo 

    
gRank,
    
gLevel,
    
gName[32],
    
Float:gHealth,
    
Float:gArmor
}
// Here I have Grades and the rank number they belong.
new MafiaGrade[][GradeInfo] = 
{
    { -
1, -1"None"0.00.0}, // Blank row that fixes some variables. (Add new levels below this row)
    
1DEFAULT_LEVEL"Junior Associate"99.00.0 },
    { 
13"Senior Associate"99.00.0 },
    { 
23"Newbie Crook"99.00.0 },
    { 
244"Experienced Crook"99.00.0 },
    { 
322"Light Gunner"99.00.0 },
    { 
311"Heavy Gunner"99.00.0 }
};
        
// In this function I check if there is any grade for X (TeamRank variable) rank.
        // If it's exist, I add it in the dialog list.
            
for(1sizeof(MafiaGrade); i++)
            {
                
dmsg[0] = EOS;
                
                if(
MafiaGrade[i][gRank] != TeamRank[playerid])
                {
                    continue;
                }
                
                
format(dmsgsizeof(dmsg), "\n"col_team_mafia"%s \t %d"MafiaGrade[i][gName], MafiaGrade[i][gLevel]);
                
strcat(stringdmsg);
                
gcounter++;
            }
                    
    
format(dmsgsizeof(dmsg), "\n"col_team_mafia"%s \t %d"MafiaGrade[i][gName], MafiaGrade[i][gLevel]);
    
strcat(stringdmsg);
       
ShowPlayerDialog(playeridDIALOG_GRADE_MAFIADIALOG_STYLE_TABLIST_HEADERS"Choose your grade"string"Select""Cancel");
            if(!
gcounter)
            {
                
SendErrorMessage(playerid"There is no available grades for your current rank (%s)."RankName(playeridTeamRank[playerid]));
            }
            else
            {
                
ShowPlayerDialog(playeridDIALOG_GRADE_MAFIADIALOG_STYLE_TABLIST_HEADERS"Choose your grade"string"Select""Cancel");        
            } 
Everythyng above is working great, and for example if I am rank 2, in dialog it shows me "Newbie Crook" and "Experienced Crook", but the problem is when I select Newbie Crook, It gives me Junior Associate, and if I select Experienced Crook it gives me Advanced Associate, why?
No matter what rank I am, it only gives me those two, what is the problem?
Reply
#2

You are probably using the listitem index to reference your array but not considering lining up the values correctly.
Reply
#3

I got it what I am doing wrong but don't know to fix it :S
I loop through all grades and check if there is any grade that is made for (for example) rank 3.
If there is such grade(s) I add them to dialog.
PHP код:
        case TEAM_MAFIA:
        {
            for(
1sizeof(MafiaGrade); i++)
            {
                
dmsg[0] = EOS;
                
                if(
MafiaGrade[i][gRank] != TeamRank[playerid])
                {
                    continue;
                }
                
                
format(dmsgsizeof(dmsg), "\n"col_team_mafia"%s \t %d"MafiaGrade[i][gName], MafiaGrade[i][gLevel]);
                
strcat(stringdmsg);
                
gcounter++;
            }
            
            if(!
gcounter)
            {
                
SendErrorMessage(playerid"There is no available grades for your current rank (%s)."RankName(playeridTeamRank[playerid]));
            }
            else
            {
                
ShowPlayerDialog(playeridDIALOG_GRADE_MAFIADIALOG_STYLE_TABLIST_HEADERS"Choose your grade"string"Select""Cancel");        
            }        
        } 
But here is the problem, in OnDialogResponse, I am always checking this:
PHP код:
MafiaGrade[listitem 1][gLevel
Pay attention on MafiaGrade[listitem + 1][gLevel]
As we all know, listitem will be always from 0 and up
In this case since in player's dialog are show grades for rank 3 (Light and Heavy gunner).
But they won't be executed through OnDialogResponse becouse that is listitem = 0, and listitem = 1,
and since I'm checking like this MafiaGrade[listitem + 1][gLevel] if you look in my variable,
it only first two grades will be executed through OnDialogResponse

PHP код:
new MafiaGrade[][GradeInfo] =  

    { -
1, -1"None"0.00.0}, // Blank row that fixes some variables. (Add new levels below this row) 
    
1DEFAULT_LEVEL"Junior Associate"99.00.0 }, // listitem = 0
    
13"Senior Associate"99.00.0 }, // listitem = 1
    
23"Newbie Crook"99.00.0 }, 
    { 
244"Experienced Crook"99.00.0 }, 
    { 
322"Light Gunner"99.00.0 }, 
    { 
311"Heavy Gunner"99.00.0 
}; 
Is there any way to fix this?
Reply
#4

There is a couple of ways you could simply add the data to your dialog text and extract from the list item. Or you could use a variable to store what listitem's reference which array indexes. Or you might even just need to save the offset if there is no gaps in which indexes are referenced in your dialog input. ex - Item 1,2,3 do not reference index 0, 3, 6 That would break that method and you would need larger arrays. You could also use y_inline/y_dialog for your dialogs then you don't need MAX_PLAYER arrays at all! Just one array large enough to store the maximum number of listitems you would ever expect to have. This is personally my favorite method.
Reply
#5

Quote:
Originally Posted by Pottus
Посмотреть сообщение
Or you could use a variable to store what listitem's reference which array indexes
How I could do that? Can you please me provide quick example how that works?
Reply
#6

https://sampforum.blast.hk/showthread.php?tid=570904

Код:
    inline Response(pid, dialogid, response, listitem, string:inputtext[])
    {
        #pragma unused pid, dialogid, response, listitem, inputtext
        SendClientMessage(playerid, 0xFF0000AA, "You clicked a button!  Good for you!");
        // Inline function will end here.
    }
    Dialog_ShowCallback(playerid, using inline Response, DIALOG_STYLE_MSGBOX, "Title", "Message", "Button 1");
    // Main function will end here.
What is good about this way is variables are saved even though the initial function call is completed.
https://github.com/Pottus/Texture-St...dio/tsmain.pwn
Line: 2725

See how exportmap is actually saved? So you could just create a small array to store what is what then reference it when that dialog gets a response. Doesn't matter how long that takes either.
Reply
#7

I see this for the first time in my life, I will be hones, I have no idea how to use this method in my case.
But, I think that few lines of code as an example for for my case will help me to understand this, so is there any chance you or someone who understand that how to apply this method in my code show me an example?
I wrote over 5K lines and I can't beleve that I'm stuck with this..
Reply
#8

u fukin kidding me 5k lines for a mafia script
Reply
#9

Quote:
Originally Posted by TheToretto
Посмотреть сообщение
u fukin kidding me 5k lines for a mafia script
Don't post here with comments like that just to increase your number of posts.
I asked for help, if you can't or don't want to help me, please leave this topic, thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)