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_RoundTest, ADMFLAG_SLAY, "Testing PrintToServer bug");
}
public Action Command_RoundTest(int client, int 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 = 1; i<= MaxClients; i++)
{
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;
}