Editing the dialog box
#1

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?
Reply
#2

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.
Reply
#3

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?
Reply
#4

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 !!
Reply
#5

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
Reply
#6

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!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)