Add cvars for triggers and physboxes
Also comment out the toggle since it doesn't serve a purpose anymore
This commit is contained in:
parent
c4ecc7f2df
commit
7b60560a7c
@ -155,14 +155,22 @@ int g_aaFilterClientSolidTouch[((MAXPLAYERS + 1) * MAX_EDICTS) / 32];
|
||||
int g_aBlockTriggerMoved[MAX_EDICTS / 32];
|
||||
int g_aBlacklisted[MAX_EDICTS / 32];
|
||||
|
||||
Handle g_hCookie_DisableLagComp;
|
||||
bool g_bDisableLagComp[MAXPLAYERS+1];
|
||||
int g_iDisableLagComp[MAXPLAYERS+1];
|
||||
//Handle g_hCookie_DisableLagComp;
|
||||
//bool g_bDisableLagComp[MAXPLAYERS + 1];
|
||||
//int g_iDisableLagComp[MAXPLAYERS + 1];
|
||||
|
||||
ConVar g_bLagCompTriggers;
|
||||
ConVar g_bLagCompPhysboxes;
|
||||
|
||||
public void OnPluginStart()
|
||||
{
|
||||
CreateConVar("sm_lagcomp_version", PLUGIN_VERSION, "LagCompensation Version", FCVAR_SPONLY|FCVAR_NOTIFY|FCVAR_DONTRECORD).SetString(PLUGIN_VERSION);
|
||||
|
||||
g_bLagCompTriggers = CreateConVar("sm_lagcomp_triggers", "1", "Lag compensate triggers", FCVAR_NONE, true, 0.0, true, 1.0);
|
||||
g_bLagCompPhysboxes = CreateConVar("sm_lagcomp_physboxes", "1", "Lag compensate physboxes", FCVAR_NONE, true, 0.0, true, 1.0);
|
||||
|
||||
AutoExecConfig(true);
|
||||
|
||||
Handle hGameData = LoadGameConfigFile("LagCompensation.games");
|
||||
if(!hGameData)
|
||||
SetFailState("Failed to load LagCompensation gamedata.");
|
||||
@ -324,14 +332,15 @@ public void OnPluginStart()
|
||||
|
||||
delete hGameData;
|
||||
|
||||
g_bHasOnEntitySpawned = GetFeatureStatus(FeatureType_Capability, "SDKHook_OnEntitySpawned") == FeatureStatus_Available;
|
||||
// Capability provider from https://github.com/alliedmodders/sourcemod/pull/1078
|
||||
g_bHasOnEntitySpawned = true;
|
||||
|
||||
g_hCookie_DisableLagComp = RegClientCookie("disable_lagcomp", "", CookieAccess_Private);
|
||||
RegConsoleCmd("sm_lagcomp", OnToggleLagCompSettings);
|
||||
RegConsoleCmd("sm_0ping", OnToggleLagCompSettings);
|
||||
SetCookieMenuItem(MenuHandler_CookieMenu, 0, "LagCompensation");
|
||||
//g_hCookie_DisableLagComp = RegClientCookie("disable_lagcomp", "", CookieAccess_Private);
|
||||
//RegConsoleCmd("sm_lagcomp", OnToggleLagCompSettings);
|
||||
//RegConsoleCmd("sm_0ping", OnToggleLagCompSettings);
|
||||
//SetCookieMenuItem(MenuHandler_CookieMenu, 0, "LagCompensation");
|
||||
|
||||
CreateTimer(0.1, DisableLagCompTimer, _, TIMER_REPEAT);
|
||||
//CreateTimer(0.1, DisableLagCompTimer, _, TIMER_REPEAT);
|
||||
|
||||
RegAdminCmd("sm_unlag", Command_AddLagCompensation, ADMFLAG_RCON, "sm_unlag <entidx>");
|
||||
RegAdminCmd("sm_lagged", Command_CheckLagCompensated, ADMFLAG_GENERIC, "sm_lagged");
|
||||
@ -443,13 +452,23 @@ public void OnMapEnd()
|
||||
g_bCleaningUp = true;
|
||||
}
|
||||
|
||||
public void OnClientConnected(int client)
|
||||
{
|
||||
g_bDisableLagComp[client] = false;
|
||||
g_iDisableLagComp[client] = 0;
|
||||
}
|
||||
//public void OnClientConnected(int client)
|
||||
//{
|
||||
// g_bDisableLagComp[client] = false;
|
||||
// g_iDisableLagComp[client] = 0;
|
||||
//}
|
||||
//
|
||||
//public void OnClientCookiesCached(int client)
|
||||
//{
|
||||
// char sBuffer[16];
|
||||
// GetClientCookie(client, g_hCookie_DisableLagComp, sBuffer, sizeof(sBuffer));
|
||||
// if(sBuffer[0])
|
||||
// g_bDisableLagComp[client] = true;
|
||||
// else
|
||||
// g_bDisableLagComp[client] = false;
|
||||
//}
|
||||
|
||||
public void OnClientCookiesCached(int client)
|
||||
public void OnClientSettingsChanged(int client)
|
||||
{
|
||||
if(!IsClientInGame(client))
|
||||
return;
|
||||
@ -458,11 +477,11 @@ public void OnClientCookiesCached(int client)
|
||||
g_aLerpTicks[client] = RoundToNearest(fLerpTime / g_fTickInterval);
|
||||
}
|
||||
|
||||
public void OnClientDisconnect(int client)
|
||||
{
|
||||
g_bDisableLagComp[client] = false;
|
||||
g_iDisableLagComp[client] = 0;
|
||||
}
|
||||
//public void OnClientDisconnect(int client)
|
||||
//{
|
||||
// g_bDisableLagComp[client] = false;
|
||||
// g_iDisableLagComp[client] = 0;
|
||||
//}
|
||||
|
||||
public void OnEntityCreated(int entity, const char[] classname)
|
||||
{
|
||||
@ -588,8 +607,14 @@ bool CheckEntityForLagComp(int entity, const char[] classname, bool bRecursive=f
|
||||
StrEqual(classname, "trigger_push", false) ||
|
||||
StrEqual(classname, "trigger_teleport", false);
|
||||
|
||||
if(bTrigger && !g_bLagCompTriggers.BoolValue)
|
||||
return false;
|
||||
|
||||
bool bPhysbox = !strncmp(classname, "func_physbox", 12, false);
|
||||
|
||||
if(bPhysbox && !g_bLagCompPhysboxes.BoolValue)
|
||||
return false;
|
||||
|
||||
bool bBlacklisted = CheckBit(g_aBlacklisted, entity);
|
||||
|
||||
if(!bTrigger && !bPhysbox || bBlacklisted)
|
||||
@ -837,7 +862,7 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
|
||||
// To get the original behavior back lets assume they actually have 0 latency.
|
||||
// To avoid abusing toggling lagcomp we increase/decrease this var by 1 every 100ms.
|
||||
// This is so we only skip single ticks at a time. Fully ON = 0, Fully OFF = MAX_RECORDS
|
||||
iDelta -= g_iDisableLagComp[client];
|
||||
//iDelta -= g_iDisableLagComp[client];
|
||||
|
||||
if(iDelta < 0)
|
||||
iDelta = 0;
|
||||
@ -1318,91 +1343,94 @@ stock void PrintToBoth(const char[] format, any ...)
|
||||
}
|
||||
}
|
||||
|
||||
public Action DisableLagCompTimer(Handle timer)
|
||||
{
|
||||
for(int client = 1; client <= MaxClients; client++)
|
||||
{
|
||||
if(g_bDisableLagComp[client] && g_iDisableLagComp[client] < MAX_RECORDS)
|
||||
{
|
||||
g_iDisableLagComp[client]++;
|
||||
}
|
||||
else if(!g_bDisableLagComp[client] && g_iDisableLagComp[client] > 0)
|
||||
{
|
||||
g_iDisableLagComp[client]--;
|
||||
}
|
||||
}
|
||||
//public Action DisableLagCompTimer(Handle timer)
|
||||
//{
|
||||
// for(int client = 1; client <= MaxClients; client++)
|
||||
// {
|
||||
// if(g_bDisableLagComp[client] && g_iDisableLagComp[client] < MAX_RECORDS)
|
||||
// {
|
||||
// g_iDisableLagComp[client]++;
|
||||
// }
|
||||
// else if(!g_bDisableLagComp[client] && g_iDisableLagComp[client] > 0)
|
||||
// {
|
||||
// g_iDisableLagComp[client]--;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return Plugin_Continue;
|
||||
//}
|
||||
//
|
||||
//public Action OnLagCompSettings(int client, int args)
|
||||
//{
|
||||
// ShowSettingsMenu(client);
|
||||
// return Plugin_Handled;
|
||||
//}
|
||||
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
public Action OnLagCompSettings(int client, int args)
|
||||
{
|
||||
ShowSettingsMenu(client);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action OnToggleLagCompSettings(int client, int args)
|
||||
{
|
||||
ToggleLagCompSettings(client);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public void ToggleLagCompSettings(int client)
|
||||
{
|
||||
g_bDisableLagComp[client] = !g_bDisableLagComp[client];
|
||||
SetClientCookie(client, g_hCookie_DisableLagComp, g_bDisableLagComp[client] ? "1" : "");
|
||||
|
||||
PrintToChat(client, "\x04[LagCompensation]\x01 LagCompensation has been %s.", g_bDisableLagComp[client] ? "disabled" : "enabled");
|
||||
}
|
||||
|
||||
public void ShowSettingsMenu(int client)
|
||||
{
|
||||
Menu menu = new Menu(MenuHandler_MainMenu);
|
||||
menu.SetTitle("LagCompensation Settings", client);
|
||||
menu.ExitBackButton = true;
|
||||
|
||||
char sBuffer[128];
|
||||
Format(sBuffer, sizeof(sBuffer), "LagCompensation: %s", g_bDisableLagComp[client] ? "Disabled" : "Enabled");
|
||||
menu.AddItem("0", sBuffer);
|
||||
|
||||
menu.Display(client, MENU_TIME_FOREVER);
|
||||
}
|
||||
|
||||
public void MenuHandler_CookieMenu(int client, CookieMenuAction action, any info, char[] buffer, int maxlen)
|
||||
{
|
||||
switch(action)
|
||||
{
|
||||
case(CookieMenuAction_DisplayOption):
|
||||
{
|
||||
Format(buffer, maxlen, "LagCompensation", client);
|
||||
}
|
||||
case(CookieMenuAction_SelectOption):
|
||||
{
|
||||
ShowSettingsMenu(client);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int MenuHandler_MainMenu(Menu menu, MenuAction action, int client, int selection)
|
||||
{
|
||||
switch(action)
|
||||
{
|
||||
case(MenuAction_Select):
|
||||
{
|
||||
switch(selection)
|
||||
{
|
||||
case(0): ToggleLagCompSettings(client);
|
||||
}
|
||||
|
||||
ShowSettingsMenu(client);
|
||||
}
|
||||
case(MenuAction_Cancel):
|
||||
{
|
||||
ShowCookieMenu(client);
|
||||
}
|
||||
case(MenuAction_End):
|
||||
{
|
||||
delete menu;
|
||||
}
|
||||
}
|
||||
}
|
||||
//public Action OnToggleLagCompSettings(int client, int args)
|
||||
//{
|
||||
// ToggleLagCompSettings(client);
|
||||
// return Plugin_Handled;
|
||||
//}
|
||||
//
|
||||
//public void ToggleLagCompSettings(int client)
|
||||
//{
|
||||
// if(!client)
|
||||
// return;
|
||||
//
|
||||
// g_bDisableLagComp[client] = !g_bDisableLagComp[client];
|
||||
// SetClientCookie(client, g_hCookie_DisableLagComp, g_bDisableLagComp[client] ? "1" : "");
|
||||
//
|
||||
// PrintToChat(client, "\x04[LagCompensation]\x01 LagCompensation has been %s.", g_bDisableLagComp[client] ? "disabled" : "enabled");
|
||||
//}
|
||||
//
|
||||
//public void ShowSettingsMenu(int client)
|
||||
//{
|
||||
// Menu menu = new Menu(MenuHandler_MainMenu);
|
||||
// menu.SetTitle("LagCompensation Settings", client);
|
||||
// menu.ExitBackButton = true;
|
||||
//
|
||||
// char sBuffer[128];
|
||||
// Format(sBuffer, sizeof(sBuffer), "LagCompensation: %s", g_bDisableLagComp[client] ? "Disabled" : "Enabled");
|
||||
// menu.AddItem("0", sBuffer);
|
||||
//
|
||||
// menu.Display(client, MENU_TIME_FOREVER);
|
||||
//}
|
||||
//
|
||||
//public void MenuHandler_CookieMenu(int client, CookieMenuAction action, any info, char[] buffer, int maxlen)
|
||||
//{
|
||||
// switch(action)
|
||||
// {
|
||||
// case(CookieMenuAction_DisplayOption):
|
||||
// {
|
||||
// Format(buffer, maxlen, "LagCompensation", client);
|
||||
// }
|
||||
// case(CookieMenuAction_SelectOption):
|
||||
// {
|
||||
// ShowSettingsMenu(client);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//public int MenuHandler_MainMenu(Menu menu, MenuAction action, int client, int selection)
|
||||
//{
|
||||
// switch(action)
|
||||
// {
|
||||
// case(MenuAction_Select):
|
||||
// {
|
||||
// switch(selection)
|
||||
// {
|
||||
// case(0): ToggleLagCompSettings(client);
|
||||
// }
|
||||
//
|
||||
// ShowSettingsMenu(client);
|
||||
// }
|
||||
// case(MenuAction_Cancel):
|
||||
// {
|
||||
// ShowCookieMenu(client);
|
||||
// }
|
||||
// case(MenuAction_End):
|
||||
// {
|
||||
// delete menu;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
Loading…
Reference in New Issue
Block a user