AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved PrintToServer bug? (https://forums.alliedmods.net/showthread.php?t=341613)

PC Gamer 02-02-2023 16:55

PrintToServer bug?
 
Can someone tell me why some of the PrintToServer commands aren't working?

No errors on console, no errors in logs.

Game: TF2
Sourcemod version: 1.11.0.6927

PHP Code:

#pragma semicolon 1
#pragma newdecls required

public Plugin myinfo 
{
    
name "[TF2] Test PrintToServer at Round Start",
    
author "PC Gamer",
    
description "Prints to Server after round start",
    
version "PLUGIN_VERSION 1.0",
}

public 
void OnPluginStart()

    
HookEvent("teamplay_round_start"OnRoundStart);
}

public 
void OnRoundStart(Event hEvent, const char[] strNamebool bDontBroadcast)

    
PrintToServer("Round Test: Starting Round"); //This line prints
    
PrintToChatAll("Round Test: Starting Round"); //This line prints
    
    
int realplayers 6;
    
PrintToServer("Round Test: There are %i Human Players"realplayers); //This line does not print
    
PrintToChatAll("Round Test: There are %i Human Players"realplayers);    //This line prints
    
    
int hcount 0;
    for (
int i 1i<= MaxClientsi++)
    {
        if(
IsClientInGame(i) && !IsFakeClient(i))
        {
            
hcount++;
        }
    }
    
    
PrintToServer("Round Test: Just kidding. There are really only %i Human Players"hcount); //This line does not print
    
PrintToChatAll("Round Test: Just kidding. There are really only %i Human Players"hcount); //This line prints
    
PrintToServer("Round Test: Done testing PrintToServer commands"); //This line prints
    
PrintToChatAll("Round Test: Done testing PrintToServer commands");//This line prints



Bacardi 02-03-2023 02:35

Re: PrintToServer bug?
 
...

sm plugins list

PC Gamer 02-03-2023 02:42

Re: PrintToServer bug?
 
I'm running 300 plugins. Is there an easy way to output sm plugins list to a text file?

Bacardi 02-03-2023 02:54

Re: PrintToServer bug?
 
rcon con_logfile myfile.log
rcon sm plugins list
rcon con_logfile ""

PC Gamer 02-03-2023 03:34

Re: PrintToServer bug?
 
Here's a list of my plugins:
Spoiler


Edit: Tested with only 2 plugins running (forcewin and my roundtest plugin). Bug still happens.

Edit2: Edited plugin code above to add PrintToChatAll commands. All of the PrintToChatAll commands correctly printed to chat. The PrintToServer commands remain buggy. Only some of them print to Server console.

Bacardi 02-03-2023 13:41

Re: PrintToServer bug?
 
Could you try change event "teamplay_round_start" to else ?
I just assume, maybe some kind DEBUG messagin is trying supress console output message just in that time.


maybe

PC Gamer 02-03-2023 15:24

Re: PrintToServer bug?
 
I just tried other events including round win, point captured, flag event, and OnClientPostAdmionCheck. In all scenarios the event fired, all of the PrintToChat commands worked, and only 2 out of 4 PrintToServer commands worked. I even added a timer to delay the print. Bug still happens.

I think this is a bug. The PrintToServer command doesn't always seem to fire when a variable is used with the command. No error is produced in server console. No error is printed in the error log. The command is simply ignored.

Edit: I changed the plugin to fire on command. Bug still exists. In the following code only Test 1 and Test 4 lines print to server console. All of the PrintToChat commands worked.

PHP Code:

#pragma semicolon 1
#pragma newdecls required

public Plugin myinfo 
{
    
name "[TF2] Test PrintToServer on command",
    
author "PC Gamer",
    
description "Prints to Server on command",
    
version "PLUGIN_VERSION 1.0",
}

public 
void OnPluginStart()
{
    
RegAdminCmd("sm_testround"Command_RoundTestADMFLAG_SLAY"Testing PrintToServer bug");
}

public 
Action Command_RoundTest(int clientint args)
{
    
PrintToServer("Test 1"); //This line prints
    
PrintToChatAll("Test 1"); //This line prints
    
    
int realplayers 6;
    
PrintToServer("Test 2: There are %i Human Players"realplayers); //This line does not print
    
PrintToChatAll("Test 2: There are %i Human Players"realplayers);    //This line prints
    
    
int hcount 0;
    for (
int i 1i<= MaxClientsi++)
    {
        if(
IsClientInGame(i) && !IsFakeClient(i))
        {
            
hcount++;
        }
    }
    
    
PrintToServer("Test 3: Just kidding. There are really only %i Human Players"hcount); //This line does not print
    
PrintToChatAll("Test 3: Just kidding. There are really only %i Human Players"hcount); //This line prints
    
PrintToServer("Test 4: Done testing PrintToServer commands"); //This line prints
    
PrintToChatAll("Test 4: Done testing PrintToServer commands");//This line prints

    
return Plugin_Handled;        



PC Gamer 02-03-2023 15:51

Re: PrintToServer bug?
 
Problem solved. My mistake.

I had the word 'Player' in my cleaner.cfg file which is used by the Cleaner Extension to suppress console messages.

Doh!

As always, thanks for your help Bacardi! You are the only person here and on Discord that tried to help.

Bacardi 02-03-2023 16:19

Re: PrintToServer bug?
 
:D

That was suprice, that extension


Quote:

Originally Posted by PC Gamer (Post 2798623)
...

As always, thanks for your help Bacardi! You are the only person here and on Discord that tried to help.

I'm just old spam bot, creating posts in here among other spams.


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

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