SA-MP Forums Archive
[HELP] Dialog - 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: [HELP] Dialog (/showthread.php?tid=507352)



[HELP] Dialog - monster010 - 17.04.2014

I have this script:

pawn Код:
if(dialogid == 1)
    {
            if(response)
            {
                        if(listitem == 0)
                        {
                                GivePlayerMoney(playerid, -150);
                                GivePlayerWeapon(playerid, 14, 1);
                                SendClientMessage(playerid, 0xFFFFFFC8, "{FFFFFF}Ai primit o floare pentru {00FF40}150${FFFFFF}.");
                        }
                        if(listitem == 1)
                        {
                                GivePlayerMoney(playerid, -1500);
                                GivePlayerWeapon(playerid, 23, 50);
                                SendClientMessage(playerid, 0xFFFFFFC8, "{FFFFFF}Ai primit un SILENCED 9MM cu 50 gloante pentru {00FF40}1.500${FFFFFF}.");
                        }
                         if(listitem == 2)
                        {
                                GivePlayerMoney(playerid, -2500);
                                GivePlayerWeapon(playerid, 24, 60);//deagle
                                SendClientMessage(playerid, 0xFFFFFFC8, "{FFFFFF}Ai primit un DEAGLE cu 60 gloante pentru {00FF40}2.500${FFFFFF}.");
                        }
                         if(listitem == 3)
                        {
                                GivePlayerMoney(playerid, -3500);
                                GivePlayerWeapon(playerid, 25, 25);
                                SendClientMessage(playerid, 0xFFFFFFC8, "{FFFFFF}Ai primit un Shotgun cu 25 gloante pentru {00FF40}3.500${FFFFFF}.");
                       }
                        if(listitem == 4)
                       {
                                GivePlayerMoney(playerid, -4500);
                                GivePlayerWeapon(playerid, 29, 50);
                                SendClientMessage(playerid, 0xFFFFFFC8, "{FFFFFF}Ai primit un MP5 cu 50 gloante pentru {00FF40}4.500${FFFFFF}.");
                       }
                        if(listitem == 5)
                       {
                                GivePlayerMoney(playerid, -5500);
                                GivePlayerWeapon(playerid, 31, 100);
                                SendClientMessage(playerid, 0xFFFFFFC8, "{FFFFFF}Ai primit un M4 cu 100 gloante pentru {00FF40}5.500${FFFFFF}.");
                       }
                       else // Pressed ESC or clicked cancel
                       {
                            SendClientMessage(playerid, COLOR_GREY, "* Ai decis sa nu cumperi arme *");
                            return 1;
                       }
               }
               return 1;
    }
When I select a option, I appear like I press "EXIT". And When O select "EXIT" Nothing happens.


A PICTURE [click]


Re : [HELP] Dialog - S4t3K - 17.04.2014

What's the difference between the "else" and other "if" ?

Note that your code DOESN'T match a non-response action.
It matches if the listitem isn't 0, 1, 2, 3, 4 or 5.

Do like that :

PHP код:
if(dialogid == 1)
{
    if(
response)
    {
        switch(
listitem)
        {
            case 
0:
            {
                
GivePlayerMoney(playerid, -150);
                
GivePlayerWeapon(playerid141);
                return 
SendClientMessage(playerid0xFFFFFFC8"{FFFFFF}Ai primit o floare pentru {00FF40}150${FFFFFF}.");
            }
            case 
1:
            {
                
GivePlayerMoney(playerid, -1500);
                
GivePlayerWeapon(playerid2350);
                return 
SendClientMessage(playerid0xFFFFFFC8"{FFFFFF}Ai primit un SILENCED 9MM cu 50 gloante pentru {00FF40}1.500${FFFFFF}.");
            }
            case 
2:
            {
                
GivePlayerMoney(playerid, -2500);
                
GivePlayerWeapon(playerid2460);//deagle
                
return SendClientMessage(playerid0xFFFFFFC8"{FFFFFF}Ai primit un DEAGLE cu 60 gloante pentru {00FF40}2.500${FFFFFF}.");
            }
            case 
3:
            {
                
GivePlayerMoney(playerid, -3500);
                
GivePlayerWeapon(playerid2525);
                return 
SendClientMessage(playerid0xFFFFFFC8"{FFFFFF}Ai primit un Shotgun cu 25 gloante pentru {00FF40}3.500${FFFFFF}.");
            }
            case 
4:
            {
                
GivePlayerMoney(playerid, -4500);
                
GivePlayerWeapon(playerid2950);
                return 
SendClientMessage(playerid0xFFFFFFC8"{FFFFFF}Ai primit un MP5 cu 50 gloante pentru {00FF40}4.500${FFFFFF}.");
            }
            case 
5:
            {
                
GivePlayerMoney(playerid, -5500);
                
GivePlayerWeapon(playerid31100);
                return 
SendClientMessage(playerid0xFFFFFFC8"{FFFFFF}Ai primit un M4 cu 100 gloante pentru {00FF40}5.500${FFFFFF}.");
            }
        }
    }
    else return 
SendClientMessage(playeridCOLOR_GREY"* Ai decis sa nu cumperi arme *");

I repaired the error (normally).
Try, tell us, then if it works, ask you what's different between my code and yours.