Raised This Month: $32 Target: $400
 8% 

Help: PrintToConsole() executing out of order


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
nomx
Junior Member
Join Date: Sep 2010
Old 09-15-2010 , 14:58   Help: PrintToConsole() executing out of order
Reply With Quote #1

Here's the code (adapted from the sm_admins command):
Code:
public Action:Command_Users(client, args)
{
	new Usrs[64], count = 0;
	for (new i = 1; i <= MaxClients; i++)
	{
		if (IsClientInGame(i)) Usrs[count++] = i;
	}

	if (count)
	{
		PrintToConsole(client, "---------------------------------------------------");
		PrintToConsole(client, "ID\tSteam ID\t \tName");
		PrintToConsole(client, "---------------------------------------------------");

		decl String:name[64], String:steamid[64], userid;

		for (new i = 0; i < count; i++)
		{
			GetClientName(Usrs[i], name, sizeof(name));
			GetClientAuthString(Usrs[i], steamid, sizeof(steamid));
			userid = GetClientUserId(Usrs[i]);
			PrintToConsole(client, "%d\t%s\t%s", userid, steamid, name);
		}

		PrintToConsole(client, "---------------------------------------------------");
	}
	return Plugin_Handled;
}
However, I'm getting output like this:

Code:
] sm_users 
---------------------------------------------------
ID	Steam ID	 	Name
9	STEAM_0:0:5267961	Super Awesome Melons
---------------------------------------------------
23	STEAM_0:0:34443103	{-K-C-} Rene__
2	STEAM_0:0:9398230	Ego
24	STEAM_0:0:29023212	{-K-C-}Winerle
---------------------------------------------------

] sm_users 
---------------------------------------------------
ID	Steam ID	 	Name
---------------------------------------------------
2	STEAM_0:0:9398230	Ego
9	STEAM_0:0:5267961	Super Awesome Melons
23	STEAM_0:0:34443103	{-K-C-} Rene__
24	STEAM_0:0:29023212	{-K-C-}Winerle
---------------------------------------------------

] sm_users 
9	STEAM_0:0:5267961	Super Awesome Melons
---------------------------------------------------
23	STEAM_0:0:34443103	{-K-C-} Rene__
ID	Steam ID	 	Name
24	STEAM_0:0:29023212	{-K-C-}Winerle
---------------------------------------------------
---------------------------------------------------
2	STEAM_0:0:9398230	Ego

] sm_users 
---------------------------------------------------
24	STEAM_0:0:29023212	{-K-C-}Winerle
ID	Steam ID	 	Name
---------------------------------------------------
---------------------------------------------------
2	STEAM_0:0:9398230	Ego
9	STEAM_0:0:5267961	Super Awesome Melons
23	STEAM_0:0:34443103	{-K-C-} Rene__
It doesn't appear to want to output in the correct order. Any way to fix this?
nomx is offline
DarkEnergy
SourceMod Donor
Join Date: Apr 2008
Location: Georgia Tech, MSECE
Old 09-15-2010 , 15:36   Re: Help: PrintToConsole() executing out of order
Reply With Quote #2

just do a single loop and check Connected and InGame
__________________
War3:Source Developer
"Your CPU is just a bunch of Muxes"
DarkEnergy is offline
pRED*
Join Date: Dec 2006
Old 09-15-2010 , 17:19   Re: Help: PrintToConsole() executing out of order
Reply With Quote #3

Welcome to the joys of UDP packets.

If order is important, use a timer to space out each line somewhat, or print all the data as one line (I think \n works..).
pRED* is offline
nomx
Junior Member
Join Date: Sep 2010
Old 09-15-2010 , 17:27   Re: Help: PrintToConsole() executing out of order
Reply With Quote #4

I was testing with a nearly empty server. I guess I could throw the first 3 lines on a single command with the new line string (somehow didn't think of that before). Then put a timer between that and the users, then another timer before the final '-----...' string.

Will try that out.

Edit: Adding the timers seems to work right. I put a 0.05 interval for the middle part, then a 0.10 for the end and it seems to work, except for when someone gets killed (reports to console) within that .1 second.

Last edited by nomx; 09-15-2010 at 17:47.
nomx is offline
rhelgeby
Veteran Member
Join Date: Oct 2008
Location: 0x4E6F72776179
Old 09-16-2010 , 08:09   Re: Help: PrintToConsole() executing out of order
Reply With Quote #5

That's odd. I've done output at the same size (or bigger) with no issues. That was even on a server far away from my location.

You must be on a poor or very busy network.
__________________
Richard Helgeby

Zombie:Reloaded | PawnUnit | Object Library
(Please don't send private messages for support, they will be ignored. Use the forum.)
rhelgeby is offline
Send a message via MSN to rhelgeby
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:24.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode