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

unsupported feature set; code is too new


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CoolJosh3k
AlliedModders Donor
Join Date: Mar 2010
Old 07-12-2022 , 00:25   unsupported feature set; code is too new
Reply With Quote #1

Hi there,

I am looking at making use of a plugin I wrote back in 2017 when I was very new to programming.

It has been a long time and I am no longer familiar with writing SourceMod plugins and so am lost when it comes to the error message of:

(unsupported feature set; code is too new)

I would love if someone could at least point me in the right direction for finding the cause, or even so much as directly helping fix it for me.

Full source here:

Code:
#include <sourcemod>

new Handle:hEnable;
new Handle:hUpTime_Min, Handle:hUpTime_Max;
new Handle:hMaxPlayers;
new Handle:hWarn_ShowChat;
new bool:InRestartCountdown;
new iIdleTime;

public const Plugin:myinfo = {
	name = "Server UpTime Restarter",
	author = "CoolJosh3k",
	description = "Restarts a server after a specified uptime. Respects player counts.",
	version = "1.0.1",
}

public OnPluginStart()
{
	AutoExecConfig();
	hEnable = CreateConVar("SUR_Enable", "1", "Use this if you wish to stop plugin functions temporarily.", FCVAR_NOTIFY, true, 0.0, true, 1.0);
	hUpTime_Min = CreateConVar("SUR_UpTime_Min", "3600", "Minimum time in seconds before restart attempt. Default is 1 day.", FCVAR_NONE, true, 60.0);
	hUpTime_Max = CreateConVar("SUR_UpTime_Min_Max", "259200", "Maximum time in seconds before server restart is forced, regardless of player count. Default is 3 days.", FCVAR_NONE, true, 60.0);
	hMaxPlayers = CreateConVar("SUR_MaxPlayers", "4", "Atleast this many players will cause the restart to be delayed. Spectators are not counted.", FCVAR_NONE, true, 1.0);
	hWarn_ShowChat = CreateConVar("SUR_Warn_ShowChat", "1", "Display restart warning message as a chat message.", FCVAR_NONE, true, 0.0, true, 1.0);
	CreateTimer(1.0, CheckTime, _, TIMER_REPEAT);
}

stock bool:IsValidPlayer(client)
{
	if ((client < 1) || (client > MaxClients))
	{
		return false;
	}
	if (IsClientInGame(client))
	{
		if (IsFakeClient(client))
		{
			return false;
		}
		if (IsClientSourceTV(client) || IsClientReplay(client))
		{
			return false;
		}
		if (GetClientTeam(client) < 2)	//No team or spectator
		{
			return false;
		}
	}
	else	//Client is not in the game
	{
		return false;
	}
	return true;
}

public Action:CheckTime(Handle:timer)
{
	if (GetConVarBool(hEnable) == false)
	{
		return;
	}
	if (InRestartCountdown)	//We are already going to be restarting, but we are busy still letting players know before we actually do.
	{
		return;
	}
	if (GetEngineTime() >= GetConVarInt(hUpTime_Max))	//It has been far too long. A server restart must happen.
	{
		BeginServerRestart();
		return;
	}
	if (GetEngineTime() >= GetConVarInt(hUpTime_Min))
	{
		if (GetGameTime() < 60.0)	//Give time for server to fill. It only just started a new map and might have had enough players.
		{
			iIdleTime++;	//GameTime will not start incrementing without at least 1 player, so we must account for that scenario.
			if (iIdleTime < 60)	//We have been not been idle for long enough. Someone might be coming.
			{
				return;
			}
		}
		else
		{
			iIdleTime = 0;
		}
		new TotalActivePlayers;
		for (new client = 1; client <= MaxClients; client++)
		{
			if (IsValidPlayer(client))
			{
				TotalActivePlayers++;
			}
		}
		if (TotalActivePlayers >= GetConVarInt(hMaxPlayers))
		{
			return;
		}
		else
		{
			BeginServerRestart();
			return;
		}
	}
	return;
}

public OnMapEnd()
{
	if (GetConVarBool(hEnable) == false)
	{
		return;
	}
	if (InRestartCountdown)
	{
		LogMessage("Server restart using \"Server UpTime Restarter\" on map end...");
		ServerCommand("_restart");
	}
}

//=================================//
//- Chain of timers for countdown -//


public BeginServerRestart()
{
	InRestartCountdown = true;
	if (GetConVarBool(hWarn_ShowChat))
	{
		PrintToChatAll("\x03SUR: \x04Server will perform scheduled restart in 60 seconds.");
	}
	CreateTimer(30.0, ServerRestartThirty);
}

public Action:ServerRestartThirty(Handle:timer)
{
	if (GetConVarBool(hEnable))
	{
		if (GetConVarBool(hWarn_ShowChat))
		{
			PrintToChatAll("\x03SUR: \x04Server will perform scheduled restart in 30 seconds.");
		}
		CreateTimer(20.0, ServerRestartTen);
	}
	else
	{
		InRestartCountdown = false;
	}
}

public Action:ServerRestartTen(Handle:timer)
{
	if (GetConVarBool(hEnable))
	{
		if (GetConVarBool(hWarn_ShowChat))
		{
			PrintToChatAll("\x03SUR: \x04Server will perform scheduled restart in TEN seconds.");
		}
		CreateTimer(5.0, ServerRestartFive);
	}
	else
	{
		InRestartCountdown = false;
	}
}

public Action:ServerRestartFive(Handle:timer)
{
	if (GetConVarBool(hEnable))
	{
		if (GetConVarBool(hWarn_ShowChat))
		{
			PrintToChatAll("\x03SUR: \x04Server will perform scheduled restart in FIVE seconds!");
		}
		CreateTimer(4.0, ServerRestartOne);
	}
	else
	{
		InRestartCountdown = false;
	}
}

public Action:ServerRestartOne(Handle:timer)
{
	if (GetConVarBool(hEnable))
	{
		if (GetConVarBool(hWarn_ShowChat))
		{
			PrintToChatAll("\x03SUR: \x04Server will now restart!");
		}
		CreateTimer(1.0, ServerRestartZero);
	}
	else
	{
		InRestartCountdown = false;
	}
}

public Action:ServerRestartZero(Handle:timer)
{
	if (GetConVarBool(hEnable))
	{
		LogMessage("Server restart using \"Server UpTime Restarter\"...");
		ServerCommand("_restart");
	}
	else
	{
		InRestartCountdown = false;
	}
}
I appears I never made this plugin public, but plan to do so. I now have a need for me own solution once again, due to a bug in TF2.

---

I wrote this plugin to address an issue where if a TF2 server is just sitting there on an empty map for long enough, some sort of jitter effect becomes present for players who later join. This worsens over time and is only resolved when the map is changed (or server restarted).

Last edited by CoolJosh3k; 07-12-2022 at 00:29.
CoolJosh3k is offline
nosoop
Veteran Member
Join Date: Aug 2014
Old 07-12-2022 , 00:46   Re: unsupported feature set; code is too new
Reply With Quote #2

You may have used a new spcomp on a server running an older version of SourceMod. SourceMod 1.11 was made the stable branch recently, so if you recently grabbed a copy of the compiler and your server is now on what's considered "old stable" (1.10), that would explain what you're seeing.
__________________
I do TF2, TF2 servers, and TF2 plugins.
I don't do DMs over Discord -- PM me on the forums regarding inquiries.
AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)

Last edited by nosoop; 07-12-2022 at 00:47.
nosoop is offline
CoolJosh3k
AlliedModders Donor
Join Date: Mar 2010
Old 07-12-2022 , 03:43   Re: unsupported feature set; code is too new
Reply With Quote #3

Quote:
Originally Posted by nosoop View Post
You may have used a new spcomp on a server running an older version of SourceMod. SourceMod 1.11 was made the stable branch recently, so if you recently grabbed a copy of the compiler and your server is now on what's considered "old stable" (1.10), that would explain what you're seeing.
I just used the website compiler, as it is a simple plugin and I don't have a local dedicated server setup (yet).

I'll try updating my server's version of SourceMod.

Thanks
CoolJosh3k is offline
Reply



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 19:34.


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