SA-MP Forums Archive
Editing the dialog box - 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: Editing the dialog box (/showthread.php?tid=604666)



Editing the dialog box - fuckingcruse - 08.04.2016

YO! I wanted to ask that. Like if it's a /help command. If a player is admin then a new line adds in the DIALOG_STYLE_LIST. If he is not admin then it's a normal help command.

For example : my help cmd shows 4 items in list.
If the player is set admin then the help cmd shows him 5th item as ADMIN cmds.

Can you explain how can it be?


Re: Editing the dialog box - AndySedeyn - 08.04.2016

You can use an if-else-statement. Considering that a /help command handles no variables and thus doesn't need any formatting:
PHP код:
if(AdminLevel[playerid] > 0) {
    
// Replace 'AdminLevel[playerid]' with w/e the variable name is that you store the admin level in.
    // Admin level > 0, player is an admin.
    
ShowPlayerDialog(playeridDIALOG_IDDIALOG_STYLE_LIST"HELP""Player commands\nAdmin Commands""Choose""Close");
}
else {
    
// Admin level == 0 or < 0, player is not an admin.
    
ShowPlayerDialog(playeridOTHER_DIALOG_IDDIALOG_STYLE_LIST"HELP""Player commands""Continue""Close");

So basically you've got two completely different dialogs with each a different ID.


Re: Editing the dialog box - fuckingcruse - 08.04.2016

But for example there is also a separate group for example scripters. Now if the player is admin and scripter both then how can i add both of them?


Re: Editing the dialog box - Akbaig - 08.04.2016

PHP код:
if(AdminLevel[playerid] > 0

    
// Replace 'AdminLevel[playerid]' with w/e the variable name is that you store the admin level in. 
    // Admin level > 0, player is an admin. 
    
ShowPlayerDialog(playeridDIALOG_IDDIALOG_STYLE_LIST"HELP""Player commands\nAdmin Commands""Choose""Close"); 

else if(
AdminLevel[playerid] > && IsScripter[playerid])

     
// replace the " IsScripter" variable according to your script
    // Admin level > 0 and is scripter, means  player is an admin and also a scripter  
    
ShowPlayerDialog(playeridOTHER_DIALOG_IDDIALOG_STYLE_LIST"HELP""Player commands\nAdmin Commands\n Scripter Commands""Continue""Close"); 
}
else

    
// Admin level == 0 or < 0, player is neither an admin nor a scripter. 
    
ShowPlayerDialog(playeridOTHER_DIALOG_IDDIALOG_STYLE_LIST"HELP""Player commands""Continue""Close"); 

Rep++ me if I helped you please !!


Re: Editing the dialog box - AndySedeyn - 08.04.2016

A nested if would be better than an else-if. An else-if basically compiles to something like
PHP код:
if(condition) {
    
// first if-statement
}
else {
    if(
condition) {
        
// First else-if statement
    
}
    else {
        if(
condition() {
            
// Second else-if statement
        
}
        else {
            
// Last else
        
}
    }

While the nested if statement would look more like:
PHP код:
if(condition) {
    
// code
    
if(condition) {
        
// code
    
}
    
// code
}
else {
    
// first else

http://forum.sa-mp.com/showpost.php?...6&postcount=10


Re: Editing the dialog box - Akbaig - 08.04.2016

I know right...

I modified your code to make him understand, so that he doesn't get confused between these two.

More precisely, through my code, he would also get a knowledge about the ' use of AND ' in if-then-else statement!