AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Help: PrintToConsole() executing out of order (https://forums.alliedmods.net/showthread.php?t=138237)

nomx 09-15-2010 14:58

Help: PrintToConsole() executing out of order
 
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?

DarkEnergy 09-15-2010 15:36

Re: Help: PrintToConsole() executing out of order
 
just do a single loop and check Connected and InGame

pRED* 09-15-2010 17:19

Re: Help: PrintToConsole() executing out of order
 
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..).

nomx 09-15-2010 17:27

Re: Help: PrintToConsole() executing out of order
 
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.

rhelgeby 09-16-2010 08:09

Re: Help: PrintToConsole() executing out of order
 
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.


All times are GMT -4. The time now is 07:09.

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