Dialog Help
#1

Can someone tell me where I went wrong?
This is OnDialogResponse:
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
	if(response == 12 && Dialogid == 12)
	{
		switch(listitem)
		{
            case 0:
   	        if(GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
   	        GivePlayerMoney(playerid, -1000);
   	        GivePlayerWeapon(playerid, 24, 9999);
   	        SendClientMessage(Playerid, COLOR_YELLOW, "You have just bought a Desert Eagle for $1,000.");
            {
		else
	        case 1:
	        if(GetPlayerMoney(playerid) < 2200) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
			GivePlayerMoney(playerid, -2200);
			GivePlayerWeapon(playerid, 31, 9999);
			SendClientMessage(playerid, COLOR_YELLOW, "You have just bought a M4A1 for $2,200.");
		else
	        case 2:
	        if(GetPlayerMoney(playerid) < 2500) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
			GivePlayerMoney(playerid, -2500);
			GivePlayerWeapon(playerid, 27, 9999);
			SendClientMessage(playerid, COLOR_YELLOW, "You have just bought a Spas-12 for $2,500.");
			}
	return 1;
}
This is the Defines (I find it easier):
Код:
#define DIALOG12_MSG "Desert Eagle\nM4A1\nSpas-12"
The command:
Код:
CMD:buygun(playerid, params[]) {
	    ShowPlayerDialog(playerid, 12, DIALOG_STYLE_LIST, "Select what gun you want", DIALOG12_MSG, "Buy", "Cancel" );
	 	return 1;
}
EDIT: These are the errors now:
Код:
C:\Users\Jordan\Desktop\Windows-Server\gamemodes\vx-rp.pwn(5512) : error 017: undefined symbol "Dialogid"
C:\Users\Jordan\Desktop\Windows-Server\gamemodes\vx-rp.pwn(5518) : error 002: only a single statement (or expression) can follow each "case"
C:\Users\Jordan\Desktop\Windows-Server\gamemodes\vx-rp.pwn(5518) : warning 215: expression has no effect
C:\Users\Jordan\Desktop\Windows-Server\gamemodes\vx-rp.pwn(5520) : error 017: undefined symbol "Playerid"
C:\Users\Jordan\Desktop\Windows-Server\gamemodes\vx-rp.pwn(5522) : error 029: invalid expression, assumed zero
C:\Users\Jordan\Desktop\Windows-Server\gamemodes\vx-rp.pwn(5522 -- 5523) : warning 215: expression has no effect
C:\Users\Jordan\Desktop\Windows-Server\gamemodes\vx-rp.pwn(5523) : error 001: expected token: ";", but found "case"
C:\Users\Jordan\Desktop\Windows-Server\gamemodes\vx-rp.pwn(5523) : warning 217: loose indentation
C:\Users\Jordan\Desktop\Windows-Server\gamemodes\vx-rp.pwn(5523) : error 014: invalid statement; not in switch
C:\Users\Jordan\Desktop\Windows-Server\gamemodes\vx-rp.pwn(5523) : fatal error 107: too many error messages on one line

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


7 Errors.
EDIT 2: updated the OnDialogResponse
Reply
#2

I don't know what you've been doing to create this mess, but it certainly ain't good.
  1. The identation looks like crap
  2. Multiple statements in a switch case must be wrapped in a compound box (i.e. curly braces).
Reply
#3

This is my first time adding a dialog, can you help?
Reply
#4

1. Dialogid "D" should be lower case
2. Playerid "P" should be lower case
3. add "{}" after each case
like
Код:
case:0
   {
    blah blah...
    }
Reply
#5

the a response should only be 1 or 0 .. its not same as dialogid
Reply
#6

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 12 && response)
    {
        switch(listitem)
        {
            case 0:
            {
                if(GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
                GivePlayerMoney(playerid, -1000);
                GivePlayerWeapon(playerid, 24, 9999);
                SendClientMessage(Playerid, COLOR_YELLOW, "You have just bought a Desert Eagle for $1,000.");
            }
            case 1:
            {
                if(GetPlayerMoney(playerid) < 2200) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
                GivePlayerMoney(playerid, -2200);
                GivePlayerWeapon(playerid, 31, 9999);
                SendClientMessage(playerid, COLOR_YELLOW, "You have just bought a M4A1 for $2,200.");
            }
            case 2:
            {
                if(GetPlayerMoney(playerid) < 2500) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
                GivePlayerMoney(playerid, -2500);
                GivePlayerWeapon(playerid, 27, 9999);
                SendClientMessage(playerid, COLOR_YELLOW, "You have just bought a Spas-12 for $2,500.");
            }
        }
    }
    return 1;
}
the correct.
Reply
#7

Quote:
Originally Posted by [O.z]Caroline
Посмотреть сообщение
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 12 && response)
    {
        switch(listitem)
        {
            case 0:
            {
                if(GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
                GivePlayerMoney(playerid, -1000);
                GivePlayerWeapon(playerid, 24, 9999);
                SendClientMessage(Playerid, COLOR_YELLOW, "You have just bought a Desert Eagle for $1,000.");
            }
            case 1:
            {
                if(GetPlayerMoney(playerid) < 2200) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
                GivePlayerMoney(playerid, -2200);
                GivePlayerWeapon(playerid, 31, 9999);
                SendClientMessage(playerid, COLOR_YELLOW, "You have just bought a M4A1 for $2,200.");
            }
            case 2:
            {
                if(GetPlayerMoney(playerid) < 2500) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
                GivePlayerMoney(playerid, -2500);
                GivePlayerWeapon(playerid, 27, 9999);
                SendClientMessage(playerid, COLOR_YELLOW, "You have just bought a Spas-12 for $2,500.");
            }
        }
    }
    return 1;
}
the correct.
lol
Код:
SendClientMessage(Playerid, COLOR_YELLOW, "You have just bought a Desert Eagle for $1,000.");
"P" in this line still needs to be lower case
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)