Dialog doens't work
#1

Hello, I have create a dialog with a few licenses you can get but there is a problem..

The screenshot you see now:


that are the licenses you can get, but if you look inside the chat it says a complete different message.

Here is the dialog:

PHP код:
if(dialogid == DIALOG_LICENSE_BUY && response
    {
        switch (
listitem)
        {
            case 
0:
            {
                if(
PlayerInfo[playerid][pIdCard] == 0)
                {
                    if(
GetPlayerCash(playerid) < 5000)
                    {
                        
SendClientMessageEx(playeridCOLOR_GREY"You can not afford to buy a passport.");
                        return 
1;
                    }
                    
GivePlayerCash(playerid,-5000);
                    
PlayerInfo[playerid][pIdCard] = 1;
                    
SendClientMessageEx(playeridCOLOR_GREY"You have successfully acquired a passport.");
                }
                else 
SendClientMessageEx(playeridCOLOR_GREY"You already have a passport.");
            }
            case 
1:
            {
                if(
PlayerInfo[playerid][pCarLic] == 0)
                {
                    if(
GetPlayerCash(playerid) < 5000)
                    {
                        
SendClientMessageEx(playeridCOLOR_GREY"You can not afford to buy a driving's license.");
                        return 
1;
                    }
                    
GivePlayerCash(playerid,-5000);
                    
PlayerInfo[playerid][pCarLic] = 1;
                    
SendClientMessageEx(playeridCOLOR_GREY"You have successfully acquired a driving's license.");
                }
                else 
SendClientMessageEx(playeridCOLOR_GREY"You already have a driving's license.");
            }
            case 
2:
            {
                if(
PlayerInfo[playerid][pFlyLic] == 0)
                {
                    if(
PlayerInfo[playerid][pLevel] >=2)
                    {
                        if(
GetPlayerCash(playerid) < 25000)
                        {
                            
SendClientMessageEx(playeridCOLOR_GREY"You can not afford to buy a pilot's license.");
                            return 
1;
                        }
                        
GivePlayerCash(playerid,-25000);
                        
PlayerInfo[playerid][pFlyLic] = 1;
                          
SendClientMessageEx(playeridCOLOR_GREY"You have successfully acquired a pilot license; you will now be able to pilot aircraft.");
                    }
                    else 
SendClientMessageEx(playeridCOLOR_GREY"You must be level 2 or above to acquire a pilot license.");
                }
                else 
SendClientMessageEx(playeridCOLOR_GREY"You already have a pilot license.");
            }
            case 
3:
            {
                if(
PlayerInfo[playerid][pTaxiLicense] == 0)
                {
                    if(
GetPlayerCash(playerid) < 35000)
                    {
                        
SendClientMessageEx(playeridCOLOR_GREY"You can not afford to buy a taxi license.");
                        return 
1;
                    }
                    
GivePlayerCash(playerid,-35000);
                    
PlayerInfo[playerid][pTaxiLicense] = 1;
                    
SendClientMessageEx(playeridCOLOR_GREY"You have successfully acquired a taxi license; you will be able to use /fare in any vehicle, and accept calls for taxis.");
                }
                else 
SendClientMessageEx(playeridCOLOR_GREY"You already have a taxi license.");
            }
            case 
4:
            {
                if(
PlayerInfo[playerid][pBoatLic] == 0)
                {
                    if(
GetPlayerCash(playerid) < 15000)
                    {
                        
SendClientMessageEx(playeridCOLOR_GREY"You can not afford to buy a boating.");
                        return 
1;
                    }
                    
GivePlayerCash(playerid,-15000);
                    
PlayerInfo[playerid][pBoatLic] = 1;
                    
SendClientMessageEx(playeridCOLOR_GREY"You have successfully acquired a boating.");
                }
                else 
SendClientMessageEx(playeridCOLOR_GREY"You already have a boating.");
            }
            case 
5:
            {
                if(
PlayerInfo[playerid][pFishLic] == 0)
                {
                    if(
GetPlayerCash(playerid) < 9000)
                    {
                        
SendClientMessageEx(playeridCOLOR_GREY"You can not afford to buy a fishing license.");
                        return 
1;
                    }
                    
GivePlayerCash(playerid,-9000);
                    
PlayerInfo[playerid][pFishLic] = 1;
                    
SendClientMessageEx(playeridCOLOR_GREY"You have successfully acquired a fishing license.");
                }
                else 
SendClientMessageEx(playeridCOLOR_GREY"You already have a fishing license.");
            }
            case 
6:
            {
                if(
PlayerInfo[playerid][pGunLic] == 0)
                {
                    if(
GetPlayerCash(playerid) < 20000)
                    {
                        
SendClientMessageEx(playeridCOLOR_GREY"You can not afford to buy a weapon license.");
                        return 
1;
                    }
                    
GivePlayerCash(playerid,-20000);
                    
PlayerInfo[playerid][pGunLic] = 1;
                    
SendClientMessageEx(playeridCOLOR_GREY"You have successfully acquired a weapon license.");
                }
                else 
SendClientMessageEx(playeridCOLOR_GREY"You already have a weapon license.");
            }
        }
    } 
And here the the command:

PHP код:
CMD:getlic(playeridparams[])
{
    if (!
IsPlayerInRangeOfPoint(playerid,2.0,366.54159.091008.38)) { return 1; }
    if (
PlayerInfo[playerid][pWantedLevel] > 0) return SendClientMessageEx(playeridCOLOR_LIGHTRED"You have an outstanding arrest warrant - acquisition of a license is prohibited.");
    
ShowPlayerDialog(playeridDIALOG_LICENSE_BUYDIALOG_STYLE_LIST"Select the type of license you wish to acquire.""Passport ($5,000)\r\nDriver's License ($5,000)\r\nPilot License ($25,000)\r\nTaxi License ($35,000)\r\nBoating License ($15,000)\r\nFishing License ($9,000)\r\nWeapon License ($20,000)""Purchase""Cancel");
    return 
1;

As you can see in the CMD the names are the same as the cases in the dialog but if I try to buy the weapon license I don't get anything..
Reply
#2

Replace each
PHP код:
if(GetPlayerCash(playerid) < 5000
by
PHP код:
if(GetPlayerCash(playerid) <= 5000
There is no return in each case. Why? Like else return [...] - return 1;
Reply
#3

GetPlayerCash is not problem, it can be used either way as far as i know. but problem is that you dont have return after each case as Dayrion said. use it like:
PHP код:
 else return SendClientMessage(playerid, -1"You already have Passport"); 
Hope it helps.
Reply
#4

Still the same problem if I chose "passport" I get "Driving license"
if I chose "Weapon License" I get Nothing
Reply
#5

Try this

PHP код:
CMD:getlic(playeridparams[])
{
    if (!
IsPlayerInRangeOfPoint(playerid,2.0,366.54159.091008.38)) { return 1; }
    if (
PlayerInfo[playerid][pWantedLevel] > 0) return SendClientMessageEx(playeridCOLOR_LIGHTRED"You have an outstanding arrest warrant - acquisition of a license is prohibited.");
    
ShowPlayerDialog(playeridDIALOG_LICENSE_BUYDIALOG_STYLE_LIST"Select the type of license you wish to acquire.""Passport ($5,000)\nDriver's License ($5,000)\nPilot License ($25,000)\nTaxi License ($35,000)\nBoating License ($15,000)\nFishing License ($9,000)\nWeapon License ($20,000)""Purchase""Cancel");
    return 
1;

Reply
#6

Still the same problem

Still the same problem if I chose "passport" I get "Driving license"
if I chose "Weapon License" I get Nothing
Reply
#7

Did you add return at each case ?
If yes, delete
PHP код:
&& response
Reply
#8

Adding return or removing response has nothing to do with fixing the problem.
If you try his code without his enum and arrays, it would work just fine.

Are you maybe adding 1 to listitem somewhere under OnDialogResponse?
Try doing this:
Код:
listitem--;
switch (listitem)
{
    case 0:
    {
        // ...
    }
    // ...
}
Reply
#9

Still the same problem if I chose passport I get a Driving license...
Reply
#10

It's the first time I see using \r\n in dialogs except files so I tested it and it worked so the problem is not that (not sure if the affects are different to OS other than Windows).

Try debug it (at the top of OnDialogResponse):
pawn Код:
printf("OnDialogResponse(%i, %i, %i, %i, \"%s\"", playerid, dialogid, response, listitem, inputtext);
Go in-game and select the first item. What does it print?
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)