/settings menu
#1

pawn Код:
CMD:settings (playerid)
{
    if (PlayerInfo[playerid][LoggedIn] == 0) return SendClientMessage(playerid, -1, ""RED"ERROR: "GREY"You must be logged in!");
    if (PlayerInfo[playerid][inDM] == 1) return SendClientMessage(playerid, -1, ""RED"ERROR: "GREY"You cannot access the settings menu in a DM arena! Please /leave to proceed.");
    new string[300];
    new SBstring[30];
    if (Nitro[playerid] == 1) format(SBstring, 30, ""C_RED"Disable"C_WHITE"");
    if (Nitro[playerid] == 0) format(SBstring, 30, ""C_GREEN"Enable"C_WHITE"");
    new AutoFixString[30];
    if (AutoFix[playerid] == 1) format(AutoFixString, 30, ""C_RED"Disable"C_WHITE"");
    if (AutoFix[playerid] == 0) format(AutoFixString, 30, ""C_GREEN"Enable"C_WHITE"");
    new BounceString[30];
    if (Bounce[playerid] == 1) format(BounceString, 30, ""C_RED"Disable"C_WHITE"");
    if (Bounce[playerid] == 0) format(BounceString, 30, ""C_GREEN"Enable"C_WHITE"");
    new AFstring[30];
    if (AntifallEnabled[playerid] == 1) format(AFstring, 30, ""C_RED"Disable"C_WHITE"");
    if (AntifallEnabled[playerid] == 0) format(AFstring, 30, ""C_GREEN"Enable"C_WHITE"");
    new WeaponSetString[30];
    if (PlayerInfo[playerid][WeaponSet] == 0) format(WeaponSetString, 30, ""ORANGE"Standard"C_WHITE"");
    if (PlayerInfo[playerid][WeaponSet] == 1) format(WeaponSetString, 30, ""ORANGE"Advanced"C_WHITE"");
    if (PlayerInfo[playerid][WeaponSet] == 2) format(WeaponSetString, 30, ""ORANGE"Expert"C_WHITE"");
    format(string, 300, "Speedboost (%s)\nAuto Repair (%s)\nBounce (%s)\nAntifall (%s)\nWeapon Set (%s)", SBstring, AutoFixString, BounceString, AFstring, WeaponSetString);
    ShowPlayerDialog(playerid, DIALOG_SETTINGS, DIALOG_STYLE_LIST, ""REDORANGE">> "C_WHITE"Account Settings", string, "OK", "Cancel");
    return 1;
}
pawn Код:
if (dialogid == DIALOG_SETTINGS)
    {
        if (!response) return 1;
        if (response)
        {
            switch (listitem)
            {
                case 0:
                {
                    if (Nitro[playerid] == 1)
                    {
                        Nitro[playerid] = 0;
                    }
                    if (Nitro[playerid] == 0)
                    {
                        Nitro[playerid] = 1;
                    }
                }
                case 1:
                {
                    if (AutoFix[playerid] == 1)
                    {
                        AutoFix[playerid] = 0;
                    }
                    if (AutoFix[playerid] == 0)
                    {
                        AutoFix[playerid] = 1;
                    }
                }
                case 2:
                {
                    if (Bounce[playerid] == 1)
                    {
                        Bounce[playerid] = 0;
                    }
                    if (Bounce[playerid] == 0)
                    {
                        Bounce[playerid] = 1;
                    }
                }
                case 3:
                {
                    if (AntifallEnabled[playerid] == 1)
                    {
                        AntifallEnabled[playerid] = 0;
                    }
                    if (AntifallEnabled[playerid] == 0)
                    {
                        AntifallEnabled[playerid] = 1;
                    }
                }
                case 4:
                {
                    ShowPlayerDialog( playerid, WEAPONSET, DIALOG_STYLE_LIST, "{58C8ED}Weapon Set", ""ORANGE"Standard Weapon Set \n"ORANGE"Advanced Weapon Set {33AA33}($30000)\n"ORANGE"Expert Weapon Set {33AA33}($60000)", "Select", "Cancel" );
                }
            }
            new string[300];
            new SBstring[30];
            if (Nitro[playerid] == 1) format(SBstring, 30, ""C_RED"Disable"C_WHITE"");
            if (Nitro[playerid] == 0) format(SBstring, 30, ""C_GREEN"Enable"C_WHITE"");
            new AutoFixString[30];
            if (AutoFix[playerid] == 1) format(AutoFixString, 30, ""C_RED"Disable"C_WHITE"");
            if (AutoFix[playerid] == 0) format(AutoFixString, 30, ""C_GREEN"Enable"C_WHITE"");
            new BounceString[30];
            if (Bounce[playerid] == 1) format(BounceString, 30, ""C_RED"Disable"C_WHITE"");
            if (Bounce[playerid] == 0) format(BounceString, 30, ""C_GREEN"Enable"C_WHITE"");
            new AFstring[30];
            if (AntifallEnabled[playerid] == 1) format(AFstring, 30, ""C_RED"Disable"C_WHITE"");
            if (AntifallEnabled[playerid] == 0) format(AFstring, 30, ""C_GREEN"Enable"C_WHITE"");
            new WeaponSetString[30];
            if (PlayerInfo[playerid][WeaponSet] == 0) format(WeaponSetString, 30, ""ORANGE"Standard"C_WHITE"");
            if (PlayerInfo[playerid][WeaponSet] == 1) format(WeaponSetString, 30, ""ORANGE"Advanced"C_WHITE"");
            if (PlayerInfo[playerid][WeaponSet] == 2) format(WeaponSetString, 30, ""ORANGE"Expert"C_WHITE"");
            format(string, 300, "Speedboost (%s)\nAuto Repair (%s)\nBounce (%s)\nAntifall (%s)\nWeapon Set (%s)", SBstring, AutoFixString, BounceString, AFstring, WeaponSetString);
            ShowPlayerDialog(playerid, DIALOG_SETTINGS, DIALOG_STYLE_LIST, ""REDORANGE">> "C_WHITE"Account Settings", string, "OK", "Cancel");
        }
    }
Whenever I click on any option ingame, it returns to the first option (speedboost) and doesn't change the disable to enable (no effect on the speedboost, antifall and others)..it is not working..
Reply
#2

I'm not sure about your problem, but on a sidenote, here's a neat little trick:

Instead of doing this:
pawn Код:
if (AutoFix[playerid] == 1)
{
    AutoFix[playerid] = 0;
}
if (AutoFix[playerid] == 0)
{
    AutoFix[playerid] = 1;
}
You can simply do this:

pawn Код:
AutoFix[playerid] = !AutoFix[playerid];
This will 'switch' it. If it's currently 0, it becomes 1, and if it's 1, it becomes 0.

Also, you should always check true/false statements like this:

pawn Код:
if(variable)

if(!variable)
not

pawn Код:
if(variable == 1)

if(variable == 0)

// (or even 'true'/'false')
Reply
#3

Thanks for the reply.
I used else if in the second statement and it worked, everything is working except the weapon set item.
pawn Код:
if (dialogid == DIALOG_SETTINGS)
    {
        if (!response) return 1;
        if (response)
        {
            switch (listitem)
            {
                case 0:
                {
                    if (Nitro[playerid] == 1)
                    {
                        Nitro[playerid] = 0;
                    }
                    else if (Nitro[playerid] == 0)
                    {
                        Nitro[playerid] = 1;
                    }
                }
                case 1:
                {
                    if (AutoFix[playerid] == 1)
                    {
                        AutoFix[playerid] = 0;
                    }
                    else if (AutoFix[playerid] == 0)
                    {
                        AutoFix[playerid] = 1;
                    }
                }
                case 2:
                {
                    if (Bounce[playerid] == 1)
                    {
                        Bounce[playerid] = 0;
                    }
                    else if (Bounce[playerid] == 0)
                    {
                        Bounce[playerid] = 1;
                    }
                }
                case 3:
                {
                    if (AntifallEnabled[playerid] == 1)
                    {
                        AntifallEnabled[playerid] = 0;
                    }
                    else if (AntifallEnabled[playerid] == 0)
                    {
                        AntifallEnabled[playerid] = 1;
                    }
                }
                case 4:
                {
                    ShowPlayerDialog( playerid, WEAPONSET, DIALOG_STYLE_LIST, "{58C8ED}Weapon Set", ""ORANGE"Standard Weapon Set \n"ORANGE"Advanced Weapon Set {33AA33}($30000)\n"ORANGE"Expert Weapon Set {33AA33}($60000)", "Select", "Cancel" );
                }
            }
            new string[300];
            new SBstring[30];
            if (Nitro[playerid] == 1) format(SBstring, 30, ""C_RED"Disable"C_WHITE"");
            if (Nitro[playerid] == 0) format(SBstring, 30, ""C_GREEN"Enable"C_WHITE"");
            new AutoFixString[30];
            if (AutoFix[playerid] == 1) format(AutoFixString, 30, ""C_RED"Disable"C_WHITE"");
            if (AutoFix[playerid] == 0) format(AutoFixString, 30, ""C_GREEN"Enable"C_WHITE"");
            new BounceString[30];
            if (Bounce[playerid] == 1) format(BounceString, 30, ""C_RED"Disable"C_WHITE"");
            if (Bounce[playerid] == 0) format(BounceString, 30, ""C_GREEN"Enable"C_WHITE"");
            new AFstring[30];
            if (AntifallEnabled[playerid] == 1) format(AFstring, 30, ""C_RED"Disable"C_WHITE"");
            if (AntifallEnabled[playerid] == 0) format(AFstring, 30, ""C_GREEN"Enable"C_WHITE"");
            new WeaponSetString[30];
            if (PlayerInfo[playerid][WeaponSet] == 0) format(WeaponSetString, 30, ""ORANGE"Standard"C_WHITE"");
            if (PlayerInfo[playerid][WeaponSet] == 1) format(WeaponSetString, 30, ""ORANGE"Advanced"C_WHITE"");
            if (PlayerInfo[playerid][WeaponSet] == 2) format(WeaponSetString, 30, ""ORANGE"Expert"C_WHITE"");
            format(string, 300, "Speedboost (%s)\nAuto Repair (%s)\nBounce (%s)\nAntifall (%s)\nWeapon Set (%s)", SBstring, AutoFixString, BounceString, AFstring, WeaponSetString);
            ShowPlayerDialog(playerid, DIALOG_SETTINGS, DIALOG_STYLE_LIST, ""REDORANGE">> "C_WHITE"Account Settings", string, "OK", "Cancel");
        }
    }
The last option does not open the weaponset dialog. It re-opens the /settings menu (I want it to happen only with the first four options not with the last)
Reply
#4

Add debug messages to see what's happening.
Reply
#5

Both the dialogs open when I select 'Weapon Set' option.
pawn Код:
weapon set dialog opened
settings dialog opened
I want to re-open the settings dialog only for the first 4 options not with the last 'weapon set' option. Is there any way to do this?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)