Players in dialog (format)
#1

Hello, I'd like your help, I need to do to show all players who are online dialogue, but only one ID is displayed in the dialogue, knows someone advice?

Код:
stock ReturnPlayerName(playerid)
{
	new pname[MAX_PLAYER_NAME];
	GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
	return pname;
}

stock GetOnLinePlayers()
{
	new OnLine;
	for(new i, g = GetMaxPlayers(); i < g; i++)
	{
		if(IsPlayerConnected(i))
		OnLine++;
	}
	return OnLine;
}



CMD:checkall(playerid, params[])
{
	new string[200];
	new string1[30];
	new count=1;
	format(string1,sizeof(string1),"Online ( %i )", GetOnLinePlayers());
	
	for(new i=0; i<MAX_PLAYERS; i++)
	{
	    if(IsPlayerConnected(i))
		{
		    new Country1[30], City1[30], IP1[30];
		    GetPlayerCountry(playerid, Country1);
		    GetPlayerCity(playerid, City1);
		    GetPlayerIp(playerid,IP1,sizeof(IP1));
	        format(string,sizeof(string),"* %s ( ID %i ) [ IP: %s | State: %s | City: %s ]\n\n", GetPlayerName(i), i, IP1, Country1, City1);
			count++;
	    }
	}
	ShowPlayerDialog(playerid, DIALOG_LOC, DIALOG_STYLE_MSGBOX , string1, string, "Cancel", "");
	return 1;
}
Reply
#2

Try this:
Код:
CMD:checkall(playerid, params[])
{
	new string[1000];
	new string1[50];
	new string2[100];
	new count=1;
	format(string1,sizeof(string1),"Online ( %i )", GetOnLinePlayers());

	for(new i=0; i<MAX_PLAYERS; i++)
	{
	    if(IsPlayerConnected(i))
		{
		    new Country1[30], City1[30], IP1[30];
		    GetPlayerCountry(playerid, Country1);
		    GetPlayerCity(playerid, City1);
		    GetPlayerIp(playerid,IP1,sizeof(IP1));
	        format(string2,sizeof(string2),"* %s ( ID %i ) [ IP: %s | State: %s | City: %s ]\n", GetPlayerName(i), i, IP1, Country1, City1);
        	format(string, sizeof(string), "%s", string2);
			count++;
	    }
	}
	ShowPlayerDialog(playerid, DIALOG_LOC, DIALOG_STYLE_MSGBOX , string1, string, "Cancel", "");
	return 1;
}
Reply
#3

Still problem :/
Reply
#4

I recommend you to remake your Functions.. Your `GetOnLinePlayers` isn't good.

PlayerName function:

Код:
ReturnPlayerName(playerid)
{
	new name[24]; GetPlayerName(playerid, name, 24); return name;
}
And for GetOnLinePlayers:

Код:
ConnectedPlayers()
{
	new Connected;
	for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i)) Connected++;
	return Connected;
}
And try remake your command too using the functions made by me..
If you have any question you can simply PM me.
Reply
#5

Well, I understand, I'll try and write here
Reply
#6

This should work:
Код:
stock GetPlayers()
{
	new Players;
    for(new i, i = MAX_PLAYERS; i++)
    {
		if(IsPlayerConnected(i)) Players++;
    }
	return Players;
}

CMD:checkall(playerid, params[]0
{
	new str[1000], str2[50], str3[100];
	format(str2, sizeof(str2), "Online [%d]", GetPlayers());
	for(new i=0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{
			new pCountry[50], pCity[50], pIp[50];
			GetPlayerCountry(playerid, pCountry);
			GetPlayerCity(playerid, pCity);
			GetPlayerIp(playerid, pIp, sizeof(pIp);
			format(str3, sizeof(str3), "* %s ( ID %i ) [ IP: %s | State: %s | City: %s ]", GetPlayerName(i), i, pIp, pCountry, pCity);
			format(str, sizeof(str), "%s\n", str3);
		}
	}
	ShowPlayerDialog(playerid, DIALOG_LOC, DIALOG_STYLE_MSGBOX, str2, str, "OK", "");
	return 1;
}
Reply
#7

Just move
ShowPlayerDialog(playerid, DIALOG_LOC, DIALOG_STYLE_MSGBOX , string1, string, "Cancel", "");

inside the loop
Reply
#8

@K0P doesn't work.

@iIkey what do you mean?

Код:
CMD:checkall(playerid, params[])
{
	new string[1000];
	new string1[50];
	new string2[100];
	new count=1;
	format(string1,sizeof(string1),"Online ( %i )", ConnectedPlayers());

	for(new i=0; i<MAX_PLAYERS; i++)
	{
	    if(IsPlayerConnected(i))
		{
		    new Country1[30], City1[30], IP1[30];
		    GetPlayerCountry(playerid, Country1);
		    GetPlayerCity(playerid, City1);
		    GetPlayerIp(playerid,IP1,sizeof(IP1));
	        format(string2,sizeof(string2),"* %s ( ID %i ) [ IP: %s | State: %s | City: %s ]\n", GetPlayerName(i), i, IP1, Country1, City1);
        	format(string, sizeof(string), "%s", string2);
        	ShowPlayerDialog(playerid, DIALOG_LOKACE, DIALOG_STYLE_MSGBOX , string1, string, "Cancel", "");
			count++;
	    }
	}
	return 1;
}
Reply
#9

Quote:
Originally Posted by ikey07
Посмотреть сообщение
Just move
ShowPlayerDialog(playerid, DIALOG_LOC, DIALOG_STYLE_MSGBOX , string1, string, "Cancel", "");

inside the loop
Lol no,it will cause lag + we need to show it only 1 time.
Reply
#10

Make more functions witch can be used in formats. Example?

format(string, sizeof(string), Text[], "%s %d %x", ReturnCity(playerid), ReturnPlayerName(playerid) etc....
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)