Detect House ID from Dialog[How to improve code optimization]
#3

Quote:
Originally Posted by GospodinX
Посмотреть сообщение
Hi guys

I add house keys for player on an iterator.
new Iterator: HouseKey[MAX_PLAYERRS]<MAX_HOUSES>;

When player type /house he can see list of his house and manage them.

Код:
 	new str[256],id = 1;
	foreach(new i: HouseKey[playerid])
	{
	    format(str,sizeof(str),"%s[%d]\n",str,id);
		id++;
	}
	ShowPlayerDialog(playerid,DIALOG_HOUSE_LIST,DIALOG_STYLE_LIST,"Select House",str,"OK","");
Now I need to detect which house id is he click.But I don't know how to do it.I'm do it on this way but i'm sure that it's wrong.(Yes it work,but it's bad code,i guess)

Код:
		case DIALOG_HOUSE_LIST:
		{
		    if(response == 1)
		    {
		        new skip=0;
		        foreach(new i: HouseKey[playerid])
		        {
		            if(skip == listitem)
		            {
						printf("Player is click on ID : %i",i);
        				break;
					}
					else
					{
					    skip++;
					}
				}
			}
		}
So I need advice how to improve my code optimization.
Do you want to detect which menu option selects the player or which house (houseid) is it in?
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)