Dialog doesnt show full members
#1

hello.
i was trying to convert from message to the dialog now the problem is that the dialog shows only 1 name and no what is meant to show the whole list of members.
it is suppost to show for example
ThatFag - Tier(online) if he is online
ThatFag - tier - if he is not online there will be no online tag

codes.
Код:
function:ShowAllMembers(playerid)
{
	new rows, fields;
	cache_get_data(rows, fields, MySQLPipeline);
	if(rows)
	{
		for(new row = 0; row < rows; row++) //magic is happening!
		{
			new iMessage[MAX_STRING], iFormat[45], iGet[75], pName[MAX_PLAYER_NAME],wazzap[30];
			if(IsPlayerConnected(GetPlayerId(pName)))
			{
			myStrcpy(wazzap,"(Online)");
			}

			cache_get_field_content(row, "PlayerName", pName, MySQLPipeline); // player is connected, skip it!
			format(iFormat, sizeof(iFormat), " - %s", pName); strcat(iMessage, iFormat);
			cache_get_field_content(row, "Tier", iGet, MySQLPipeline);
			format(iFormat, sizeof(iFormat), "{6D81E5}(Tier: %d){17A501}%s\n%s",strval(iGet),wazzap,iFormat); strcat(iMessage, iFormat);
			SendClientMessage(playerid, COLOR_GREY, iMessage);
			ShowPlayerDialog(playerid,800,DIALOG_STYLE_LIST,"Members",iMessage,"Okay","");
		}
	}
	return 1;
}
Reply
#2

Here's some advice:
  • cache_get_data is redundant when you have cache_get_row_count:
    PHP код:
    for(new rowrows cache_get_row_count(); row rowsi++) 
  • Do not declare variables inside a loop.
  • Add all retrieved names to one variable and then use that string in the dialog.
  • The previous tip means that you will have to move ShowPlayerDialog to outside the loop.
  • Put a value in pName first before using it somewhere.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)