Get playerid from listitem.
#4

When you use the dialog tab list like NaS suggested, you only need to convert the inputtext using strval
Code:
if (response) {
	new id = strval(inputtext);
	if (IsPlayerConnected(id)) {
		ShowPlayerStats(id);
		return 1;
	} else {
		// selected player is no longer online
	}
}
And your dialog tab list is formatted like this:
Code:
format(players, sizeof (players), "%i\t%s", i, GetPlayerName(i));
inputtext will only return the first column of the tab list.

But if you wish to stay with your own code (dialog list of player names only), you do this:
Code:
if (response) {
	new id;
	if (!sscanf(inputtext, "u", id)) {
		if (id != INVALID_PLAYER_ID)
		{
			ShowPlayerStats(id);
			return true;
		} else {
			// selected player is no longer online
		}
	}
}
if you only do inputtext[0], it will only take the first digit... so ID "12" will be only "1"

Note it is important to handle if the regarding player is still connected or not, because the players from the list might have been left the server OR changed name before the player response the dialog.
Reply


Messages In This Thread
Get playerid from listitem. - by CherryMond - 02.01.2019, 17:41
Re: Get playerid from listitem. - by NaS - 02.01.2019, 17:50
Re: Get playerid from listitem. - by CherryMond - 02.01.2019, 18:12
Re: Get playerid from listitem. - by RoboN1X - 03.01.2019, 03:34
Re: Get playerid from listitem. - by Kane - 03.01.2019, 08:40
Re: Get playerid from listitem. - by CherryMond - 03.01.2019, 20:27
Re: Get playerid from listitem. - by BlackBank - 03.01.2019, 22:33
Re: Get playerid from listitem. - by cessil - 03.01.2019, 23:04
Re: Get playerid from listitem. - by BlackBank - 03.01.2019, 23:11
Re: Get playerid from listitem. - by Y_Less - 04.01.2019, 00:16
Re: Get playerid from listitem. - by Threshold - 04.01.2019, 05:58
Re: Get playerid from listitem. - by cessil - 04.01.2019, 07:10
Re: Get playerid from listitem. - by Y_Less - 04.01.2019, 11:12
Re: Get playerid from listitem. - by BlackBank - 04.01.2019, 19:50
Re: Get playerid from listitem. - by CherryMond - 04.01.2019, 22:54
Re: Get playerid from listitem. - by Pottus - 05.01.2019, 04:17

Forum Jump:


Users browsing this thread: 1 Guest(s)