String problem!
#1

Code:
Код:
//format gui
format(str, sizeof(str), "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n", pItem[playerid][0], pItem[playerid][1], pItem[playerid][2], pItem[playerid][3], pItem[playerid][4], pItem[playerid][5], pItem[playerid][6], pItem[playerid][7], pItem[playerid][8], pItem[playerid][9]);

//setting item
format(pItem[playerid][0], 32, "%s", iName[0]);
Then in GUI it looks like:
Item
tem
em
m


Instead:
Item


What is wrong?
Reply
#2

I've got:
Код:
new pItem[MAX_PLAYERS][10];

new iName[][32] =
{
	{"Item"}
};
Код:
        new str[320];
        format(str, sizeof(str), "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n", pItem[playerid][0], pItem[playerid][1], pItem[playerid][2], pItem[playerid][3], pItem[playerid][4], pItem[playerid][5], pItem[playerid][6], pItem[playerid][7], pItem[playerid][8], pItem[playerid][9]);
		ShowPlayerDialog(playerid, DIALOG_ITEMS, DIALOG_STYLE_LIST, "Items", str, "Select", "Exit");
and then i'm trying to give player item
Код:
format(pItem[playerid][0], 32, "%s", iName[0]);
Later in OnDialogResponse i'm going to check selected name of item and do specific action.
is it good way to do it?
Reply
#3

Try this:

Код:
enum InfoItem{It0[32],It1[32],It2[32],It3[32],It4[32],It5[32],It6[32],It7[32],It8[32],It9[32]}

new pItem[MAX_PLAYERS][InfoItem];

new iName[][32] =
{
	{"Item"}
};


pItem[playerid][It0] = iName[0]; // same lenght dont need to format

new str[320];
format(str, sizeof(str), "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n", pItem[playerid][It0], pItem[playerid][It1], pItem[playerid][It2], pItem[playerid][It3], pItem[playerid][It4], pItem[playerid][It5], pItem[playerid][It6], pItem[playerid][It7], pItem[playerid][It8], pItem[playerid][It9]);
ShowPlayerDialog(playerid, DIALOG_ITEMS, DIALOG_STYLE_LIST, "Items", str, "Select", "Exit");
Reply
#4

Awesome.

Now, anyway to do something by name in OnDialogResopnse?
Reply
#5

Quote:
Originally Posted by cnoopers
Посмотреть сообщение
Awesome.

Now, anyway to do something by name in OnDialogResopnse?
Do you mind explaining it a bit more?
Reply
#6

I want to check in callback OnDialogResponse string of choosed It1, It2 etc.
From:
Код:
new iName[][32] =
{
	{"Item"}
};
Reply
#7

Quote:
Originally Posted by cnoopers
Посмотреть сообщение
I want to check in callback OnDialogResponse string of choosed It1, It2 etc.
From:
Код:
new iName[][32] =
{
	{"Item"}
};
Oh, alright:

Example:
pawn Код:
#define DIALOG_INVENTORY 1

// Show the dialog:
ShowPlayerDialog(playerid, DIALOG_INVENTORY, DIALOG_STYLE_LIST, "Inventory", "TestItem1", "Close", "");

// OnDialogResponse:
if(dialogid == DIALOG_INVENTORY) // DIALOG_INVENTORY = DIALOG_SYLE_LIST.
{
    if(!response) return 1;
    else if(response)
    {
        new string[144];
        format(string, sizeof(string), "%s", iName[listitem]);
        return SendClientMessage(playerid, -1, string);
    }
}
Reply
#8

Well I mean sth like:
Код:
	if(dialogid == DIALOG_ITEMS){
        if(response){
			if(iName[0]){
		    	SendClientMessage(playerid, -1, "first item");
			}
			if(iName[1]){
		    	SendClientMessage(playerid, -1, "second item");
			}
        }
        return 1;
	}
but this code is incorrect.
Reply
#9

Quote:
Originally Posted by cnoopers
Посмотреть сообщение
Well I mean sth like:
Код:
	if(dialogid == DIALOG_ITEMS){
        if(response){
			if(iName[0]){
		    	SendClientMessage(playerid, -1, "first item");
			}
			if(iName[1]){
		    	SendClientMessage(playerid, -1, "second item");
			}
        }
        return 1;
	}
but this code is incorrect.
It's practically the same thing to what I've posted.
Reply
#10

Try this

Код:
if (dialogid == DIALOG_ITEMS && response)
{
	new string[20];
	format(string, sizeof(string),"Item%d selected", listitem);
	SendClientMessage(playerid,0xFFC000FF,string);
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)