Help with dialogs
#1

This is my code
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/usecase", cmdtext, true) == 0)
	{
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Select your item", "", "Select", "Cancel");
        if(gMine[playerid] > 0)
        {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Select your item", "Mine", "Select", "Cancel");
		}
		if(gBomb[playerid] > 0)
        {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Select your item", "\nbomb", "Select", "Cancel");
		}
		return 1;
    }
i want to make an inventory dialog system like: When you have bombs, it add the bombs item, etc, i tried everything but cant make it happen
Reply
#2

You would have to keep formatting a string to put into the dialog, then finally add the dialog with the string. But the problem is the listitems for each would be different.
Reply
#3

i tried
Код:
if (strcmp("/usecase", cmdtext, true) == 0)
	{
        new string[64];
        format(string,sizeof(string),"Mine: x %d",gMine[playerid]);
        new string2[64];
        format(string2,sizeof(string2),"Barrels: x %d",gBomb[playerid]);
        new string3[64];
        format(string3,sizeof(string3),"Nuke: x %d",gNuke[playerid]);
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Select your item", string, "Select", "Cancel");
	}
but cant make it combine
Reply
#4

I think this should work.

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/usecase", cmdtext, true) == 0)
    {
        new dstring[200];
       
        new lstring[32];
        format(lstring, sizeof(lstring), "Mines %i\n", gMine[playerid]);
        strins(dstring, lstring, strlen(dstring));
       
        format(lstring, sizeof(lstring), "Bombs %i\n", gBomb[playerid]);
        strins(dstring, lstring, strlen(dstring));
   
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Select your item", dstring, "Select", "Cancel");
        return 1;
    }
}
Reply
#5

Код:
C:\Users\Mario\Desktop\Downloads\Server\filterscripts\weaponstore.pwn(377) : error 017: undefined symbol "isnull"
it doesnt work
Reply
#6

Check my edit above.

edit: You could just use:

pawn Код:
new lstring[128];
format(lstring, sizeof(lstring), "Mines %i\nBombs %i", gMines[playerid], gBomb[playerid]);
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Select your item", lstring, "Select", "Cancel");
Reply
#7

Thanks!! it works now!!!
Reply
#8

Try this.
Edit the items/selections you want on your one. Good luck.
PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
if(
response)// They pressed the first button. 
    
{
    switch(
dialogid)// If you only have one dialog, then this isn't required, but it's neater for when you implement more dialogs. 
        
{
        case 
1:// Our dialog!
            
{
               switch(
listitem)// Checking which listitem was selected
            
{
                case 
0:// The first item listed
                
{
                    if(
GetPlayerMoney(playerid) < 1) return SendClientMessage(playerid0xFFFFFF"You don't have enough cash.");
                    
GivePlayerMoney(playerid, -1);
                    
SetPlayerSpecialAction(playeridSPECIAL_ACTION_DRINK_SPRUNK);
                }
                case 
1// The second item listed
                
{
                    if(
GetPlayerMoney(playerid) < 2) return SendClientMessage(playerid0xFFFFFF"You don't have enough cash.");
                    
GivePlayerMoney(playerid, -2);
                    
SetPlayerSpecialAction(playeridSPECIAL_ACTION_DRINK_BEER);
                }
                case 
2// The third item listed
                
{
                    if(
GetPlayerMoney(playerid) < 3) return SendClientMessage(playerid0xFFFFFF"You don't have enough cash.");
                    
GivePlayerMoney(playerid, -3);
                    
SetPlayerSpecialAction(playeridSPECIAL_ACTION_DRINK_WINE);
                }
            }
            }
    }
    }
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)