Raised This Month: $12 Target: $400
 3% 

Solved PrintToServer bug?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 02-02-2023 , 16:55   PrintToServer bug?
Reply With Quote #1

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


Last edited by PC Gamer; 02-03-2023 at 15:51.
PC Gamer is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 02-03-2023 , 02:35   Re: PrintToServer bug?
Reply With Quote #2

...

sm plugins list
__________________
Do not Private Message @me
Bacardi is offline
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 02-03-2023 , 02:42   Re: PrintToServer bug?
Reply With Quote #3

I'm running 300 plugins. Is there an easy way to output sm plugins list to a text file?
PC Gamer is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 02-03-2023 , 02:54   Re: PrintToServer bug?
Reply With Quote #4

rcon con_logfile myfile.log
rcon sm plugins list
rcon con_logfile ""
__________________
Do not Private Message @me
Bacardi is offline
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 02-03-2023 , 03:34   Re: PrintToServer bug?
Reply With Quote #5

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.

Last edited by PC Gamer; 02-03-2023 at 04:22.
PC Gamer is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 02-03-2023 , 13:41   Re: PrintToServer bug?
Reply With Quote #6

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
__________________
Do not Private Message @me
Bacardi is offline
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 02-03-2023 , 15:24   Re: PrintToServer bug?
Reply With Quote #7

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;        


Last edited by PC Gamer; 02-03-2023 at 15:39.
PC Gamer is offline
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 02-03-2023 , 15:51   Re: PrintToServer bug?
Reply With Quote #8

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.
PC Gamer is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 02-03-2023 , 16:19   Re: PrintToServer bug?
Reply With Quote #9



That was suprice, that extension


Quote:
Originally Posted by PC Gamer View Post
...

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.
__________________
Do not Private Message @me

Last edited by Bacardi; 02-03-2023 at 16:21.
Bacardi is offline
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 21:01.


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