How to make multiple dialog boxes?
#1

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{










    switch(1)
    {
        case 1:
        {
            if(!response)
            {
                SendClientMessage(playerid, 0xFF0000FF, "Use Again");
                return 1; // We processed it
            }

            switch(listitem) // This is far more efficient than using an if-elseif-else structure
            {
                case 0:
                {
					if (GetPlayerMoney(playerid) >= 50)
					{
					GivePlayerWeapon(playerid,22,50);
					GivePlayerMoney(playerid,-50);
					GameTextForPlayer(playerid,"~r~-$50",3000,1);
					PlayerPlaySound(playerid, 1052, 0.0, 0.0, 10.0);
					}
					else
					{
					SendClientMessage(playerid,red,"You do not have the cash.");
					}
                }
                case 1:
                {
                    if (GetPlayerMoney(playerid) >= 3000)
					{
					GivePlayerWeapon(playerid,24,50);
					GivePlayerMoney(playerid,-3000);
					GameTextForPlayer(playerid,"~r~-$3000",3000,1);
					PlayerPlaySound(playerid, 1052, 0.0, 0.0, 10.0);
					}
					else
					{
					SendClientMessage(playerid,red,"You do not have the cash.");
					}
                }
                case 2:
                {
                    if (GetPlayerMoney(playerid) >= 750)
					{
                  	GivePlayerWeapon(playerid,25,50);
					GivePlayerMoney(playerid,-750);
					GameTextForPlayer(playerid,"~r~-$750",3000,1);
					PlayerPlaySound(playerid, 1052, 0.0, 0.0, 10.0);
					}
					else
					{
					SendClientMessage(playerid,red,"You do not have the cash.");
					}
                }
                case 3:
                {
                    if (GetPlayerMoney(playerid) >= 3500)
					{
                  	GivePlayerWeapon(playerid,26,50);
					GivePlayerMoney(playerid,-3500);
					GameTextForPlayer(playerid,"~r~-$3500",3000,1);
					PlayerPlaySound(playerid, 1052, 0.0, 0.0, 10.0);
					}
					else
					{
					SendClientMessage(playerid,red,"You do not have the cash.");
					}
                }
				case 4:
                {
                    if (GetPlayerMoney(playerid) >= 10000)
					{
                  	GivePlayerWeapon(playerid,27,100);
					GivePlayerMoney(playerid,-10000);
					GameTextForPlayer(playerid,"~r~-$10000",3000,1);
					PlayerPlaySound(playerid, 1052, 0.0, 0.0, 10.0);
					}
					else
					{
					SendClientMessage(playerid,red,"You do not have the cash.");
					}
                }
				case 5:
                {
                    if (GetPlayerMoney(playerid) >= 2000)
					{
                  	GivePlayerWeapon(playerid,29,150);
					GivePlayerMoney(playerid,-2000);
					GameTextForPlayer(playerid,"~r~-$2000",3000,1);
					PlayerPlaySound(playerid, 1052, 0.0, 0.0, 10.0);
					}
					else
					{
					SendClientMessage(playerid,red,"You do not have the cash.");
					}
                }
                case 6:
                {
                    if (GetPlayerMoney(playerid) >= 5000)
					{
                  	GivePlayerWeapon(playerid,16,5);
					GivePlayerMoney(playerid,-5000);
					GameTextForPlayer(playerid,"~r~-$5000",3000,1);
					PlayerPlaySound(playerid, 1052, 0.0, 0.0, 10.0);
					}
					else
					{
					SendClientMessage(playerid,red,"You do not have the cash.");
					}
                }
                case 7:
                {
                    if (GetPlayerMoney(playerid) >= 15000)
					{
                  	GivePlayerWeapon(playerid,30,300);
					GivePlayerMoney(playerid,-15000);
					GameTextForPlayer(playerid,"~r~-$15000",3000,1);
					PlayerPlaySound(playerid, 1052, 0.0, 0.0, 10.0);
					}
					else
					{
					SendClientMessage(playerid,red,"You do not have the cash.");
					}
                }
                case 8:
                {
                    if (GetPlayerMoney(playerid) >= 25000)
					{
                  	GivePlayerWeapon(playerid,31,300);
					GivePlayerMoney(playerid,-25000);
					GameTextForPlayer(playerid,"~r~-$25000",3000,1);
					PlayerPlaySound(playerid, 1052, 0.0, 0.0, 10.0);
					}
					else
					{
					SendClientMessage(playerid,red,"You do not have the cash.");
					}
                }

            switch(listitem) // This is far more efficient than using an if-elseif-else structure
            {
				{
                	case 0:
                	{   //tec 1000 crack 3500 knife 75
					if (GetPlayerMoney(playerid) >= 100)
					{
					GivePlayerWeapon(playerid,23,50);
					GivePlayerMoney(playerid,-100);
					GameTextForPlayer(playerid,"~r~-$100",3000,1);
					PlayerPlaySound(playerid, 1052, 0.0, 0.0, 10.0);
					}
					else
					{
					SendClientMessage(playerid,red,"You do not have the cash.");
					}
				}
                case 1:
                {
                    if (GetPlayerMoney(playerid) >= 300)
					{
					GivePlayerWeapon(playerid,25,50);
					GivePlayerMoney(playerid,-300);
					GameTextForPlayer(playerid,"~r~-$300",3000,1);
					PlayerPlaySound(playerid, 1052, 0.0, 0.0, 10.0);
					}
					else
					{
					SendClientMessage(playerid,red,"You do not have the cash.");
					}
                }
                case 2:
                {
                    if (GetPlayerMoney(playerid) >= 1000)
					{
                  	GivePlayerWeapon(playerid,32,100);
					GivePlayerMoney(playerid,-1000);
					GameTextForPlayer(playerid,"~r~-$1000",3000,1);
					PlayerPlaySound(playerid, 1052, 0.0, 0.0, 10.0);
					}
					else
					{
					SendClientMessage(playerid,red,"You do not have the cash.");
					}
                }
                case 3:
                {
                    if (GetPlayerMoney(playerid) >= 3500)
					{
                  	SetPlayerHealth(playerid,17);
					GivePlayerMoney(playerid,-3500);
					GameTextForPlayer(playerid,"~r~-$3500",3000,1);
					PlayerPlaySound(playerid, 1052, 0.0, 0.0, 10.0);
					}
					else
					{
					SendClientMessage(playerid,red,"You do not have the cash.");
					}
                }
				case 4:
                {
                    if (GetPlayerMoney(playerid) >= 75)
					{
                  	GivePlayerWeapon(playerid,4,1);
					GivePlayerMoney(playerid,-75);
					GameTextForPlayer(playerid,"~r~-$75",3000,1);
					PlayerPlaySound(playerid, 1052, 0.0, 0.0, 10.0);
					}
					else
					{
					SendClientMessage(playerid,red,"You do not have the cash.");
					}
				}


			
    return 0; // If you put return 1 here the callback will not continue to be called in other scripts (filterscripts, etc.).
}
What is the problem?
Reply
#2

For starters, wth is this?

Код:
switch(1)
{
EDIT:

This is how you code list dialogs.

Код:
if(dialogid == YOUR_LIST_DIALOG_ID)
{
    switch(listitem)
    {
        case 0:
        {
            //line/list 1
        }
        case 1:
        {
            //line/list 2
        }
        case 2:
        {
            //line/list 3
        }
        //And so on...
    }
}
Reply
#3

https://sampwiki.blast.hk/wiki/OnDialogResponse

thats what that is
Reply
#4

pawn Код:
switch(dialogid)
you might want to reread that wiki page

EDIT:

you can use the code above to be efficient if you have
only 1 or 2 dialogs.

for more than that they should be in a switch also.
Reply
#5

Quote:
Originally Posted by Sleek
Посмотреть сообщение
You obviously do not know how a switch statement works, so please review my edit in my last post to see how list dialogs are coded.

Hope i have helped you.


EDIT:

You may do it Jonny5's way, but i find that way, less efficient(Although that way will fix your code as is).
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)