SA-MP Forums Archive
Dialog not giving weapons / skins - 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 not giving weapons / skins (/showthread.php?tid=527045)



Dialog not giving weapons / skins - Cole_William - 20.07.2014

So my issue is, that the dialogs if you click on the guns or skins it wont give you or set you any of them, now the "Duty" button works, it sets their duty color corectly but nothing else.

Defines:
http://pastebin.com/3ETsdS8g

Command:
http://pastebin.com/wkn1WqRf

Dialog:
http://pastebin.com/sdP9jNMK


Re: Dialog not giving weapons / skins - Cole_William - 20.07.2014

Anyone?


Re: Dialog not giving weapons / skins - Scottas - 20.07.2014

can't see problem here. Do you have more filterscripts, that uses OnDialogResponse?


Re: Dialog not giving weapons / skins - Cole_William - 20.07.2014

No Filterscripts, everything is coded in the script.


Re: Dialog not giving weapons / skins - Cole_William - 20.07.2014

Ok, so does this mean my script is just screwed without reason?


Re: Dialog not giving weapons / skins - Cole_William - 20.07.2014

I've tried switching the cases too

pawn Код:
if(listitem == 2)
But just returned a lot of errors. Does no one know what's wrong?


Re: Dialog not giving weapons / skins - Scottas - 20.07.2014

Oh, I see the problem. Bad script identation caused it, be carefull with it, look what you have:
pawn Код:
if(dialogid == DIALOG_LOCKER)
{
    if( response )
    {
        switch(listitem)
        {
            case 0: // Duty
            {
                if(PlayerInfo[playerid][pBadge] == 0)
                {
                    PlayerInfo[playerid][pBadge] = 1;
                    SetPlayerColor(playerid, GetFactionColor(playerid));
                }
                else if(PlayerInfo[playerid][pBadge] == 1)
                {
                    PlayerInfo[playerid][pBadge] = 0;
                    SetPlayerColor(playerid, COLOR_WHITE);
                }
            }
            case 1: // Weapons
            {
                if(PlayerInfo[playerid][pFaction] == 1) // GOV Weapon Choice
                {
                    ShowPlayerDialog(playerid, DIALOG_GOVWEAPONS, DIALOG_STYLE_LIST, "GOV Weapons", "Baton\nPepper Spray\nDeagle", "Select","Cancel");
                }
                if(PlayerInfo[playerid][pFaction] == 2) // LSPD Weapons Choice
                {
                    ShowPlayerDialog(playerid, DIALOG_LSPDWEAPONS, DIALOG_STYLE_LIST, "LSPD Weapons", "Baton\nPepper Spray\nDeagle", "Select","Cancel");
                }
            }
            case 2: // Skins
            {
                if(PlayerInfo[playerid][pFaction] == 1) // GOV Skin Choice
                {
                    ShowPlayerDialog(playerid, DIALOG_GOVSKINS, DIALOG_STYLE_LIST, "Skins", "Vacant\nVacant\nVacant", "Select","Cancel");
                }
                if(PlayerInfo[playerid][pFaction] == 2) // LSPD Skin Choice
                {
                    ShowPlayerDialog(playerid, DIALOG_LSPDSKINS, DIALOG_STYLE_LIST, "Skins", "Vacant\nVacant\nVacant", "Select","Cancel");
                }
            }
        }
    }
    if(dialogid == DIALOG_GOVWEAPONS) // Gov Weapons
    {
        if(response)
        {
            switch(listitem)
            {
                case 0: // Baton
                {
                    GivePlayerWeapon(playerid, 3, 0);
                }
                case 1: // Pepperspray
                {
                    GivePlayerWeapon(playerid, 41, 100);
                }
                case 2: // Deagle
                {
                    GivePlayerWeapon(playerid, 24, 100);
                }
            }
        }
    }

    if(dialogid == DIALOG_LSPDWEAPONS) // LSPD Weapons
    {
        if(response)
        {
            switch(listitem)
            {
                case 0: // Baton
                {
                    GivePlayerWeapon(playerid, 3, 0);
                }
                case 1: // Pepperspray
                {
                    GivePlayerWeapon(playerid, 41, 100);
                }
                case 2: // Deagle
                {
                    GivePlayerWeapon(playerid, 24, 100);
                }
            }
        }
    }

    if(dialogid == DIALOG_GOVSKINS) // GOV Skins
    {
        if(response)
        {
            switch(listitem)
            {
                case 0: // Empty
                {
                    PlayerInfo[playerid][pSkin] = 281;
                    SetPlayerSkin(playerid, 281);
                }
                case 1: // Empty
                {
                    PlayerInfo[playerid][pSkin] = 281;
                    SetPlayerSkin(playerid, 281);
                }
                case 2: // Empty
                {
                    PlayerInfo[playerid][pSkin] = 281;
                    SetPlayerSkin(playerid, 281);
                }
            }
        }
    }
    if(dialogid == DIALOG_LSPDSKINS) // LSPD Skins
    {
        if(response)
        {
            switch(listitem)
            {
                case 0: // Empty
                {
                    PlayerInfo[playerid][pSkin] = 281;
                    SetPlayerSkin(playerid, 281);
                }
                case 1: // Empty
                {
                    PlayerInfo[playerid][pSkin] = 281;
                    SetPlayerSkin(playerid, 281);
                }
                case 2: // Empty
                {
                    PlayerInfo[playerid][pSkin] = 281;
                    SetPlayerSkin(playerid, 281);
                }
            }
        }
    }
}
Do you see what's wrong? All code is inside first check, so other dialogid checks allways returns false, because the first one is true.


Re: Dialog not giving weapons / skins - Cole_William - 20.07.2014

Quote:
Originally Posted by Scottas
Посмотреть сообщение
Oh, I see the problem. Bad script identation caused it, be carefull with it, look what you have:
pawn Код:
if(dialogid == DIALOG_LOCKER)
{
    if( response )
    {
        switch(listitem)
        {
            case 0: // Duty
            {
                if(PlayerInfo[playerid][pBadge] == 0)
                {
                    PlayerInfo[playerid][pBadge] = 1;
                    SetPlayerColor(playerid, GetFactionColor(playerid));
                }
                else if(PlayerInfo[playerid][pBadge] == 1)
                {
                    PlayerInfo[playerid][pBadge] = 0;
                    SetPlayerColor(playerid, COLOR_WHITE);
                }
            }
            case 1: // Weapons
            {
                if(PlayerInfo[playerid][pFaction] == 1) // GOV Weapon Choice
                {
                    ShowPlayerDialog(playerid, DIALOG_GOVWEAPONS, DIALOG_STYLE_LIST, "GOV Weapons", "Baton\nPepper Spray\nDeagle", "Select","Cancel");
                }
                if(PlayerInfo[playerid][pFaction] == 2) // LSPD Weapons Choice
                {
                    ShowPlayerDialog(playerid, DIALOG_LSPDWEAPONS, DIALOG_STYLE_LIST, "LSPD Weapons", "Baton\nPepper Spray\nDeagle", "Select","Cancel");
                }
            }
            case 2: // Skins
            {
                if(PlayerInfo[playerid][pFaction] == 1) // GOV Skin Choice
                {
                    ShowPlayerDialog(playerid, DIALOG_GOVSKINS, DIALOG_STYLE_LIST, "Skins", "Vacant\nVacant\nVacant", "Select","Cancel");
                }
                if(PlayerInfo[playerid][pFaction] == 2) // LSPD Skin Choice
                {
                    ShowPlayerDialog(playerid, DIALOG_LSPDSKINS, DIALOG_STYLE_LIST, "Skins", "Vacant\nVacant\nVacant", "Select","Cancel");
                }
            }
        }
    }
    if(dialogid == DIALOG_GOVWEAPONS) // Gov Weapons
    {
        if(response)
        {
            switch(listitem)
            {
                case 0: // Baton
                {
                    GivePlayerWeapon(playerid, 3, 0);
                }
                case 1: // Pepperspray
                {
                    GivePlayerWeapon(playerid, 41, 100);
                }
                case 2: // Deagle
                {
                    GivePlayerWeapon(playerid, 24, 100);
                }
            }
        }
    }

    if(dialogid == DIALOG_LSPDWEAPONS) // LSPD Weapons
    {
        if(response)
        {
            switch(listitem)
            {
                case 0: // Baton
                {
                    GivePlayerWeapon(playerid, 3, 0);
                }
                case 1: // Pepperspray
                {
                    GivePlayerWeapon(playerid, 41, 100);
                }
                case 2: // Deagle
                {
                    GivePlayerWeapon(playerid, 24, 100);
                }
            }
        }
    }

    if(dialogid == DIALOG_GOVSKINS) // GOV Skins
    {
        if(response)
        {
            switch(listitem)
            {
                case 0: // Empty
                {
                    PlayerInfo[playerid][pSkin] = 281;
                    SetPlayerSkin(playerid, 281);
                }
                case 1: // Empty
                {
                    PlayerInfo[playerid][pSkin] = 281;
                    SetPlayerSkin(playerid, 281);
                }
                case 2: // Empty
                {
                    PlayerInfo[playerid][pSkin] = 281;
                    SetPlayerSkin(playerid, 281);
                }
            }
        }
    }
    if(dialogid == DIALOG_LSPDSKINS) // LSPD Skins
    {
        if(response)
        {
            switch(listitem)
            {
                case 0: // Empty
                {
                    PlayerInfo[playerid][pSkin] = 281;
                    SetPlayerSkin(playerid, 281);
                }
                case 1: // Empty
                {
                    PlayerInfo[playerid][pSkin] = 281;
                    SetPlayerSkin(playerid, 281);
                }
                case 2: // Empty
                {
                    PlayerInfo[playerid][pSkin] = 281;
                    SetPlayerSkin(playerid, 281);
                }
            }
        }
    }
}
Do you see what's wrong? All code is inside first check, so other dialogid checks allways returns false, because the first one is true.
I don't see nor understand, i am a new scripter so you gotta explain a bit more please.


Re: Dialog not giving weapons / skins - Scottas - 20.07.2014

I've explained as I could, there is working version of your code:
pawn Код:
if(dialogid == DIALOG_LOCKER)
{
    if( response )
    {
        switch(listitem)
        {
            case 0: // Duty
            {
                if(PlayerInfo[playerid][pBadge] == 0)
                {
                    PlayerInfo[playerid][pBadge] = 1;
                    SetPlayerColor(playerid, GetFactionColor(playerid));
                }
                else if(PlayerInfo[playerid][pBadge] == 1)
                {
                    PlayerInfo[playerid][pBadge] = 0;
                    SetPlayerColor(playerid, COLOR_WHITE);
                }
            }
            case 1: // Weapons
            {
                if(PlayerInfo[playerid][pFaction] == 1) // GOV Weapon Choice
                {
                    ShowPlayerDialog(playerid, DIALOG_GOVWEAPONS, DIALOG_STYLE_LIST, "GOV Weapons", "Baton\nPepper Spray\nDeagle", "Select","Cancel");
                }
                if(PlayerInfo[playerid][pFaction] == 2) // LSPD Weapons Choice
                {
                    ShowPlayerDialog(playerid, DIALOG_LSPDWEAPONS, DIALOG_STYLE_LIST, "LSPD Weapons", "Baton\nPepper Spray\nDeagle", "Select","Cancel");
                }
            }
            case 2: // Skins
            {
                if(PlayerInfo[playerid][pFaction] == 1) // GOV Skin Choice
                {
                    ShowPlayerDialog(playerid, DIALOG_GOVSKINS, DIALOG_STYLE_LIST, "Skins", "Vacant\nVacant\nVacant", "Select","Cancel");
                }
                if(PlayerInfo[playerid][pFaction] == 2) // LSPD Skin Choice
                {
                    ShowPlayerDialog(playerid, DIALOG_LSPDSKINS, DIALOG_STYLE_LIST, "Skins", "Vacant\nVacant\nVacant", "Select","Cancel");
                }
            }
        }
    }
}
if(dialogid == DIALOG_GOVWEAPONS) // Gov Weapons
{
    if(response)
    {
        switch(listitem)
        {
            case 0: // Baton
            {
                GivePlayerWeapon(playerid, 3, 0);
            }
            case 1: // Pepperspray
            {
                GivePlayerWeapon(playerid, 41, 100);
            }
            case 2: // Deagle
            {
                GivePlayerWeapon(playerid, 24, 100);
            }
        }
    }
}

if(dialogid == DIALOG_LSPDWEAPONS) // LSPD Weapons
{
    if(response)
    {
        switch(listitem)
        {
            case 0: // Baton
            {
                GivePlayerWeapon(playerid, 3, 0);
            }
            case 1: // Pepperspray
            {
                GivePlayerWeapon(playerid, 41, 100);
            }
            case 2: // Deagle
            {
                GivePlayerWeapon(playerid, 24, 100);
            }
        }
    }
}

if(dialogid == DIALOG_GOVSKINS) // GOV Skins
{
    if(response)
    {
        switch(listitem)
        {
            case 0: // Empty
            {
                PlayerInfo[playerid][pSkin] = 281;
                SetPlayerSkin(playerid, 281);
            }
            case 1: // Empty
            {
                PlayerInfo[playerid][pSkin] = 281;
                SetPlayerSkin(playerid, 281);
            }
            case 2: // Empty
            {
                PlayerInfo[playerid][pSkin] = 281;
                SetPlayerSkin(playerid, 281);
            }
        }
    }
}
if(dialogid == DIALOG_LSPDSKINS) // LSPD Skins
{
    if(response)
    {
        switch(listitem)
        {
            case 0: // Empty
            {
                PlayerInfo[playerid][pSkin] = 281;
                SetPlayerSkin(playerid, 281);
            }
            case 1: // Empty
            {
                PlayerInfo[playerid][pSkin] = 281;
                SetPlayerSkin(playerid, 281);
            }
            case 2: // Empty
            {
                PlayerInfo[playerid][pSkin] = 281;
                SetPlayerSkin(playerid, 281);
            }
        }
    }
}