SA-MP Forums Archive
Little Dialogproblem! - 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: Little Dialogproblem! (/showthread.php?tid=324943)



Little Dialogproblem! - Twisted_Insane - 11.03.2012

Hey! I get this 4 errors, and I think, that I've put it on the wrong place! It's the dialog "case:fastshopdialog"...

Код:
D:\Program Files\GTA San Andreas\SAMP_Server\gamemodes\deathmatch.pwn(2165) : error 014: invalid statement; not in switch
D:\Program Files\GTA San Andreas\SAMP_Server\gamemodes\deathmatch.pwn(2165) : warning 215: expression has no effect
D:\Program Files\GTA San Andreas\SAMP_Server\gamemodes\deathmatch.pwn(2165) : error 001: expected token: ";", but found ":"
D:\Program Files\GTA San Andreas\SAMP_Server\gamemodes\deathmatch.pwn(2165) : error 029: invalid expression, assumed zero
D:\Program Files\GTA San Andreas\SAMP_Server\gamemodes\deathmatch.pwn(2165) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
I marked the dialog which is causing the issues:

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, ""WHITE"Registering...",""RED"You have entered an invalid password.\n"WHITE"Type your password below to register a new account.","Register","Quit");
                    if(INI_Open(getINI(playerid)))
                    {
                        INI_WriteString("Password",inputtext);
                        INI_WriteInt("Cash", 0);
                        INI_WriteInt("Admin", 0);
                        INI_WriteInt("FirstTime", 0);
                        INI_WriteInt("Skin", 0);
                        INI_WriteInt("Score", 0);
                        INI_WriteInt("Kills", 0);
                        INI_WriteInt("Deaths", 0);
                        INI_WriteInt("VIPlevel", 0);
                        INI_Save();
                        INI_Close();
                        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""WHITE"Login",""WHITE"Type your password below to login.","Login","Quit");
                    }
                }
            } case DIALOG_LOGIN:
              {
                if(!response)
                    return Kick ( playerid );
                if(response)
                {
                    if(!strlen(inputtext))
                        return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""WHITE"Login",""RED"You have entered an invalid password.\n"WHITE"Type your password below to login.","Login","Quit");
                    if(INI_Open(getINI(playerid)))
                    {
                        INI_ReadString(PlayerInfo[playerid][pPass],"Password",20);
                        if(strcmp(inputtext,PlayerInfo[playerid][pPass],false)) {
               
                            ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""WHITE"Login",""RED"You have entered an incorrect password.\n"WHITE"Type your password below to login.","Login","Quit");
                            TimesAttempted[playerid] += 1;
                            if(TimesAttempted[playerid] == 1) SendClientMessage(playerid,COLOR_RED,"Wrong password, 2 login-attempts left!");
                            else if(TimesAttempted[playerid] == 2) SendClientMessage(playerid,COLOR_RED,"Wrong password, 1 login-attempt left!");
                            else if(TimesAttempted[playerid] == 3){
                            new tname[MAX_PLAYER_NAME], rstring[128];
                            GetPlayerName(playerid, tname, sizeof(tname));
                            format(rstring,sizeof(rstring),"SYSTEM: Player %s has been automatically kicked by the server (Exceeding login-attempts)!",tname);
                            SendClientMessageToAll(COLOR_RED,rstring);
                            Kick(playerid);
                            }
                        }
                        else  {
                        SendClientMessage(playerid,BRIGHT_GREEN,"You have successfully logged in! Welcome back, homie!");
                        PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
                        }
                       
                        GivePlayerMoney( playerid, INI_ReadInt( "Cash" ) );
                        PlayerInfo[playerid][pAdmin] = INI_ReadInt("Admin");
                        PlayerInfo[playerid][pKills] = INI_ReadInt("Kills");
                        PlayerInfo[playerid][pDeaths] = INI_ReadInt("Deaths");
                        gFirstTimeHasJoined[playerid] = INI_ReadInt("FirstTime");
                        gPlayerSkinForEver[playerid] = INI_ReadInt("Skin");
                        SetPlayerScore( playerid, INI_ReadInt( "Score" ) );
                        PlayerInfo[playerid][VIPlevel] = INI_ReadInt("VIP-Level");
                        INI_Close();
                    }
                }

        case fastshopdialog: //STARTS HERE
        {
            switch(listitem)
            {
                case 0: // The first listitem
                {
                    if(GetPlayerMoney(playerid) < 2500) return SendClientMessage(playerid, COLOR_RED,"You need at least $2500 to buy a Desert Eagle!");
                    GivePlayerMoney(playerid, -2500);
                    GivePlayerWeapon(playerid, 24, 100);
                    SendClientMessage(playerid, COLOR_GREEN, "You have successfully bought a Desert Eagle with 100 ammo for $2500!");
                }
                case 1:
                {
                    if(GetPlayerMoney(playerid) < 3000) return SendClientMessage(playerid, COLOR_RED,"You need at least $3000 to buy a Sniper Rifle!");
                    GivePlayerMoney(playerid, -3000);
                    GivePlayerWeapon(playerid, 34, 75);
                    SendClientMessage(playerid, COLOR_GREEN, "You have successfully bought a Sniper Rifle with 75 ammo for $3000!");
                }
                case 2:
                {
                    if(GetPlayerMoney(playerid) < 4000) return SendClientMessage(playerid, COLOR_RED,"You need at least $4000 to buy a Shotgun!");
                    GivePlayerMoney(playerid, -4000);
                    GivePlayerWeapon(playerid, 25, 175);
                    SendClientMessage(playerid, COLOR_GREEN, "You have successfully bought a Shotgun with 1175 ammo for $4000!");
                }
                case 3:
                {
                    if(GetPlayerMoney(playerid) < 6000) return SendClientMessage(playerid, COLOR_RED,"You need at least $6000 to buy a Spas!");
                    GivePlayerMoney(playerid, -6000);
                    GivePlayerWeapon(playerid, 27, 200);
                    SendClientMessage(playerid, COLOR_GREEN, "You have successfully bought a Spas 12 with 200 ammo for $6000!");
                }
                case 4:
                {
                    if(GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid, COLOR_RED,"You need at least $1000 to buy a MP5!");
                    GivePlayerMoney(playerid, -1000);
                    GivePlayerWeapon(playerid, 29, 300);
                    SendClientMessage(playerid, COLOR_GREEN, "You have successfully bought a MP5 with 300 ammo for $1000!");
                }
                case 5:
                {
                    if(GetPlayerMoney(playerid) < 1500) return SendClientMessage(playerid, COLOR_RED,"You need at least $1500 to buy a M4!");
                    GivePlayerMoney(playerid, -1500);
                    GivePlayerWeapon(playerid, 31, 250);
                    SendClientMessage(playerid, COLOR_GREEN, "You have successfully bought a M4 with 250 ammo for $1500!");
                }
                case 6:
                {
                    if(GetPlayerMoney(playerid) < 25000) return SendClientMessage(playerid, COLOR_RED,"You need at least $25000 to buy Sawn-off Shotguns!");
                    GivePlayerMoney(playerid, -25000);
                    GivePlayerWeapon(playerid, 26, 150);
                    SendClientMessage(playerid, COLOR_GREEN, "You have successfully bought a Sawn-off Shotgun with 150 ammo for $25000!");
                }
            }
        }

    }
}
       
return 1;
}



Re: Little Dialogproblem! - MP2 - 11.03.2012

If you indent properly, you will be able to see what the problem is.


Re: Little Dialogproblem! - Twisted_Insane - 11.03.2012

EDIT: Fixed by myself, thanks anyways!^^


Re: Little Dialogproblem! - Twisted_Insane - 11.03.2012

SORRY for doubleposting around, but I got a problem! When I select a listitem, it does what it is supposed to do! BUT, even when I press "Cancel", it will buy me a gun! Lol, I want the dialog to disappear when a player pressed cancel:

pawn Код:
case fastshopdialog:
        {
            switch(listitem)
            {
                case 0: // The first listitem
                {
                    if(GetPlayerMoney(playerid) < 2500) return SendClientMessage(playerid, COLOR_RED,"You need at least $2500 to buy a Desert Eagle!");
                    GivePlayerMoney(playerid, -2500);
                    GivePlayerWeapon(playerid, 24, 100);
                    SendClientMessage(playerid, COLOR_GREEN, "You have successfully bought a Desert Eagle with 100 ammo for $2500!");
                }
                case 1:
                {
                    if(GetPlayerMoney(playerid) < 3000) return SendClientMessage(playerid, COLOR_RED,"You need at least $3000 to buy a Sniper Rifle!");
                    GivePlayerMoney(playerid, -3000);
                    GivePlayerWeapon(playerid, 34, 75);
                    SendClientMessage(playerid, COLOR_GREEN, "You have successfully bought a Sniper Rifle with 75 ammo for $3000!");
                }
                case 2:
                {
                    if(GetPlayerMoney(playerid) < 4000) return SendClientMessage(playerid, COLOR_RED,"You need at least $4000 to buy a Shotgun!");
                    GivePlayerMoney(playerid, -4000);
                    GivePlayerWeapon(playerid, 25, 175);
                    SendClientMessage(playerid, COLOR_GREEN, "You have successfully bought a Shotgun with 1175 ammo for $4000!");
                }
                case 3:
                {
                    if(GetPlayerMoney(playerid) < 6000) return SendClientMessage(playerid, COLOR_RED,"You need at least $6000 to buy a Spas!");
                    GivePlayerMoney(playerid, -6000);
                    GivePlayerWeapon(playerid, 27, 200);
                    SendClientMessage(playerid, COLOR_GREEN, "You have successfully bought a Spas 12 with 200 ammo for $6000!");
                }
                case 4:
                {
                    if(GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid, COLOR_RED,"You need at least $1000 to buy a MP5!");
                    GivePlayerMoney(playerid, -1000);
                    GivePlayerWeapon(playerid, 29, 300);
                    SendClientMessage(playerid, COLOR_GREEN, "You have successfully bought a MP5 with 300 ammo for $1000!");
                }
                case 5:
                {
                    if(GetPlayerMoney(playerid) < 1500) return SendClientMessage(playerid, COLOR_RED,"You need at least $1500 to buy a M4!");
                    GivePlayerMoney(playerid, -1500);
                    GivePlayerWeapon(playerid, 31, 250);
                    SendClientMessage(playerid, COLOR_GREEN, "You have successfully bought a M4 with 250 ammo for $1500!");
                }
                case 6:
                {
                    if(GetPlayerMoney(playerid) < 25000) return SendClientMessage(playerid, COLOR_RED,"You need at least $25000 to buy Sawn-off Shotguns!");
                    GivePlayerMoney(playerid, -25000);
                    GivePlayerWeapon(playerid, 26, 150);
                    SendClientMessage(playerid, COLOR_GREEN, "You have successfully bought a Sawn-off Shotgun with 150 ammo for $25000!");
                }
            }
        }
AND the CMD of course:

pawn Код:
CMD:fastshop(playerid, params[])
{
    ShowPlayerDialog(playerid, fastshopdialog, DIALOG_STYLE_LIST, "{00FFFF}Ammunation Fastshop - {FF0000} Choose your gun!", "Desert Eagle ($2500)\nSniper Rifle ($3000)\nShotgun ($4000)\nSpas ($6000)\nMP5 ($1000)\nM4 ($1500)\nSawn-off Shotgun ($25000)", "Select", "Cancel");
    SendClientMessage(playerid, COLOR_GREEN, "Remember, the fastshop will deliver your guns earlier, but it will cost you more money than the normal shop ( /shop ) !");
    return 1;
}



Respuesta: Little Dialogproblem! - OPremium - 11.03.2012

pawn Код:
case fastshopdialog:
        {
            if(!response) return 1; //Player clicked cancel
            switch(listitem)
            {
                case 0: // The first listitem
                {
                        //Rest of the code :P



Re: Little Dialogproblem! - eesh - 11.03.2012

pawn Код:
case fastshopdialog:
        {
        if(reponse)
        {
            switch(listitem)
            {
                case 0: // The first listitem
                {
                    if(GetPlayerMoney(playerid) < 2500) return SendClientMessage(playerid, COLOR_RED,"You need at least $2500 to buy a Desert Eagle!");
                    GivePlayerMoney(playerid, -2500);
                    GivePlayerWeapon(playerid, 24, 100);
                    SendClientMessage(playerid, COLOR_GREEN, "You have successfully bought a Desert Eagle with 100 ammo for $2500!");
                }
                case 1:
                {
                    if(GetPlayerMoney(playerid) < 3000) return SendClientMessage(playerid, COLOR_RED,"You need at least $3000 to buy a Sniper Rifle!");
                    GivePlayerMoney(playerid, -3000);
                    GivePlayerWeapon(playerid, 34, 75);
                    SendClientMessage(playerid, COLOR_GREEN, "You have successfully bought a Sniper Rifle with 75 ammo for $3000!");
                }
                case 2:
                {
                    if(GetPlayerMoney(playerid) < 4000) return SendClientMessage(playerid, COLOR_RED,"You need at least $4000 to buy a Shotgun!");
                    GivePlayerMoney(playerid, -4000);
                    GivePlayerWeapon(playerid, 25, 175);
                    SendClientMessage(playerid, COLOR_GREEN, "You have successfully bought a Shotgun with 1175 ammo for $4000!");
                }
                case 3:
                {
                    if(GetPlayerMoney(playerid) < 6000) return SendClientMessage(playerid, COLOR_RED,"You need at least $6000 to buy a Spas!");
                    GivePlayerMoney(playerid, -6000);
                    GivePlayerWeapon(playerid, 27, 200);
                    SendClientMessage(playerid, COLOR_GREEN, "You have successfully bought a Spas 12 with 200 ammo for $6000!");
                }
                case 4:
                {
                    if(GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid, COLOR_RED,"You need at least $1000 to buy a MP5!");
                    GivePlayerMoney(playerid, -1000);
                    GivePlayerWeapon(playerid, 29, 300);
                    SendClientMessage(playerid, COLOR_GREEN, "You have successfully bought a MP5 with 300 ammo for $1000!");
                }
                case 5:
                {
                    if(GetPlayerMoney(playerid) < 1500) return SendClientMessage(playerid, COLOR_RED,"You need at least $1500 to buy a M4!");
                    GivePlayerMoney(playerid, -1500);
                    GivePlayerWeapon(playerid, 31, 250);
                    SendClientMessage(playerid, COLOR_GREEN, "You have successfully bought a M4 with 250 ammo for $1500!");
                }
                case 6:
                {
                    if(GetPlayerMoney(playerid) < 25000) return SendClientMessage(playerid, COLOR_RED,"You need at least $25000 to buy Sawn-off Shotguns!");
                    GivePlayerMoney(playerid, -25000);
                    GivePlayerWeapon(playerid, 26, 150);
                    SendClientMessage(playerid, COLOR_GREEN, "You have successfully bought a Sawn-off Shotgun with 150 ammo for $25000!");
                }
            }
        }
    }



Re: Little Dialogproblem! - Twisted_Insane - 11.03.2012

Ah, thank you, I've already forgot this!^^

Now I've got one more question:

I'm making a similar dialog to this, but, whenever a player has purchased ANY kind of the guns listed, I want to set a special timer which gives the player the gun after a time! Of course I know how to set a timer, but I wanted to ask, if I have to set for any gun listed above a timer? Or could I just use in any case one timer? If yes, how would I be able to use the same timer?

@eesh

Your's is completely wrong!


Re: Little Dialogproblem! - eesh - 11.03.2012

pawn Код:
SetTimerEx("giveweapon",yourtimehere,false,"dd",playerid,weaponchosen);//change the weaponid here.

stock giveweapon(playerid,weaponid)
{
    GivePlayerWeapon(playerid,weaponid,ammo);
    return 1;
}
and no mine isn't wrong. Notice the
pawn Код:
if(response)
on the 3rd line which means the code under it ONLY runs when the user clicks yes.


Re: Little Dialogproblem! - Twisted_Insane - 11.03.2012

I didn't really get it now:

I don't want to give the player a weapon with a stock, I wanna kill the timer and then give him weapons! My question: Would it look likt this?

pawn Код:
case 0: // The first listitem
                {
                    if(GetPlayerMoney(playerid) < 2500) return SendClientMessage(playerid, COLOR_RED,"You need at least $2500 to buy a Desert Eagle!");
                    GivePlayerMoney(playerid, -2500);
                    GivePlayerWeapon(playerid, 24, 100);
                    SendClientMessage(playerid, COLOR_GREEN, "You have successfully bought a Desert Eagle with 100 ammo for $2500!");
                    SetTimer("gun1", 60000, false);
                }
                case 1:
                {
                    if(GetPlayerMoney(playerid) < 3000) return SendClientMessage(playerid, COLOR_RED,"You need at least $3000 to buy a Sniper Rifle!");
                    GivePlayerMoney(playerid, -3000);
                    GivePlayerWeapon(playerid, 34, 75);
                    SendClientMessage(playerid, COLOR_GREEN, "You have successfully bought a Sniper Rifle with 75 ammo for $3000!");
                    SetTimer("gun2", 60000, false);
                }
                case 2:
                {
                    if(GetPlayerMoney(playerid) < 4000) return SendClientMessage(playerid, COLOR_RED,"You need at least $4000 to buy a Shotgun!");
                    GivePlayerMoney(playerid, -4000);
                    GivePlayerWeapon(playerid, 25, 175);
                    SendClientMessage(playerid, COLOR_GREEN, "You have successfully bought a Shotgun with 1175 ammo for $4000!");
                    SetTimer("gun3", 60000, false);
                }
I have to create for any case a timer? Or is it somehow possible to use the same timer?


Re: Little Dialogproblem! - Twisted_Insane - 13.03.2012

Anyone knows how to use the same timer several times?