Implementing 24/7 shop Dialog Error
#1

Im attempting to implement a simple 24/7 shop dialog i got from Sa-mp Wiki my only errors are the following.
What am i doing wrong? Can someone help me correct these and explain it as well?
pawn Код:
C:\Users\Tab\Desktop\True Roleplay [0.3c]\True Roleplay [0.3c]\gamemodes\TRP.pwn(91) : warning 201: redefinition of constant/macro (symbol "CMD:%1(%2)")
C:\Users\Tab\Desktop\True Roleplay [0.3c]\True Roleplay [0.3c]\gamemodes\TRP.pwn(2080) : error 002: only a single statement (or expression) can follow each "case"
C:\Users\Tab\Desktop\True Roleplay [0.3c]\True Roleplay [0.3c]\gamemodes\TRP.pwn(2080 -- 2081) : error 028: invalid subscript (not an array or too many subscripts): "response"
C:\Users\Tab\Desktop\True Roleplay [0.3c]\True Roleplay [0.3c]\gamemodes\TRP.pwn(2080 -- 2082) : error 001: expected token: "}", but found "switch"
C:\Users\Tab\Desktop\True Roleplay [0.3c]\True Roleplay [0.3c]\gamemodes\TRP.pwn(2080 -- 2082) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.
Lines
pawn Код:
if(response)// line 2080
    { //line 2081
    switch(7)//line 2081
pawn Код:
if(response)// They pressed the first button.
    {
    switch(7)// If you only have one dialog, then this isn't required, but it's neater for when you implement more dialogs.
        {
        case 7:// Our dialog!
            {
            switch(listitem)// Checking which listitem was selected
            {
                case 0:// The first item listed
                {
                    if(GetPlayerMoney(playerid) < 1) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
                    GivePlayerMoney(playerid, -1);
                    SetPlayerSpecialAction(playerid, SPECIAL_ACTION_DRINK_SPRUNK);
                }
                case 1: // The second item listed
                {
                    if(GetPlayerMoney(playerid) < 2) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
                    GivePlayerMoney(playerid, -2);
                    SetPlayerSpecialAction(playerid, SPECIAL_ACTION_DRINK_BEER);
                }
                case 2: // The third item listed
                {
                    if(GetPlayerMoney(playerid) < 3) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
                    GivePlayerMoney(playerid, -3);
                    SetPlayerSpecialAction(playerid, SPECIAL_ACTION_DRINK_WINE);
                }
            }
        }
    }
    return 1;
}
Reply
#2

Can you show some lines above 2080 please ?
Reply
#3

Dialog Above 2080 is my Age dialog for registering

pawn Код:
case DIALOG_AGE:
        {
            if(response)
            {
                PlayerInfo[playerid][pAge] = strval(inputtext);
                new string[64];
                format(string, sizeof(string),"So you are %s years old", inputtext);
                SendClientMessage(playerid, COLOR_YELLOW2, string);
                if(strval(inputtext) <= 15)
                {
                    SendClientMessage(playerid, COLOR_WHITE, "SERVER: This is a 16+ Only Server, Grow up and Come Back.");
                    Kick(playerid);
                    return 1;
                }
                if(strval(inputtext) >= 101)
                {
                    SendClientMessage(playerid, COLOR_WHITE, "George: Im sorry our records indicate thats not valid");
                    ShowPlayerDialog(playerid,6,DIALOG_STYLE_INPUT,"Social Security Office:Age","How Old did you say you were again?","Submit","Cancel");
                    return 1;
                }
                SetSpawnInfo(playerid, 0, 0, 1481.0886, -1756.8551, 17.5313, 359.6866, 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);
            }
            else
            {
                Kick(playerid);
            }
        }//2079 so on so forth ^^
Reply
#4

pawn Код:
case DIALOG_AGE:
    {
        if(response)
        {
            PlayerInfo[playerid][pAge] = strval(inputtext);
            new string[64];
            format(string, sizeof(string),"So you are %s years old", inputtext);
            SendClientMessage(playerid, COLOR_YELLOW2, string);
            if(strval(inputtext) <= 15)
            {
                    SendClientMessage(playerid, COLOR_WHITE, "SERVER: This is a 16+ Only Server, Grow up and Come Back.");
                    Kick(playerid);
                    return 1;
            }
            if(strval(inputtext) >= 101)
            {
                    SendClientMessage(playerid, COLOR_WHITE, "George: Im sorry our records indicate thats not valid");
                    ShowPlayerDialog(playerid,6,DIALOG_STYLE_INPUT,"Social Security Office:Age","How Old did you say you were again?","Submit","Cancel");
                    return 1;
            }
            SetSpawnInfo(playerid, 0, 0, 1481.0886, -1756.8551, 17.5313, 359.6866, 0, 0, 0, 0, 0, 0);
            SpawnPlayer(playerid);
        }
        else
        {
            Kick(playerid);
        }
    }
    case 7:
    {
        if( !response ) return 0;
        if( response )
        {
            switch( listitem )
            {
                case 0:// The first item listed
                {
                    if(GetPlayerMoney(playerid) < 1) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
                    GivePlayerMoney(playerid, -1);
                    SetPlayerSpecialAction(playerid, SPECIAL_ACTION_DRINK_SPRUNK);
                }
                case 1: // The second item listed
                {
                    if(GetPlayerMoney(playerid) < 2) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
                    GivePlayerMoney(playerid, -2);
                    SetPlayerSpecialAction(playerid, SPECIAL_ACTION_DRINK_BEER);
                }
                case 2: // The third item listed
                {
                    if(GetPlayerMoney(playerid) < 3) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
                    GivePlayerMoney(playerid, -3);
                    SetPlayerSpecialAction(playerid, SPECIAL_ACTION_DRINK_WINE);
                }
            }
        }
    }
    // Next dialogs
Reply
#5

So you are doing the
pawn Код:
if(response)// line 2080
    { //line 2081
    switch(7)//line 2081
inside the
pawn Код:
case DIALOG_AGE:
?!

If so, you have
pawn Код:
if(response)
twice in the same case
Reply
#6

@Smit If i use your code i get this

pawn Код:
C:\Users\Tab\Desktop\True Roleplay [0.3c]\True Roleplay [0.3c]\gamemodes\TRP.pwn(91) : warning 201: redefinition of constant/macro (symbol "CMD:%1(%2)")
C:\Users\Tab\Desktop\True Roleplay [0.3c]\True Roleplay [0.3c]\gamemodes\TRP.pwn(2110) : error 002: only a single statement (or expression) can follow each "case"
C:\Users\Tab\Desktop\True Roleplay [0.3c]\True Roleplay [0.3c]\gamemodes\TRP.pwn(2110) : warning 215: expression has no effect
C:\Users\Tab\Desktop\True Roleplay [0.3c]\True Roleplay [0.3c]\gamemodes\TRP.pwn(2111) : warning 209: function "OnDialogResponse" should return a value
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
@Drebin
how would i correct it because if i remove anything it gives me errors on everything in my script.
Reply
#7

function "OnDialogResponse" should return a value - self-explanatory
Wich line is 2110 ?
Reply
#8

Quote:
Originally Posted by SmiT
Посмотреть сообщение
function "OnDialogResponse" should return a value - self-explanatory
Wich line is 2110 ?
That is the Return value

pawn Код:
return 1;
Reply
#9

-.- Just post the whole OnDialogResponse
Reply
#10

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"Level",1);
                INI_WriteInt(File,"Cash", 10000);
                GivePlayerMoney(playerid, 10000);
                INI_WriteInt(File,"Sex",0);
                INI_WriteInt(File,"Age",0);
                INI_WriteInt(File,"Skin",0);
                INI_WriteInt(File,"Leader",0);
                INI_WriteInt(File,"Rank",0);
                INI_WriteInt(File,"Team",0);
                INI_WriteInt(File,"Member",0);
                INI_WriteInt(File,"Admin",0);
                INI_WriteInt(File,"VIP",0);
                INI_WriteInt(File,"Muted",0);
                INI_WriteInt(File,"Tutorial",0);
                INI_WriteInt(File,"Mute Time",0);
                INI_WriteInt(File,"Banned",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_Close(File);
                new sex[] = " Male \n Female ";
                ShowPlayerDialog(playerid, DIALOG_SEX, DIALOG_STYLE_LIST, "Please selecet your Gender", sex, "Select","Quit Game");
            }
        }
case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                    ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
                }
                return 1;
            }
        }
case DIALOG_SEX:
        {
            if(!response) return Kick(playerid);
            if(response)
            {
                if (listitem == 0)
                {
                    PlayerInfo[playerid][pSex] = 1;
                    SendClientMessage(playerid, COLOR_YELLOW2,"So you are Male");
                    ShowPlayerDialog(playerid,6,DIALOG_STYLE_INPUT,"Social Security Office:Age","Hi, Welcome to Los Santos. I just need to you fill out a few forms for me to Process your Citizenship. How old are you?","Submit","Cancel");
                }
                else if (listitem == 1)
                {
                    PlayerInfo[playerid][pSex] = 2;
                    PlayerInfo[playerid][pSkin] = 12;
                    SetPlayerSkin(playerid, 12);
                    SendClientMessage(playerid, COLOR_YELLOW2,"So you are Female");
                    ShowPlayerDialog(playerid,6,DIALOG_STYLE_INPUT,"Social Security Office:Age","Hi, Welcome to Los Santos. I just need to you fill out a few forms for me to Process your Citizenship. How old are you?","Submit","Cancel");
                }
                else
                {
                    Kick(playerid);
                }
            }
        }
case DIALOG_AGE:
    {
        if(response)
        {
            PlayerInfo[playerid][pAge] = strval(inputtext);
            new string[64];
            format(string, sizeof(string),"So you are %s years old", inputtext);
            SendClientMessage(playerid, COLOR_YELLOW2, string);
            if(strval(inputtext) <= 15)
            {
                    SendClientMessage(playerid, COLOR_WHITE, "SERVER: This is a 16+ Only Server, Grow up and Come Back.");
                    Kick(playerid);
                    return 1;
            }
            if(strval(inputtext) >= 101)
            {
                    SendClientMessage(playerid, COLOR_WHITE, "George: Im sorry our records indicate thats not valid");
                    ShowPlayerDialog(playerid,6,DIALOG_STYLE_INPUT,"Social Security Office:Age","How Old did you say you were again?","Submit","Cancel");
                    return 1;
            }
            SetSpawnInfo(playerid, 0, 0, 1481.0886, -1756.8551, 17.5313, 359.6866, 0, 0, 0, 0, 0, 0);
            SpawnPlayer(playerid);
        }
        else
        {
            Kick(playerid);
        }
    }
case DIALOG_STORE:
    {
        if( !response ) return 0;
        if( response )
        {
            switch( listitem )
            {
                case 0:// The first item listed
                {
                    if(GetPlayerMoney(playerid) < 1) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
                    GivePlayerMoney(playerid, -1);
                    SetPlayerSpecialAction(playerid, SPECIAL_ACTION_DRINK_SPRUNK);
                }
                case 1: // The second item listed
                {
                    if(GetPlayerMoney(playerid) < 2) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
                    GivePlayerMoney(playerid, -2);
                    SetPlayerSpecialAction(playerid, SPECIAL_ACTION_DRINK_BEER);
                }
                case 2: // The third item listed
                {
                    if(GetPlayerMoney(playerid) < 3) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
                    GivePlayerMoney(playerid, -3);
                    SetPlayerSpecialAction(playerid, SPECIAL_ACTION_DRINK_WINE);
                }
            }
        }
    }
    // Next dialogs
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)