mirror of
https://github.com/shavitush/bhoptimer.git
synced 2025-12-06 18:08:26 +00:00
Got rid of the cached cvars bullshit
protip: don't follow hosties' coding conventions that shit sucks mad dick
This commit is contained in:
parent
7f81c9d6c0
commit
3114eec03f
@ -76,11 +76,6 @@ ConVar gCV_RankingsIntegration = null;
|
||||
ConVar gCV_CustomChat = null;
|
||||
ConVar gCV_Colon = null;
|
||||
|
||||
// cached cvars
|
||||
bool gB_RankingsIntegration = true;
|
||||
int gI_CustomChat = 1;
|
||||
char gS_Colon[MAXLENGTH_CMESSAGE] = ":";
|
||||
|
||||
// cache
|
||||
EngineVersion gEV_Type = Engine_Unknown;
|
||||
|
||||
@ -147,10 +142,6 @@ public void OnPluginStart()
|
||||
gCV_CustomChat = CreateConVar("shavit_chat_customchat", "1", "Allow custom chat names or message colors?\n0 - Disabled\n1 - Enabled (requires chat flag/'shavit_chat' override)\n2 - Allow use by everyone", 0, true, 0.0, true, 2.0);
|
||||
gCV_Colon = CreateConVar("shavit_chat_colon", ":", "String to use as the colon when messaging.");
|
||||
|
||||
gCV_RankingsIntegration.AddChangeHook(OnConVarChanged);
|
||||
gCV_CustomChat.AddChangeHook(OnConVarChanged);
|
||||
gCV_Colon.AddChangeHook(OnConVarChanged);
|
||||
|
||||
AutoExecConfig();
|
||||
|
||||
gSM_Messages = new StringMap();
|
||||
@ -388,7 +379,7 @@ public Action Hook_SayText2(UserMsg msg_id, any msg, const int[] players, int pl
|
||||
char sName[MAXLENGTH_NAME];
|
||||
char sCMessage[MAXLENGTH_CMESSAGE];
|
||||
|
||||
if((gI_CustomChat > 0 && (CheckCommandAccess(client, "shavit_chat", ADMFLAG_CHAT) || gI_CustomChat == 2)) && gI_ChatSelection[client] == -1)
|
||||
if((gCV_CustomChat.IntValue > 0 && (CheckCommandAccess(client, "shavit_chat", ADMFLAG_CHAT) || gCV_CustomChat.IntValue == 2)) && gI_ChatSelection[client] == -1)
|
||||
{
|
||||
if(gB_NameEnabled[client])
|
||||
{
|
||||
@ -431,7 +422,10 @@ public Action Hook_SayText2(UserMsg msg_id, any msg, const int[] players, int pl
|
||||
}
|
||||
}
|
||||
|
||||
ReplaceFormats(sTextFormatting, MAXLENGTH_BUFFER, sName, gS_Colon, sOriginalText);
|
||||
char sColon[MAXLENGTH_CMESSAGE];
|
||||
gCV_Colon.GetString(sColon, MAXLENGTH_CMESSAGE);
|
||||
|
||||
ReplaceFormats(sTextFormatting, MAXLENGTH_BUFFER, sName, sColon, sOriginalText);
|
||||
|
||||
DataPack pack = new DataPack();
|
||||
pack.WriteCell(GetClientSerial(client)); // client serial
|
||||
@ -517,13 +511,6 @@ void Frame_SendText(DataPack pack)
|
||||
EndMessage();
|
||||
}
|
||||
|
||||
public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] newValue)
|
||||
{
|
||||
gB_RankingsIntegration = gCV_RankingsIntegration.BoolValue;
|
||||
gI_CustomChat = gCV_CustomChat.IntValue;
|
||||
gCV_Colon.GetString(gS_Colon, MAXLENGTH_CMESSAGE);
|
||||
}
|
||||
|
||||
public void Shavit_OnDatabaseLoaded()
|
||||
{
|
||||
gH_SQL = Shavit_GetDatabase();
|
||||
@ -679,7 +666,7 @@ public Action Command_CCName(int client, int args)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if(!(gI_CustomChat > 0 && (CheckCommandAccess(client, "shavit_chat", ADMFLAG_CHAT) || gI_CustomChat == 2)))
|
||||
if(!(gCV_CustomChat.IntValue > 0 && (CheckCommandAccess(client, "shavit_chat", ADMFLAG_CHAT) || gCV_CustomChat.IntValue == 2)))
|
||||
{
|
||||
Shavit_PrintToChat(client, "%T", "NoCommandAccess", client);
|
||||
|
||||
@ -728,7 +715,7 @@ public Action Command_CCMessage(int client, int args)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if(!(gI_CustomChat > 0 && (CheckCommandAccess(client, "shavit_chat", ADMFLAG_CHAT) || gI_CustomChat == 2)))
|
||||
if(!(gCV_CustomChat.IntValue > 0 && (CheckCommandAccess(client, "shavit_chat", ADMFLAG_CHAT) || gCV_CustomChat.IntValue == 2)))
|
||||
{
|
||||
Shavit_PrintToChat(client, "%T", "NoCommandAccess", client);
|
||||
|
||||
@ -787,7 +774,7 @@ Action ShowChatRanksMenu(int client, int item)
|
||||
FormatEx(sDisplay, MAXLENGTH_DISPLAY, "%T\n ", "AutoAssign", client);
|
||||
menu.AddItem("-2", sDisplay, (gI_ChatSelection[client] == -2)? ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
|
||||
|
||||
if(gI_CustomChat > 0 && (CheckCommandAccess(client, "shavit_chat", ADMFLAG_CHAT) || gI_CustomChat == 2))
|
||||
if(gCV_CustomChat.IntValue > 0 && (CheckCommandAccess(client, "shavit_chat", ADMFLAG_CHAT) || gCV_CustomChat.IntValue == 2))
|
||||
{
|
||||
FormatEx(sDisplay, MAXLENGTH_DISPLAY, "%T\n ", "CustomChat", client);
|
||||
menu.AddItem("-1", sDisplay, (gI_ChatSelection[client] == -1)? ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
|
||||
@ -1031,7 +1018,10 @@ void PreviewChat(int client, int rank)
|
||||
char sSampleText[MAXLENGTH_MESSAGE];
|
||||
FormatEx(sSampleText, MAXLENGTH_MESSAGE, "%sThe quick brown fox jumps over the lazy dog", sCMessage);
|
||||
|
||||
ReplaceFormats(sTextFormatting, MAXLENGTH_BUFFER, sName, gS_Colon, sSampleText);
|
||||
char sColon[MAXLENGTH_CMESSAGE];
|
||||
gCV_Colon.GetString(sColon, MAXLENGTH_CMESSAGE);
|
||||
|
||||
ReplaceFormats(sTextFormatting, MAXLENGTH_BUFFER, sName, sColon, sSampleText);
|
||||
|
||||
Handle hSayText2 = StartMessageOne("SayText2", client, USERMSG_RELIABLE|USERMSG_BLOCKHOOKS);
|
||||
|
||||
@ -1067,7 +1057,7 @@ void PreviewChat(int client, int rank)
|
||||
|
||||
bool HasRankAccess(int client, int rank)
|
||||
{
|
||||
bool bAllowCustom = gI_CustomChat > 0 && (CheckCommandAccess(client, "shavit_chat", ADMFLAG_CHAT) || gI_CustomChat == 2);
|
||||
bool bAllowCustom = gCV_CustomChat.IntValue > 0 && (CheckCommandAccess(client, "shavit_chat", ADMFLAG_CHAT) || gCV_CustomChat.IntValue == 2);
|
||||
|
||||
if(rank == -2 ||
|
||||
(rank == -1 && bAllowCustom))
|
||||
@ -1119,7 +1109,7 @@ bool HasRankAccess(int client, int rank)
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!gB_Rankings || !gB_RankingsIntegration)
|
||||
if(!gB_Rankings || !gCV_RankingsIntegration.BoolValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -1201,7 +1191,7 @@ public Action Command_CCList(int client, int args)
|
||||
continue;
|
||||
}
|
||||
|
||||
if(gI_CustomChat > 0 && (CheckCommandAccess(i, "shavit_chat", ADMFLAG_CHAT) || gI_CustomChat == 2))
|
||||
if(gCV_CustomChat.IntValue > 0 && (CheckCommandAccess(i, "shavit_chat", ADMFLAG_CHAT) || gCV_CustomChat.IntValue == 2))
|
||||
{
|
||||
PrintToConsole(client, "%N (%d/#%d) (name: \"%s\"; message: \"%s\")", i, i, GetClientUserId(i), gS_CustomName[i], gS_CustomMessage[i]);
|
||||
}
|
||||
@ -1358,7 +1348,7 @@ public void SQL_CreateTable_Callback(Database db, DBResultSet results, const cha
|
||||
continue;
|
||||
}
|
||||
|
||||
if(gI_CustomChat > 0 && (CheckCommandAccess(i, "shavit_chat", ADMFLAG_CHAT) || gI_CustomChat == 2))
|
||||
if(gCV_CustomChat.IntValue > 0 && (CheckCommandAccess(i, "shavit_chat", ADMFLAG_CHAT) || gCV_CustomChat.IntValue == 2))
|
||||
{
|
||||
LoadFromDatabase(i);
|
||||
}
|
||||
|
||||
@ -116,12 +116,6 @@ ConVar gCV_VelocityTeleport = null;
|
||||
ConVar gCV_DefaultStyle = null;
|
||||
|
||||
// cached cvars
|
||||
bool gB_Restart = true;
|
||||
bool gB_Pause = true;
|
||||
bool gB_AllowTimerWithoutZone = false;
|
||||
bool gB_BlockPreJump = false;
|
||||
bool gB_NoZAxisSpeed = true;
|
||||
bool gB_VelocityTeleport = false;
|
||||
int gI_DefaultStyle = 0;
|
||||
bool gB_StyleCookies = true;
|
||||
|
||||
@ -317,12 +311,6 @@ public void OnPluginStart()
|
||||
gCV_VelocityTeleport = CreateConVar("shavit_core_velocityteleport", "0", "Teleport the client when changing its velocity? (for special styles)", 0, true, 0.0, true, 1.0);
|
||||
gCV_DefaultStyle = CreateConVar("shavit_core_defaultstyle", "0", "Default style ID.\nAdd the '!' prefix to disable style cookies - i.e. \"!3\" to *force* scroll to be the default style.", 0, true, 0.0);
|
||||
|
||||
gCV_Restart.AddChangeHook(OnConVarChanged);
|
||||
gCV_Pause.AddChangeHook(OnConVarChanged);
|
||||
gCV_AllowTimerWithoutZone.AddChangeHook(OnConVarChanged);
|
||||
gCV_BlockPreJump.AddChangeHook(OnConVarChanged);
|
||||
gCV_NoZAxisSpeed.AddChangeHook(OnConVarChanged);
|
||||
gCV_VelocityTeleport.AddChangeHook(OnConVarChanged);
|
||||
gCV_DefaultStyle.AddChangeHook(OnConVarChanged);
|
||||
|
||||
AutoExecConfig();
|
||||
@ -358,18 +346,8 @@ public void OnPluginStart()
|
||||
|
||||
public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] newValue)
|
||||
{
|
||||
gB_Restart = gCV_Restart.BoolValue;
|
||||
gB_Pause = gCV_Pause.BoolValue;
|
||||
gB_AllowTimerWithoutZone = gCV_AllowTimerWithoutZone.BoolValue;
|
||||
gB_BlockPreJump = gCV_BlockPreJump.BoolValue;
|
||||
gB_NoZAxisSpeed = gCV_NoZAxisSpeed.BoolValue;
|
||||
gB_VelocityTeleport = gCV_VelocityTeleport.BoolValue;
|
||||
|
||||
if(convar == gCV_DefaultStyle)
|
||||
{
|
||||
gB_StyleCookies = newValue[0] != '!';
|
||||
gI_DefaultStyle = StringToInt(newValue[1]);
|
||||
}
|
||||
gB_StyleCookies = (newValue[0] != '!');
|
||||
gI_DefaultStyle = StringToInt(newValue[1]);
|
||||
}
|
||||
|
||||
public void OnLibraryAdded(const char[] name)
|
||||
@ -458,7 +436,7 @@ public Action Command_StartTimer(int client, int args)
|
||||
char sCommand[16];
|
||||
GetCmdArg(0, sCommand, 16);
|
||||
|
||||
if(!gB_Restart)
|
||||
if(!gCV_Restart.BoolValue)
|
||||
{
|
||||
if(args != -1)
|
||||
{
|
||||
@ -475,14 +453,14 @@ public Action Command_StartTimer(int client, int args)
|
||||
track = Track_Bonus;
|
||||
}
|
||||
|
||||
if(gB_AllowTimerWithoutZone || (gB_Zones && (Shavit_ZoneExists(Zone_Start, track) || gB_KZMap)))
|
||||
if(gCV_AllowTimerWithoutZone.BoolValue || (gB_Zones && (Shavit_ZoneExists(Zone_Start, track) || gB_KZMap)))
|
||||
{
|
||||
Call_StartForward(gH_Forwards_OnRestart);
|
||||
Call_PushCell(client);
|
||||
Call_PushCell(track);
|
||||
Call_Finish();
|
||||
|
||||
if(gB_AllowTimerWithoutZone)
|
||||
if(gCV_AllowTimerWithoutZone.BoolValue)
|
||||
{
|
||||
StartTimer(client, track);
|
||||
}
|
||||
@ -557,7 +535,7 @@ public Action Command_TogglePause(int client, int args)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if(!gB_Pause)
|
||||
if(!gCV_Pause.BoolValue)
|
||||
{
|
||||
char sCommand[16];
|
||||
GetCmdArg(0, sCommand, 16);
|
||||
@ -719,7 +697,7 @@ public Action Command_Style(int client, int args)
|
||||
|
||||
if(gB_WR)
|
||||
{
|
||||
Shavit_GetWRTime(i, time, Track_Main);
|
||||
time = Shavit_GetWorldRecord(i, Track_Main);
|
||||
}
|
||||
|
||||
if(time > 0.0)
|
||||
@ -835,7 +813,7 @@ void ChangeClientStyle(int client, int style, bool manual)
|
||||
|
||||
StopTimer(client);
|
||||
|
||||
if(gB_AllowTimerWithoutZone || (gB_Zones && (Shavit_ZoneExists(Zone_Start, gA_Timers[client].iTrack) || gB_KZMap)))
|
||||
if(gCV_AllowTimerWithoutZone.BoolValue || (gB_Zones && (Shavit_ZoneExists(Zone_Start, gA_Timers[client].iTrack) || gB_KZMap)))
|
||||
{
|
||||
Call_StartForward(gH_Forwards_OnRestart);
|
||||
Call_PushCell(client);
|
||||
@ -929,7 +907,7 @@ void VelocityChanges(int data)
|
||||
fAbsVelocity[1] /= x;
|
||||
}
|
||||
|
||||
if(!gB_VelocityTeleport)
|
||||
if(!gCV_VelocityTeleport.BoolValue)
|
||||
{
|
||||
SetEntPropVector(client, Prop_Data, "m_vecAbsVelocity", fAbsVelocity);
|
||||
}
|
||||
@ -1092,7 +1070,7 @@ public int Native_FinishMap(Handle handler, int numParams)
|
||||
|
||||
if(gB_WR)
|
||||
{
|
||||
Shavit_GetPlayerPB(client, style, oldtime, track);
|
||||
oldtime = Shavit_GetClientPB(client, style, track);
|
||||
}
|
||||
|
||||
Call_PushCell(oldtime);
|
||||
@ -1361,7 +1339,7 @@ void StartTimer(int client, int track)
|
||||
float fSpeed[3];
|
||||
GetEntPropVector(client, Prop_Data, "m_vecVelocity", fSpeed);
|
||||
|
||||
if(!gB_NoZAxisSpeed || gA_StyleSettings[gA_Timers[client].iStyle].bPrespeed || (fSpeed[2] == 0.0 && SquareRoot(Pow(fSpeed[0], 2.0) + Pow(fSpeed[1], 2.0)) <= 290.0))
|
||||
if(!gCV_NoZAxisSpeed.BoolValue || gA_StyleSettings[gA_Timers[client].iStyle].bPrespeed || (fSpeed[2] == 0.0 && SquareRoot(Pow(fSpeed[0], 2.0) + Pow(fSpeed[1], 2.0)) <= 290.0))
|
||||
{
|
||||
Action result = Plugin_Continue;
|
||||
Call_StartForward(gH_Forwards_Start);
|
||||
@ -2302,7 +2280,7 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
|
||||
gA_Timers[client].iGroundTicks = 0;
|
||||
}
|
||||
|
||||
if(bInStart && gB_BlockPreJump && !gA_StyleSettings[gA_Timers[client].iStyle].bPrespeed && (vel[2] > 0 || (buttons & IN_JUMP) > 0))
|
||||
if(bInStart && gCV_BlockPreJump.BoolValue && !gA_StyleSettings[gA_Timers[client].iStyle].bPrespeed && (vel[2] > 0 || (buttons & IN_JUMP) > 0))
|
||||
{
|
||||
vel[2] = 0.0;
|
||||
buttons &= ~IN_JUMP;
|
||||
|
||||
@ -146,38 +146,7 @@ ConVar gCV_MaxCP = null;
|
||||
ConVar gCV_MaxCP_Segmented = null;
|
||||
|
||||
// cached cvars
|
||||
int gI_GodMode = 3;
|
||||
int gI_PreSpeed = 1;
|
||||
bool gB_HideTeamChanges = true;
|
||||
bool gB_RespawnOnTeam = true;
|
||||
bool gB_RespawnOnRestart = true;
|
||||
bool gB_StartOnSpawn = true;
|
||||
float gF_PrestrafeLimit = 30.00;
|
||||
bool gB_HideRadar = true;
|
||||
bool gB_TeleportCommands = true;
|
||||
bool gB_NoWeaponDrops = true;
|
||||
bool gB_NoBlock = true;
|
||||
bool gB_NoBlood = false;
|
||||
float gF_AutoRespawn = 1.5;
|
||||
int gI_CreateSpawnPoints = 6;
|
||||
bool gB_DisableRadio = false;
|
||||
bool gB_Scoreboard = true;
|
||||
int gI_WeaponCommands = 2;
|
||||
int gI_PlayerOpacity = -1;
|
||||
bool gB_StaticPrestrafe = true;
|
||||
int gI_NoclipMe = true;
|
||||
float gF_AdvertisementInterval = 600.0;
|
||||
bool gB_Checkpoints = true;
|
||||
int gI_RemoveRagdolls = 1;
|
||||
char gS_ClanTag[32] = "{tr}{styletag} :: {time}";
|
||||
bool gB_DropAll = true;
|
||||
bool gB_ResetTargetname = false;
|
||||
bool gB_RestoreStates = false;
|
||||
bool gB_JointeamHook = true;
|
||||
int gI_HumanTeam = 0;
|
||||
int gI_SpectatorList = 1;
|
||||
int gI_MaxCP = 1000;
|
||||
int gI_MaxCP_Segmented = 10;
|
||||
|
||||
// dhooks
|
||||
Handle gH_GetPlayerMaxSpeed = null;
|
||||
@ -290,12 +259,6 @@ public void OnPluginStart()
|
||||
gA_Advertisements = new ArrayList(300);
|
||||
hostname = FindConVar("hostname");
|
||||
hostport = FindConVar("hostport");
|
||||
mp_humanteam = FindConVar("mp_humanteam");
|
||||
|
||||
if(mp_humanteam == null)
|
||||
{
|
||||
mp_humanteam = FindConVar("mp_humans_must_join_team");
|
||||
}
|
||||
|
||||
// cvars and stuff
|
||||
gCV_GodMode = CreateConVar("shavit_misc_godmode", "3", "Enable godmode for players?\n0 - Disabled\n1 - Only prevent fall/world damage.\n2 - Only prevent damage from other players.\n3 - Full godmode.", 0, true, 0.0, true, 3.0);
|
||||
@ -330,42 +293,17 @@ public void OnPluginStart()
|
||||
gCV_MaxCP = CreateConVar("shavit_misc_maxcp", "1000", "Maximum amount of checkpoints.\nNote: Very high values will result in high memory usage!", 0, true, 1.0, true, 10000.0);
|
||||
gCV_MaxCP_Segmented = CreateConVar("shavit_misc_maxcp_seg", "10", "Maximum amount of segmented checkpoints. Make this less or equal to shavit_misc_maxcp.\nNote: Very high values will result in HUGE memory usage!", 0, true, 1.0, true, 50.0);
|
||||
|
||||
gCV_GodMode.AddChangeHook(OnConVarChanged);
|
||||
gCV_PreSpeed.AddChangeHook(OnConVarChanged);
|
||||
gCV_HideTeamChanges.AddChangeHook(OnConVarChanged);
|
||||
gCV_RespawnOnTeam.AddChangeHook(OnConVarChanged);
|
||||
gCV_RespawnOnRestart.AddChangeHook(OnConVarChanged);
|
||||
gCV_StartOnSpawn.AddChangeHook(OnConVarChanged);
|
||||
gCV_PrestrafeLimit.AddChangeHook(OnConVarChanged);
|
||||
gCV_HideRadar.AddChangeHook(OnConVarChanged);
|
||||
gCV_TeleportCommands.AddChangeHook(OnConVarChanged);
|
||||
gCV_NoWeaponDrops.AddChangeHook(OnConVarChanged);
|
||||
gCV_NoBlock.AddChangeHook(OnConVarChanged);
|
||||
gCV_NoBlood.AddChangeHook(OnConVarChanged);
|
||||
gCV_AutoRespawn.AddChangeHook(OnConVarChanged);
|
||||
gCV_CreateSpawnPoints.AddChangeHook(OnConVarChanged);
|
||||
gCV_DisableRadio.AddChangeHook(OnConVarChanged);
|
||||
gCV_Scoreboard.AddChangeHook(OnConVarChanged);
|
||||
gCV_WeaponCommands.AddChangeHook(OnConVarChanged);
|
||||
gCV_PlayerOpacity.AddChangeHook(OnConVarChanged);
|
||||
gCV_StaticPrestrafe.AddChangeHook(OnConVarChanged);
|
||||
gCV_NoclipMe.AddChangeHook(OnConVarChanged);
|
||||
gCV_AdvertisementInterval.AddChangeHook(OnConVarChanged);
|
||||
gCV_Checkpoints.AddChangeHook(OnConVarChanged);
|
||||
gCV_RemoveRagdolls.AddChangeHook(OnConVarChanged);
|
||||
gCV_ClanTag.AddChangeHook(OnConVarChanged);
|
||||
gCV_DropAll.AddChangeHook(OnConVarChanged);
|
||||
gCV_ResetTargetname.AddChangeHook(OnConVarChanged);
|
||||
gCV_RestoreStates.AddChangeHook(OnConVarChanged);
|
||||
gCV_JointeamHook.AddChangeHook(OnConVarChanged);
|
||||
gCV_SpectatorList.AddChangeHook(OnConVarChanged);
|
||||
gCV_MaxCP.AddChangeHook(OnConVarChanged);
|
||||
gCV_MaxCP_Segmented.AddChangeHook(OnConVarChanged);
|
||||
AutoExecConfig();
|
||||
|
||||
mp_humanteam = FindConVar("mp_humanteam");
|
||||
|
||||
if(mp_humanteam == null)
|
||||
{
|
||||
mp_humanteam = FindConVar("mp_humans_must_join_team");
|
||||
}
|
||||
|
||||
mp_humanteam.AddChangeHook(OnConVarChanged);
|
||||
|
||||
AutoExecConfig();
|
||||
|
||||
// crons
|
||||
if(gEV_Type != Engine_TF2)
|
||||
{
|
||||
@ -499,38 +437,6 @@ public void Shavit_OnStyleChanged(int client, int oldstyle, int newstyle, int tr
|
||||
|
||||
public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] newValue)
|
||||
{
|
||||
gI_GodMode = gCV_GodMode.IntValue;
|
||||
gI_PreSpeed = gCV_PreSpeed.IntValue;
|
||||
gB_HideTeamChanges = gCV_HideTeamChanges.BoolValue;
|
||||
gB_RespawnOnTeam = gCV_RespawnOnTeam.BoolValue;
|
||||
gB_RespawnOnRestart = gCV_RespawnOnRestart.BoolValue;
|
||||
gB_StartOnSpawn = gCV_StartOnSpawn.BoolValue;
|
||||
gF_PrestrafeLimit = gCV_PrestrafeLimit.FloatValue;
|
||||
gB_HideRadar = gCV_HideRadar.BoolValue;
|
||||
gB_TeleportCommands = gCV_TeleportCommands.BoolValue;
|
||||
gB_NoWeaponDrops = gCV_NoWeaponDrops.BoolValue;
|
||||
gB_NoBlock = gCV_NoBlock.BoolValue;
|
||||
gB_NoBlood = gCV_NoBlood.BoolValue;
|
||||
gF_AutoRespawn = gCV_AutoRespawn.FloatValue;
|
||||
gI_CreateSpawnPoints = gCV_CreateSpawnPoints.IntValue;
|
||||
gB_DisableRadio = gCV_DisableRadio.BoolValue;
|
||||
gB_Scoreboard = gCV_Scoreboard.BoolValue;
|
||||
gI_WeaponCommands = gCV_WeaponCommands.IntValue;
|
||||
gI_PlayerOpacity = gCV_PlayerOpacity.IntValue;
|
||||
gB_StaticPrestrafe = gCV_StaticPrestrafe.BoolValue;
|
||||
gI_NoclipMe = gCV_NoclipMe.IntValue;
|
||||
gF_AdvertisementInterval = gCV_AdvertisementInterval.FloatValue;
|
||||
gB_Checkpoints = gCV_Checkpoints.BoolValue;
|
||||
gI_RemoveRagdolls = gCV_RemoveRagdolls.IntValue;
|
||||
gCV_ClanTag.GetString(gS_ClanTag, 32);
|
||||
gB_DropAll = gCV_DropAll.BoolValue;
|
||||
gB_ResetTargetname = gCV_ResetTargetname.BoolValue;
|
||||
gB_RestoreStates = gCV_RestoreStates.BoolValue;
|
||||
gB_JointeamHook = gCV_JointeamHook.BoolValue;
|
||||
gI_SpectatorList = gCV_SpectatorList.IntValue;
|
||||
gI_MaxCP = gCV_MaxCP.IntValue;
|
||||
gI_MaxCP_Segmented = gCV_MaxCP_Segmented.IntValue;
|
||||
|
||||
if(convar == mp_humanteam)
|
||||
{
|
||||
if(StrEqual(newValue, "t", false) || StrEqual(newValue, "red", false))
|
||||
@ -572,7 +478,7 @@ public void OnMapStart()
|
||||
GetCurrentMap(gS_CurrentMap, 192);
|
||||
GetMapDisplayName(gS_CurrentMap, gS_CurrentMap, 192);
|
||||
|
||||
if(gI_CreateSpawnPoints > 0)
|
||||
if(gCV_CreateSpawnPoints.IntValue > 0)
|
||||
{
|
||||
int iEntity = -1;
|
||||
|
||||
@ -584,7 +490,7 @@ public void OnMapStart()
|
||||
float fOrigin[3];
|
||||
GetEntPropVector(iEntity, Prop_Send, "m_vecOrigin", fOrigin);
|
||||
|
||||
for(int i = 1; i <= gI_CreateSpawnPoints; i++)
|
||||
for(int i = 1; i <= gCV_CreateSpawnPoints.IntValue; i++)
|
||||
{
|
||||
for(int iTeam = 1; iTeam <= 2; iTeam++)
|
||||
{
|
||||
@ -605,9 +511,9 @@ public void OnMapStart()
|
||||
Shavit_OnChatConfigLoaded();
|
||||
}
|
||||
|
||||
if(gF_AdvertisementInterval > 0.0)
|
||||
if(gCV_AdvertisementInterval.FloatValue > 0.0)
|
||||
{
|
||||
CreateTimer(gF_AdvertisementInterval, Timer_Advertisement, 0, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
|
||||
CreateTimer(gCV_AdvertisementInterval.FloatValue, Timer_Advertisement, 0, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -694,7 +600,7 @@ public void OnLibraryRemoved(const char[] name)
|
||||
|
||||
public Action Command_Jointeam(int client, const char[] command, int args)
|
||||
{
|
||||
if(!IsValidClient(client) || !gB_JointeamHook)
|
||||
if(!IsValidClient(client) || !gCV_JointeamHook.BoolValue)
|
||||
{
|
||||
return Plugin_Continue;
|
||||
}
|
||||
@ -751,7 +657,7 @@ public Action Command_Jointeam(int client, const char[] command, int args)
|
||||
}
|
||||
}
|
||||
|
||||
if(gB_RespawnOnTeam && bRespawn)
|
||||
if(gCV_RespawnOnTeam.BoolValue && bRespawn)
|
||||
{
|
||||
if(gEV_Type == Engine_TF2)
|
||||
{
|
||||
@ -789,7 +695,7 @@ void CleanSwitchTeam(int client, int team, bool change = false)
|
||||
|
||||
public Action Command_Radio(int client, const char[] command, int args)
|
||||
{
|
||||
if(gB_DisableRadio)
|
||||
if(gCV_DisableRadio.BoolValue)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
@ -799,7 +705,7 @@ public Action Command_Radio(int client, const char[] command, int args)
|
||||
|
||||
public MRESReturn CCSPlayer__GetPlayerMaxSpeed(int pThis, Handle hReturn)
|
||||
{
|
||||
if(!gB_StaticPrestrafe || !IsValidClient(pThis, true))
|
||||
if(!gCV_StaticPrestrafe.BoolValue || !IsValidClient(pThis, true))
|
||||
{
|
||||
return MRES_Ignored;
|
||||
}
|
||||
@ -818,7 +724,7 @@ public Action Timer_Scoreboard(Handle Timer)
|
||||
continue;
|
||||
}
|
||||
|
||||
if(gB_Scoreboard)
|
||||
if(gCV_Scoreboard.BoolValue)
|
||||
{
|
||||
UpdateScoreboard(i);
|
||||
}
|
||||
@ -889,8 +795,7 @@ void UpdateScoreboard(int client)
|
||||
return;
|
||||
}
|
||||
|
||||
float fPB = 0.0;
|
||||
Shavit_GetPlayerPB(client, 0, fPB, Track_Main);
|
||||
float fPB = Shavit_GetClientPB(client, 0, Track_Main);
|
||||
|
||||
int iScore = (fPB != 0.0 && fPB < 2000)? -RoundToFloor(fPB):-2000;
|
||||
|
||||
@ -913,7 +818,10 @@ void UpdateScoreboard(int client)
|
||||
void UpdateClanTag(int client)
|
||||
{
|
||||
// no clan tags in tf2
|
||||
if(gEV_Type == Engine_TF2 || StrEqual(gS_ClanTag, "0"))
|
||||
char sTag[32];
|
||||
gCV_ClanTag.GetString(sTag, 32);
|
||||
|
||||
if(gEV_Type == Engine_TF2 || StrEqual(sTag, "0"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -964,7 +872,7 @@ void UpdateClanTag(int client)
|
||||
}
|
||||
|
||||
char sCustomTag[32];
|
||||
strcopy(sCustomTag, 32, gS_ClanTag);
|
||||
strcopy(sCustomTag, 32, sTag);
|
||||
ReplaceString(sCustomTag, 32, "{style}", gS_StyleStrings[gI_Style[client]].sStyleName);
|
||||
ReplaceString(sCustomTag, 32, "{styletag}", gS_StyleStrings[gI_Style[client]].sClanTag);
|
||||
ReplaceString(sCustomTag, 32, "{time}", sTime);
|
||||
@ -998,7 +906,7 @@ public Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float
|
||||
// prespeed
|
||||
if(!bNoclip && !gA_StyleSettings[gI_Style[client]].bPrespeed && Shavit_InsideZone(client, Zone_Start, track))
|
||||
{
|
||||
if((gI_PreSpeed == 2 || gI_PreSpeed == 3) && gI_GroundEntity[client] == -1 && iGroundEntity != -1 && (buttons & IN_JUMP) > 0)
|
||||
if((gCV_PreSpeed.IntValue == 2 || gCV_PreSpeed.IntValue == 3) && gI_GroundEntity[client] == -1 && iGroundEntity != -1 && (buttons & IN_JUMP) > 0)
|
||||
{
|
||||
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, view_as<float>({0.0, 0.0, 0.0}));
|
||||
Shavit_PrintToChat(client, "%T", "BHStartZoneDisallowed", client, gS_ChatStrings.sVariable, gS_ChatStrings.sText, gS_ChatStrings.sWarning, gS_ChatStrings.sText);
|
||||
@ -1008,14 +916,14 @@ public Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
if(gI_PreSpeed == 1 || gI_PreSpeed >= 3)
|
||||
if(gCV_PreSpeed.IntValue == 1 || gCV_PreSpeed.IntValue >= 3)
|
||||
{
|
||||
float fSpeed[3];
|
||||
GetEntPropVector(client, Prop_Data, "m_vecAbsVelocity", fSpeed);
|
||||
|
||||
float fLimit = (gA_StyleSettings[gI_Style[client]].fRunspeed + gF_PrestrafeLimit);
|
||||
float fLimit = (gA_StyleSettings[gI_Style[client]].fRunspeed + gCV_PrestrafeLimit.FloatValue);
|
||||
|
||||
if(gI_PreSpeed < 4)
|
||||
if(gCV_PreSpeed.IntValue < 4)
|
||||
{
|
||||
// if trying to jump, add a very low limit to stop prespeeding in an elegant way
|
||||
// otherwise, make sure nothing weird is happening (such as sliding at ridiculous speeds, at zone enter)
|
||||
@ -1079,7 +987,7 @@ public void OnClientPutInServer(int client)
|
||||
|
||||
public void OnClientDisconnect(int client)
|
||||
{
|
||||
if(gB_NoWeaponDrops)
|
||||
if(gCV_NoWeaponDrops.BoolValue)
|
||||
{
|
||||
int entity = -1;
|
||||
|
||||
@ -1144,7 +1052,7 @@ public Action OnTakeDamage(int victim, int attacker)
|
||||
}
|
||||
}
|
||||
|
||||
switch(gI_GodMode)
|
||||
switch(gCV_GodMode.IntValue)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
@ -1180,7 +1088,7 @@ public Action OnTakeDamage(int victim, int attacker)
|
||||
|
||||
public void OnWeaponDrop(int client, int entity)
|
||||
{
|
||||
if(gB_NoWeaponDrops && IsValidEntity(entity))
|
||||
if(gCV_NoWeaponDrops.BoolValue && IsValidEntity(entity))
|
||||
{
|
||||
AcceptEntityInput(entity, "Kill");
|
||||
}
|
||||
@ -1313,7 +1221,7 @@ public Action Command_Teleport(int client, int args)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if(!gB_TeleportCommands)
|
||||
if(!gCV_TeleportCommands.BoolValue)
|
||||
{
|
||||
Shavit_PrintToChat(client, "%T", "CommandDisabled", client, gS_ChatStrings.sWarning, gS_ChatStrings.sText);
|
||||
|
||||
@ -1426,7 +1334,7 @@ public Action Command_Weapon(int client, int args)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if(gI_WeaponCommands == 0)
|
||||
if(gCV_WeaponCommands.IntValue == 0)
|
||||
{
|
||||
Shavit_PrintToChat(client, "%T", "CommandDisabled", client, gS_ChatStrings.sWarning, gS_ChatStrings.sText);
|
||||
|
||||
@ -1516,7 +1424,7 @@ public Action Command_Save(int client, int args)
|
||||
int iMaxCPs = GetMaxCPs(client);
|
||||
bool bSegmenting = CanSegment(client);
|
||||
|
||||
if(!gB_Checkpoints && !bSegmenting)
|
||||
if(!gCV_Checkpoints.BoolValue && !bSegmenting)
|
||||
{
|
||||
Shavit_PrintToChat(client, "%T", "FeatureDisabled", client, gS_ChatStrings.sWarning, gS_ChatStrings.sText);
|
||||
|
||||
@ -1568,7 +1476,7 @@ public Action Command_Tele(int client, int args)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if(!gB_Checkpoints)
|
||||
if(!gCV_Checkpoints.BoolValue)
|
||||
{
|
||||
Shavit_PrintToChat(client, "%T", "FeatureDisabled", client, gS_ChatStrings.sWarning, gS_ChatStrings.sText);
|
||||
|
||||
@ -1584,7 +1492,7 @@ public Action Command_Tele(int client, int args)
|
||||
|
||||
int parsed = StringToInt(arg);
|
||||
|
||||
if(0 < parsed <= gI_MaxCP)
|
||||
if(0 < parsed <= gCV_MaxCP.IntValue)
|
||||
{
|
||||
index = parsed;
|
||||
}
|
||||
@ -1599,7 +1507,7 @@ public Action OpenCheckpointsMenu(int client, int item)
|
||||
{
|
||||
bool bSegmented = CanSegment(client);
|
||||
|
||||
if(!gB_Checkpoints && !bSegmented)
|
||||
if(!gCV_Checkpoints.BoolValue && !bSegmented)
|
||||
{
|
||||
Shavit_PrintToChat(client, "%T", "FeatureDisabled", client, gS_ChatStrings.sWarning, gS_ChatStrings.sText);
|
||||
|
||||
@ -1620,7 +1528,7 @@ public Action OpenCheckpointsMenu(int client, int item)
|
||||
|
||||
char sDisplay[64];
|
||||
FormatEx(sDisplay, 64, "%T", "MiscCheckpointSave", client, (gA_CheckpointsCache[client].iCheckpoints + 1));
|
||||
menu.AddItem("save", sDisplay, (gA_CheckpointsCache[client].iCheckpoints < gI_MaxCP)? ITEMDRAW_DEFAULT:ITEMDRAW_DISABLED);
|
||||
menu.AddItem("save", sDisplay, (gA_CheckpointsCache[client].iCheckpoints < gCV_MaxCP.IntValue)? ITEMDRAW_DEFAULT:ITEMDRAW_DISABLED);
|
||||
|
||||
if(gA_CheckpointsCache[client].iCheckpoints > 0)
|
||||
{
|
||||
@ -1958,7 +1866,7 @@ bool SaveCheckpoint(int client, int index, bool overflow = false)
|
||||
|
||||
void TeleportToCheckpoint(int client, int index, bool suppressMessage)
|
||||
{
|
||||
if(index < 0 || index > gI_MaxCP || (!gB_Checkpoints && !CanSegment(client)))
|
||||
if(index < 0 || index > gCV_MaxCP.IntValue || (!gCV_Checkpoints.BoolValue && !CanSegment(client)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -2097,14 +2005,14 @@ public Action Command_Noclip(int client, int args)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if(gI_NoclipMe == 0)
|
||||
if(gCV_NoclipMe.IntValue == 0)
|
||||
{
|
||||
Shavit_PrintToChat(client, "%T", "FeatureDisabled", client, gS_ChatStrings.sWarning, gS_ChatStrings.sText);
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
else if(gI_NoclipMe == 2 && !CheckCommandAccess(client, "admin_noclipme", ADMFLAG_CHEATS))
|
||||
else if(gCV_NoclipMe.IntValue == 2 && !CheckCommandAccess(client, "admin_noclipme", ADMFLAG_CHEATS))
|
||||
{
|
||||
Shavit_PrintToChat(client, "%T", "LackingAccess", client, gS_ChatStrings.sWarning, gS_ChatStrings.sText);
|
||||
|
||||
@ -2143,7 +2051,7 @@ public Action CommandListener_Noclip(int client, const char[] command, int args)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
if((gI_NoclipMe == 1 || (gI_NoclipMe == 2 && CheckCommandAccess(client, "noclipme", ADMFLAG_CHEATS))) && command[0] == '+')
|
||||
if((gCV_NoclipMe.IntValue == 1 || (gCV_NoclipMe.IntValue == 2 && CheckCommandAccess(client, "noclipme", ADMFLAG_CHEATS))) && command[0] == '+')
|
||||
{
|
||||
if(Shavit_GetTimerStatus(client) != Timer_Stopped)
|
||||
{
|
||||
@ -2215,8 +2123,8 @@ public Action Command_Specs(int client, int args)
|
||||
continue;
|
||||
}
|
||||
|
||||
if((gI_SpectatorList == 1 && !bIsAdmin && CheckCommandAccess(i, "admin_speclisthide", ADMFLAG_KICK)) ||
|
||||
(gI_SpectatorList == 2 && !CanUserTarget(client, i)))
|
||||
if((gCV_SpectatorList.IntValue == 1 && !bIsAdmin && CheckCommandAccess(i, "admin_speclisthide", ADMFLAG_KICK)) ||
|
||||
(gCV_SpectatorList.IntValue == 2 && !CanUserTarget(client, i)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -2257,7 +2165,7 @@ public Action Shavit_OnStart(int client)
|
||||
return Plugin_Stop;
|
||||
}
|
||||
|
||||
if(gB_ResetTargetname || Shavit_IsPracticeMode(client)) // practice mode can be abused to break map triggers
|
||||
if(gCV_ResetTargetname.BoolValue || Shavit_IsPracticeMode(client)) // practice mode can be abused to break map triggers
|
||||
{
|
||||
DispatchKeyValue(client, "targetname", "");
|
||||
SetEntPropString(client, Prop_Data, "m_iClassname", "player");
|
||||
@ -2320,7 +2228,7 @@ public void Shavit_OnWorldRecord(int client, int style, float time, int jumps, i
|
||||
|
||||
public void Shavit_OnRestart(int client, int track)
|
||||
{
|
||||
if(!gB_RespawnOnRestart)
|
||||
if(!gCV_RespawnOnRestart.BoolValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -2355,7 +2263,7 @@ public void Shavit_OnRestart(int client, int track)
|
||||
CS_RespawnPlayer(client);
|
||||
}
|
||||
|
||||
if(gB_RespawnOnRestart)
|
||||
if(gCV_RespawnOnRestart.BoolValue)
|
||||
{
|
||||
RestartTimer(client, track);
|
||||
}
|
||||
@ -2378,7 +2286,7 @@ public Action Respawn(Handle Timer, any data)
|
||||
CS_RespawnPlayer(client);
|
||||
}
|
||||
|
||||
if(gB_RespawnOnRestart)
|
||||
if(gCV_RespawnOnRestart.BoolValue)
|
||||
{
|
||||
RestartTimer(client, Track_Main);
|
||||
}
|
||||
@ -2403,19 +2311,19 @@ public void Player_Spawn(Event event, const char[] name, bool dontBroadcast)
|
||||
{
|
||||
int serial = GetClientSerial(client);
|
||||
|
||||
if(gB_HideRadar)
|
||||
if(gCV_HideRadar.BoolValue)
|
||||
{
|
||||
RequestFrame(RemoveRadar, serial);
|
||||
}
|
||||
|
||||
if(gB_StartOnSpawn)
|
||||
if(gCV_StartOnSpawn.BoolValue)
|
||||
{
|
||||
RestartTimer(client, Track_Main);
|
||||
}
|
||||
|
||||
if(gB_SaveStates[client])
|
||||
{
|
||||
if(gB_RestoreStates)
|
||||
if(gCV_RestoreStates.BoolValue)
|
||||
{
|
||||
RequestFrame(RestoreState, serial);
|
||||
}
|
||||
@ -2426,7 +2334,7 @@ public void Player_Spawn(Event event, const char[] name, bool dontBroadcast)
|
||||
}
|
||||
}
|
||||
|
||||
if(gB_Scoreboard)
|
||||
if(gCV_Scoreboard.BoolValue)
|
||||
{
|
||||
UpdateScoreboard(client);
|
||||
}
|
||||
@ -2434,15 +2342,15 @@ public void Player_Spawn(Event event, const char[] name, bool dontBroadcast)
|
||||
UpdateClanTag(client);
|
||||
}
|
||||
|
||||
if(gB_NoBlock)
|
||||
if(gCV_NoBlock.BoolValue)
|
||||
{
|
||||
SetEntProp(client, Prop_Data, "m_CollisionGroup", 2);
|
||||
}
|
||||
|
||||
if(gI_PlayerOpacity != -1)
|
||||
if(gCV_PlayerOpacity.IntValue != -1)
|
||||
{
|
||||
SetEntityRenderMode(client, RENDER_TRANSCOLOR);
|
||||
SetEntityRenderColor(client, 255, 255, 255, gI_PlayerOpacity);
|
||||
SetEntityRenderColor(client, 255, 255, 255, gCV_PlayerOpacity.IntValue);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2489,7 +2397,7 @@ void RestoreState(any data)
|
||||
|
||||
public Action Player_Notifications(Event event, const char[] name, bool dontBroadcast)
|
||||
{
|
||||
if(gB_HideTeamChanges)
|
||||
if(gCV_HideTeamChanges.BoolValue)
|
||||
{
|
||||
event.BroadcastDisabled = true;
|
||||
}
|
||||
@ -2503,13 +2411,13 @@ public Action Player_Notifications(Event event, const char[] name, bool dontBroa
|
||||
SaveState(client);
|
||||
}
|
||||
|
||||
if(gF_AutoRespawn > 0.0 && StrEqual(name, "player_death"))
|
||||
if(gCV_AutoRespawn.FloatValue > 0.0 && StrEqual(name, "player_death"))
|
||||
{
|
||||
CreateTimer(gF_AutoRespawn, Respawn, GetClientSerial(client), TIMER_FLAG_NO_MAPCHANGE);
|
||||
CreateTimer(gCV_AutoRespawn.FloatValue, Respawn, GetClientSerial(client), TIMER_FLAG_NO_MAPCHANGE);
|
||||
}
|
||||
}
|
||||
|
||||
switch(gI_RemoveRagdolls)
|
||||
switch(gCV_RemoveRagdolls.IntValue)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
@ -2540,7 +2448,7 @@ public Action Player_Notifications(Event event, const char[] name, bool dontBroa
|
||||
|
||||
public void Weapon_Fire(Event event, const char[] name, bool dB)
|
||||
{
|
||||
if(gI_WeaponCommands < 2)
|
||||
if(gCV_WeaponCommands.IntValue < 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -2638,7 +2546,7 @@ public Action Shotgun_Shot(const char[] te_name, const int[] Players, int numCli
|
||||
|
||||
public Action EffectDispatch(const char[] te_name, const Players[], int numClients, float delay)
|
||||
{
|
||||
if(!gB_NoBlood)
|
||||
if(!gCV_NoBlood.BoolValue)
|
||||
{
|
||||
return Plugin_Continue;
|
||||
}
|
||||
@ -2670,7 +2578,7 @@ public Action EffectDispatch(const char[] te_name, const Players[], int numClien
|
||||
|
||||
public Action WorldDecal(const char[] te_name, const Players[], int numClients, float delay)
|
||||
{
|
||||
if(!gB_NoBlood)
|
||||
if(!gCV_NoBlood.BoolValue)
|
||||
{
|
||||
return Plugin_Continue;
|
||||
}
|
||||
@ -2729,7 +2637,7 @@ int GetDecalName(int index, char[] sDecalName, int maxlen)
|
||||
|
||||
public void Shavit_OnFinish(int client)
|
||||
{
|
||||
if(!gB_Scoreboard)
|
||||
if(!gCV_Scoreboard.BoolValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -2756,7 +2664,7 @@ public void Shavit_OnResume(int client, int track)
|
||||
|
||||
public Action Command_Drop(int client, const char[] command, int argc)
|
||||
{
|
||||
if(!gB_DropAll || !IsValidClient(client) || gEV_Type == Engine_TF2)
|
||||
if(!gCV_DropAll.BoolValue || !IsValidClient(client) || gEV_Type == Engine_TF2)
|
||||
{
|
||||
return Plugin_Continue;
|
||||
}
|
||||
@ -2841,5 +2749,5 @@ bool CanSegment(int client)
|
||||
|
||||
int GetMaxCPs(int client)
|
||||
{
|
||||
return CanSegment(client)? gI_MaxCP_Segmented:gI_MaxCP;
|
||||
return CanSegment(client)? gCV_MaxCP_Segmented.IntValue:gCV_MaxCP.IntValue;
|
||||
}
|
||||
|
||||
@ -64,10 +64,7 @@ ArrayList gA_ValidMaps = null;
|
||||
StringMap gA_MapTiers = null;
|
||||
|
||||
ConVar gCV_PointsPerTier = null;
|
||||
float gF_PointsPerTier = 50.0;
|
||||
|
||||
ConVar gCV_WeightingMultiplier = null;
|
||||
float gF_WeightingMultiplier = 0.975;
|
||||
|
||||
int gI_Rank[MAXPLAYERS+1];
|
||||
float gF_Points[MAXPLAYERS+1];
|
||||
@ -145,10 +142,7 @@ public void OnPluginStart()
|
||||
RegAdminCmd("sm_recalcall", Command_RecalcAll, ADMFLAG_ROOT, "Recalculate the points for every map on the server. Run this after you change the ranking multiplier for a style or after you install the plugin.");
|
||||
|
||||
gCV_PointsPerTier = CreateConVar("shavit_rankings_pointspertier", "50.0", "Base points to use for per-tier scaling.\nRead the design idea to see how it works: https://github.com/shavitush/bhoptimer/issues/465", 0, true, 1.0);
|
||||
gCV_PointsPerTier.AddChangeHook(OnConVarChanged);
|
||||
|
||||
gCV_WeightingMultiplier = CreateConVar("shavit_rankings_weighting", "0.975", "Weighing multiplier. 1.0 to disable weighting.\nFormula: p[1] * this^0 + p[2] * this^1 + p[3] * this^2 + ... + p[n] * this^(n-1)\nRestart server to apply.", 0, true, 0.01, true, 1.0);
|
||||
gCV_WeightingMultiplier.AddChangeHook(OnConVarChanged);
|
||||
|
||||
AutoExecConfig();
|
||||
|
||||
@ -330,7 +324,7 @@ public void SQL_CreateTable_Callback(Database db, DBResultSet results, const cha
|
||||
"END LOOP; " ...
|
||||
"CLOSE cur; " ...
|
||||
"RETURN total; " ...
|
||||
"END;;", gS_MySQLPrefix, gF_WeightingMultiplier);
|
||||
"END;;", gS_MySQLPrefix, gCV_WeightingMultiplier.FloatValue);
|
||||
|
||||
RunLongFastQuery(bSuccess, "CREATE GetRecordPoints",
|
||||
"CREATE FUNCTION GetRecordPoints(rstyle INT, rtrack INT, rtime FLOAT, rmap CHAR(128), pointspertier FLOAT, stylemultiplier FLOAT) " ...
|
||||
@ -383,12 +377,6 @@ void RunLongFastQuery(bool &success, const char[] func, const char[] query, any
|
||||
}
|
||||
}
|
||||
|
||||
public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] newValue)
|
||||
{
|
||||
gF_PointsPerTier = gCV_PointsPerTier.FloatValue;
|
||||
gF_WeightingMultiplier = gCV_WeightingMultiplier.FloatValue;
|
||||
}
|
||||
|
||||
public void OnClientConnected(int client)
|
||||
{
|
||||
gI_Rank[client] = 0;
|
||||
@ -688,7 +676,7 @@ public Action Command_RecalcAll(int client, int args)
|
||||
|
||||
else
|
||||
{
|
||||
FormatEx(sQuery, 192, "UPDATE %splayertimes SET points = GetRecordPoints(%d, track, time, map, %.1f, %.3f) WHERE style = %d;", gS_MySQLPrefix, i, gF_PointsPerTier, gA_StyleSettings[i].fRankingMultiplier, i);
|
||||
FormatEx(sQuery, 192, "UPDATE %splayertimes SET points = GetRecordPoints(%d, track, time, map, %.1f, %.3f) WHERE style = %d;", gS_MySQLPrefix, i, gCV_PointsPerTier.FloatValue, gA_StyleSettings[i].fRankingMultiplier, i);
|
||||
}
|
||||
|
||||
trans.AddQuery(sQuery);
|
||||
@ -762,7 +750,7 @@ void RecalculateMap(const char[] map, const int track, const int style)
|
||||
|
||||
char sQuery[192];
|
||||
FormatEx(sQuery, 192, "UPDATE %splayertimes SET points = GetRecordPoints(%d, %d, time, '%s', %.1f, %.3f) WHERE style = %d AND track = %d AND map = '%s';",
|
||||
gS_MySQLPrefix, style, track, map, gF_PointsPerTier, gA_StyleSettings[style].fRankingMultiplier, style, track, map);
|
||||
gS_MySQLPrefix, style, track, map, gCV_PointsPerTier.FloatValue, gA_StyleSettings[style].fRankingMultiplier, style, track, map);
|
||||
|
||||
gH_SQL.Query(SQL_Recalculate_Callback, sQuery, 0, DBPrio_High);
|
||||
|
||||
|
||||
@ -123,16 +123,6 @@ ConVar gCV_BotShooting = null;
|
||||
ConVar gCV_BotPlusUse = null;
|
||||
ConVar gCV_BotWeapon = null;
|
||||
|
||||
// cached cvars
|
||||
bool gB_Enabled = true;
|
||||
float gF_ReplayDelay = 5.0;
|
||||
float gF_TimeLimit = 7200.0;
|
||||
int gI_DefaultTeam = 3;
|
||||
bool gB_CentralBot = true;
|
||||
int gI_BotShooting = 3;
|
||||
bool gB_BotPlusUse = true;
|
||||
char gS_BotWeapon[32] = "";
|
||||
|
||||
// timer settings
|
||||
int gI_Styles = 0;
|
||||
stylestrings_t gS_StyleStrings[STYLE_LIMIT];
|
||||
@ -234,14 +224,7 @@ public void OnPluginStart()
|
||||
gCV_BotPlusUse = CreateConVar("shavit_replay_botplususe", "1", "Allow bots to use +use?", 0, true, 0.0, true, 1.0);
|
||||
gCV_BotWeapon = CreateConVar("shavit_replay_botweapon", "", "Choose which weapon the bot will hold.\nLeave empty to use the default.\nSet to \"none\" to have none.\nExample: weapon_usp");
|
||||
|
||||
gCV_Enabled.AddChangeHook(OnConVarChanged);
|
||||
gCV_ReplayDelay.AddChangeHook(OnConVarChanged);
|
||||
gCV_TimeLimit.AddChangeHook(OnConVarChanged);
|
||||
gCV_DefaultTeam.AddChangeHook(OnConVarChanged);
|
||||
gCV_CentralBot.AddChangeHook(OnConVarChanged);
|
||||
gCV_BotShooting.AddChangeHook(OnConVarChanged);
|
||||
gCV_BotPlusUse.AddChangeHook(OnConVarChanged);
|
||||
gCV_BotWeapon.AddChangeHook(OnConVarChanged);
|
||||
|
||||
AutoExecConfig();
|
||||
|
||||
@ -271,19 +254,7 @@ public void OnPluginStart()
|
||||
|
||||
public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] newValue)
|
||||
{
|
||||
gB_Enabled = gCV_Enabled.BoolValue;
|
||||
gF_ReplayDelay = gCV_ReplayDelay.FloatValue;
|
||||
gF_TimeLimit = gCV_TimeLimit.FloatValue;
|
||||
gI_DefaultTeam = gCV_DefaultTeam.IntValue;
|
||||
gB_CentralBot = gCV_CentralBot.BoolValue;
|
||||
gI_BotShooting = gCV_BotShooting.IntValue;
|
||||
gB_BotPlusUse = gCV_BotPlusUse.BoolValue;
|
||||
gCV_BotWeapon.GetString(gS_BotWeapon, 32);
|
||||
|
||||
if(convar == gCV_CentralBot)
|
||||
{
|
||||
OnMapStart();
|
||||
}
|
||||
OnMapStart();
|
||||
}
|
||||
|
||||
public void OnAdminMenuCreated(Handle topmenu)
|
||||
@ -352,7 +323,7 @@ public int Native_GetReplayBotCurrentFrame(Handle handler, int numParams)
|
||||
|
||||
public int Native_GetReplayBotIndex(Handle handler, int numParams)
|
||||
{
|
||||
if(gB_CentralBot)
|
||||
if(gCV_CentralBot.BoolValue)
|
||||
{
|
||||
return gA_CentralCache.iClient;
|
||||
}
|
||||
@ -365,7 +336,7 @@ public int Native_IsReplayDataLoaded(Handle handler, int numParams)
|
||||
int style = GetNativeCell(1);
|
||||
int track = GetNativeCell(2);
|
||||
|
||||
if(gB_CentralBot)
|
||||
if(gCV_CentralBot.BoolValue)
|
||||
{
|
||||
return view_as<int>(gA_CentralCache.iClient != -1 && gA_CentralCache.iReplayStatus != Replay_Idle && gA_FrameCache[style][track].iFrameCount > 0);
|
||||
}
|
||||
@ -406,7 +377,7 @@ public int Native_ReloadReplay(Handle handler, int numParams)
|
||||
loaded = DefaultLoadReplay(style, track);
|
||||
}
|
||||
|
||||
if(gB_CentralBot)
|
||||
if(gCV_CentralBot.BoolValue)
|
||||
{
|
||||
if(gA_CentralCache.iStyle == style && gA_CentralCache.iTrack == track)
|
||||
{
|
||||
@ -426,7 +397,7 @@ public int Native_ReloadReplay(Handle handler, int numParams)
|
||||
{
|
||||
gI_ReplayTick[style] = 0;
|
||||
gRS_ReplayStatus[style] = Replay_Start;
|
||||
CreateTimer((gF_ReplayDelay / 2.0), Timer_StartReplay, style, TIMER_FLAG_NO_MAPCHANGE);
|
||||
CreateTimer((gCV_ReplayDelay.FloatValue / 2.0), Timer_StartReplay, style, TIMER_FLAG_NO_MAPCHANGE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -445,7 +416,7 @@ public int Native_ReloadReplays(Handle handler, int numParams)
|
||||
continue;
|
||||
}
|
||||
|
||||
for(int j = 0; j < ((gB_CentralBot)? TRACKS_SIZE:1); j++)
|
||||
for(int j = 0; j < ((gCV_CentralBot.BoolValue)? TRACKS_SIZE:1); j++)
|
||||
{
|
||||
if(Shavit_ReloadReplay(i, j, restart))
|
||||
{
|
||||
@ -510,7 +481,7 @@ public int Native_GetReplayTime(Handle handler, int numParams)
|
||||
return view_as<int>(0.0);
|
||||
}
|
||||
|
||||
if(gB_CentralBot)
|
||||
if(gCV_CentralBot.BoolValue)
|
||||
{
|
||||
if(gA_CentralCache.iReplayStatus == Replay_End)
|
||||
{
|
||||
@ -537,7 +508,7 @@ public int Native_HijackAngles(Handle handler, int numParams)
|
||||
|
||||
public int Native_GetReplayBotStyle(Handle handler, int numParams)
|
||||
{
|
||||
return (gB_CentralBot && gA_CentralCache.iReplayStatus == Replay_Idle)? -1:GetReplayStyle(GetNativeCell(1));
|
||||
return (gCV_CentralBot.BoolValue && gA_CentralCache.iReplayStatus == Replay_Idle)? -1:GetReplayStyle(GetNativeCell(1));
|
||||
}
|
||||
|
||||
public int Native_GetReplayBotTrack(Handle handler, int numParams)
|
||||
@ -547,7 +518,7 @@ public int Native_GetReplayBotTrack(Handle handler, int numParams)
|
||||
|
||||
public int Native_GetReplayBotType(Handle handler, int numParams)
|
||||
{
|
||||
return view_as<int>((gB_CentralBot)? Replay_Central:Replay_Legacy);
|
||||
return view_as<int>((gCV_CentralBot.BoolValue)? Replay_Central:Replay_Legacy);
|
||||
}
|
||||
|
||||
public int Native_Replay_DeleteMap(Handle handler, int numParams)
|
||||
@ -562,7 +533,7 @@ public int Native_Replay_DeleteMap(Handle handler, int numParams)
|
||||
continue;
|
||||
}
|
||||
|
||||
for(int j = 0; j < ((gB_CentralBot)? TRACKS_SIZE:1); j++)
|
||||
for(int j = 0; j < ((gCV_CentralBot.BoolValue)? TRACKS_SIZE:1); j++)
|
||||
{
|
||||
char sTrack[4];
|
||||
FormatEx(sTrack, 4, "_%d", j);
|
||||
@ -638,7 +609,7 @@ void SQL_SetPrefix()
|
||||
|
||||
public Action Cron(Handle Timer)
|
||||
{
|
||||
if(!gB_Enabled)
|
||||
if(!gCV_Enabled.BoolValue)
|
||||
{
|
||||
bot_quota.IntValue = 0;
|
||||
|
||||
@ -653,16 +624,16 @@ public Action Cron(Handle Timer)
|
||||
|
||||
for(int i = 0; i < gI_Styles; i++)
|
||||
{
|
||||
for(int j = 0; j < ((gB_CentralBot)? TRACKS_SIZE:1); j++)
|
||||
for(int j = 0; j < ((gCV_CentralBot.BoolValue)? TRACKS_SIZE:1); j++)
|
||||
{
|
||||
if(!gB_CentralBot && gI_ReplayBotClient[i] != 0)
|
||||
if(!gCV_CentralBot.BoolValue && gI_ReplayBotClient[i] != 0)
|
||||
{
|
||||
UpdateReplayInfo(gI_ReplayBotClient[i], i, GetReplayLength(i, j), j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(gB_CentralBot && gA_CentralCache.iClient != -1)
|
||||
if(gCV_CentralBot.BoolValue && gA_CentralCache.iClient != -1)
|
||||
{
|
||||
if(gA_CentralCache.iStyle != -1)
|
||||
{
|
||||
@ -738,7 +709,7 @@ public void OnMapStart()
|
||||
GetCurrentMap(gS_Map, 160);
|
||||
GetMapDisplayName(gS_Map, gS_Map, 160);
|
||||
|
||||
if(!gB_Enabled)
|
||||
if(!gCV_Enabled.BoolValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -857,7 +828,7 @@ public void OnMapStart()
|
||||
|
||||
bool loaded = false;
|
||||
|
||||
for(int j = 0; j < ((gB_CentralBot)? TRACKS_SIZE:1); j++)
|
||||
for(int j = 0; j < ((gCV_CentralBot.BoolValue)? TRACKS_SIZE:1); j++)
|
||||
{
|
||||
delete gA_Frames[i][j];
|
||||
gA_Frames[i][j] = new ArrayList(CELLS_PER_FRAME);
|
||||
@ -869,7 +840,7 @@ public void OnMapStart()
|
||||
loaded = DefaultLoadReplay(i, j);
|
||||
}
|
||||
|
||||
if(!gB_CentralBot)
|
||||
if(!gCV_CentralBot.BoolValue)
|
||||
{
|
||||
ServerCommand((gEV_Type != Engine_TF2)? "bot_add":"tf_bot_add");
|
||||
gI_ExpectedBots++;
|
||||
@ -878,12 +849,12 @@ public void OnMapStart()
|
||||
{
|
||||
gI_ReplayTick[i] = 0;
|
||||
gRS_ReplayStatus[i] = Replay_Start;
|
||||
CreateTimer((gF_ReplayDelay / 2.0), Timer_StartReplay, i, TIMER_FLAG_NO_MAPCHANGE);
|
||||
CreateTimer((gCV_ReplayDelay.FloatValue / 2.0), Timer_StartReplay, i, TIMER_FLAG_NO_MAPCHANGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(gB_CentralBot)
|
||||
if(gCV_CentralBot.BoolValue)
|
||||
{
|
||||
gI_ExpectedBots = 1;
|
||||
ServerCommand((gEV_Type != Engine_TF2)? "bot_add":"tf_bot_add");
|
||||
@ -1140,7 +1111,7 @@ bool DeleteReplay(int style, int track)
|
||||
return false;
|
||||
}
|
||||
|
||||
if(gB_CentralBot && gA_CentralCache.iStyle == style && gA_CentralCache.iTrack == track)
|
||||
if(gCV_CentralBot.BoolValue && gA_CentralCache.iStyle == style && gA_CentralCache.iTrack == track)
|
||||
{
|
||||
StopCentralReplay(0);
|
||||
}
|
||||
@ -1195,7 +1166,7 @@ public void OnClientPutInServer(int client)
|
||||
|
||||
else
|
||||
{
|
||||
if(!gB_CentralBot)
|
||||
if(!gCV_CentralBot.BoolValue)
|
||||
{
|
||||
for(int i = 0; i < gI_Styles; i++)
|
||||
{
|
||||
@ -1233,7 +1204,7 @@ public void OnEntityCreated(int entity, const char[] classname)
|
||||
|
||||
public Action HookTriggers(int entity, int other)
|
||||
{
|
||||
if(gB_Enabled && 1 <= other <= MaxClients && IsFakeClient(other))
|
||||
if(gCV_Enabled.BoolValue && 1 <= other <= MaxClients && IsFakeClient(other))
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
@ -1280,7 +1251,7 @@ void FormatStyle(const char[] source, int style, bool central, float time, int t
|
||||
|
||||
void UpdateReplayInfo(int client, int style, float time, int track)
|
||||
{
|
||||
if(!gB_Enabled || !IsValidClient(client) || !IsFakeClient(client))
|
||||
if(!gCV_Enabled.BoolValue || !IsValidClient(client) || !IsFakeClient(client))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -1338,7 +1309,7 @@ void UpdateReplayInfo(int client, int style, float time, int track)
|
||||
|
||||
gB_DontCallTimer = true;
|
||||
|
||||
if(!gB_CentralBot && iFrameCount == 0)
|
||||
if(!gCV_CentralBot.BoolValue && iFrameCount == 0)
|
||||
{
|
||||
if(IsPlayerAlive(client))
|
||||
{
|
||||
@ -1371,11 +1342,14 @@ void UpdateReplayInfo(int client, int style, float time, int track)
|
||||
}
|
||||
}
|
||||
|
||||
if(gEV_Type != Engine_TF2 && strlen(gS_BotWeapon) > 0)
|
||||
char sWeapon[32];
|
||||
gCV_BotWeapon.GetString(sWeapon, 32);
|
||||
|
||||
if(gEV_Type != Engine_TF2 && strlen(sWeapon) > 0)
|
||||
{
|
||||
int iWeapon = GetEntPropEnt(client, Prop_Data, "m_hActiveWeapon");
|
||||
|
||||
if(StrEqual(gS_BotWeapon, "none"))
|
||||
if(StrEqual(sWeapon, "none"))
|
||||
{
|
||||
if(iWeapon != -1 && IsValidEntity(iWeapon))
|
||||
{
|
||||
@ -1392,7 +1366,7 @@ void UpdateReplayInfo(int client, int style, float time, int track)
|
||||
{
|
||||
GetEntityClassname(iWeapon, sClassname, 32);
|
||||
|
||||
if(!StrEqual(gS_BotWeapon, sClassname))
|
||||
if(!StrEqual(sWeapon, sClassname))
|
||||
{
|
||||
CS_DropWeapon(client, iWeapon, false);
|
||||
AcceptEntityInput(iWeapon, "Kill");
|
||||
@ -1401,22 +1375,22 @@ void UpdateReplayInfo(int client, int style, float time, int track)
|
||||
|
||||
else
|
||||
{
|
||||
GivePlayerItem(client, gS_BotWeapon);
|
||||
GivePlayerItem(client, sWeapon);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(GetClientTeam(client) != gI_DefaultTeam)
|
||||
if(GetClientTeam(client) != gCV_DefaultTeam.IntValue)
|
||||
{
|
||||
if(gEV_Type == Engine_TF2)
|
||||
{
|
||||
ChangeClientTeam(client, gI_DefaultTeam);
|
||||
ChangeClientTeam(client, gCV_DefaultTeam.IntValue);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
CS_SwitchTeam(client, gI_DefaultTeam);
|
||||
CS_SwitchTeam(client, gCV_DefaultTeam.IntValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1475,7 +1449,7 @@ public void Shavit_OnFinish(int client, int style, float time, int jumps, int st
|
||||
return;
|
||||
}
|
||||
|
||||
if(!gB_Enabled || (gF_TimeLimit > 0.0 && time > gF_TimeLimit))
|
||||
if(!gCV_Enabled.BoolValue || (gCV_TimeLimit.FloatValue > 0.0 && time > gCV_TimeLimit.FloatValue))
|
||||
{
|
||||
ClearFrames(client);
|
||||
|
||||
@ -1494,8 +1468,7 @@ public void Shavit_OnFinish(int client, int style, float time, int jumps, int st
|
||||
|
||||
else
|
||||
{
|
||||
float wrtime = 0.0;
|
||||
Shavit_GetWRTime(style, wrtime, track);
|
||||
float wrtime = Shavit_GetWorldRecord(style, track);
|
||||
|
||||
if(wrtime != 0.0 && time > wrtime)
|
||||
{
|
||||
@ -1522,12 +1495,12 @@ public void Shavit_OnFinish(int client, int style, float time, int jumps, int st
|
||||
|
||||
if(ReplayEnabled(style))
|
||||
{
|
||||
if(gB_CentralBot && gA_CentralCache.iStyle == style && gA_CentralCache.iTrack == track)
|
||||
if(gCV_CentralBot.BoolValue && gA_CentralCache.iStyle == style && gA_CentralCache.iTrack == track)
|
||||
{
|
||||
StopCentralReplay(0);
|
||||
}
|
||||
|
||||
else if(!gB_CentralBot && gI_ReplayBotClient[style] != 0)
|
||||
else if(!gCV_CentralBot.BoolValue && gI_ReplayBotClient[style] != 0)
|
||||
{
|
||||
UpdateReplayInfo(gI_ReplayBotClient[style], style, time, track);
|
||||
|
||||
@ -1572,7 +1545,7 @@ void ApplyFlags(int &flags1, int flags2, int flag)
|
||||
// OnPlayerRunCmd instead of Shavit_OnUserCmdPre because bots are also used here.
|
||||
public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3])
|
||||
{
|
||||
if(!gB_Enabled)
|
||||
if(!gCV_Enabled.BoolValue)
|
||||
{
|
||||
return Plugin_Continue;
|
||||
}
|
||||
@ -1654,7 +1627,7 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
|
||||
gI_ReplayTick[style] = 0;
|
||||
gRS_ReplayStatus[style] = gA_CentralCache.iReplayStatus = Replay_End;
|
||||
|
||||
CreateTimer((gF_ReplayDelay / 2.0), Timer_EndReplay, style, TIMER_FLAG_NO_MAPCHANGE);
|
||||
CreateTimer((gCV_ReplayDelay.FloatValue / 2.0), Timer_EndReplay, style, TIMER_FLAG_NO_MAPCHANGE);
|
||||
|
||||
return Plugin_Changed;
|
||||
}
|
||||
@ -1673,17 +1646,17 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
|
||||
|
||||
buttons = gA_Frames[style][track].Get(gI_ReplayTick[style], 5);
|
||||
|
||||
if((gI_BotShooting & iBotShooting_Attack1) == 0)
|
||||
if((gCV_BotShooting.IntValue & iBotShooting_Attack1) == 0)
|
||||
{
|
||||
buttons &= ~IN_ATTACK;
|
||||
}
|
||||
|
||||
if((gI_BotShooting & iBotShooting_Attack2) == 0)
|
||||
if((gCV_BotShooting.IntValue & iBotShooting_Attack2) == 0)
|
||||
{
|
||||
buttons &= ~IN_ATTACK2;
|
||||
}
|
||||
|
||||
if(!gB_BotPlusUse)
|
||||
if(!gCV_BotPlusUse.BoolValue)
|
||||
{
|
||||
buttons &= ~IN_USE;
|
||||
}
|
||||
@ -1753,7 +1726,7 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
|
||||
|
||||
else if(ReplayEnabled(Shavit_GetBhopStyle(client)) && Shavit_GetTimerStatus(client) == Timer_Running)
|
||||
{
|
||||
if((gI_PlayerFrames[client] / gF_Tickrate) > gF_TimeLimit)
|
||||
if((gI_PlayerFrames[client] / gF_Tickrate) > gCV_TimeLimit.FloatValue)
|
||||
{
|
||||
Shavit_PrintToChat(client, "stopped recording: %d", gI_PlayerFrames[client]);
|
||||
// in case of bad timing
|
||||
@ -1812,7 +1785,7 @@ bool IsWallBetween(float pos1[3], float pos2[3], int bot)
|
||||
|
||||
public Action Timer_EndReplay(Handle Timer, any data)
|
||||
{
|
||||
if(gB_CentralBot && gB_ForciblyStopped)
|
||||
if(gCV_CentralBot.BoolValue && gB_ForciblyStopped)
|
||||
{
|
||||
gB_ForciblyStopped = false;
|
||||
|
||||
@ -1829,7 +1802,7 @@ public Action Timer_EndReplay(Handle Timer, any data)
|
||||
{
|
||||
gRS_ReplayStatus[data] = Replay_Start;
|
||||
|
||||
CreateTimer((gF_ReplayDelay / 2.0), Timer_StartReplay, data, TIMER_FLAG_NO_MAPCHANGE);
|
||||
CreateTimer((gCV_ReplayDelay.FloatValue / 2.0), Timer_StartReplay, data, TIMER_FLAG_NO_MAPCHANGE);
|
||||
}
|
||||
|
||||
else
|
||||
@ -1843,7 +1816,7 @@ public Action Timer_EndReplay(Handle Timer, any data)
|
||||
|
||||
public Action Timer_StartReplay(Handle Timer, any data)
|
||||
{
|
||||
if(gRS_ReplayStatus[data] == Replay_Running || (gB_CentralBot && gB_ForciblyStopped))
|
||||
if(gRS_ReplayStatus[data] == Replay_Running || (gCV_CentralBot.BoolValue && gB_ForciblyStopped))
|
||||
{
|
||||
return Plugin_Stop;
|
||||
}
|
||||
@ -1864,7 +1837,7 @@ bool ReplayEnabled(any style)
|
||||
|
||||
public void Player_Event(Event event, const char[] name, bool dontBroadcast)
|
||||
{
|
||||
if(!gB_Enabled)
|
||||
if(!gCV_Enabled.BoolValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -1900,7 +1873,7 @@ public Action DelayedUpdate(Handle Timer, any data)
|
||||
|
||||
public void BotEvents(Event event, const char[] name, bool dontBroadcast)
|
||||
{
|
||||
if(!gB_Enabled)
|
||||
if(!gCV_Enabled.BoolValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -1925,7 +1898,7 @@ public void BotEvents(Event event, const char[] name, bool dontBroadcast)
|
||||
|
||||
public Action Hook_SayText2(UserMsg msg_id, any msg, const int[] players, int playersNum, bool reliable, bool init)
|
||||
{
|
||||
if(!gB_HideNameChange || !gB_Enabled)
|
||||
if(!gB_HideNameChange || !gCV_Enabled.BoolValue)
|
||||
{
|
||||
return Plugin_Continue;
|
||||
}
|
||||
@ -1974,8 +1947,7 @@ void ClearFrames(int client)
|
||||
|
||||
public void Shavit_OnWRDeleted(int style, int id, int track)
|
||||
{
|
||||
float time = 0.0;
|
||||
Shavit_GetWRTime(style, time, track);
|
||||
float time = Shavit_GetWorldRecord(style, track);
|
||||
|
||||
if(gA_FrameCache[style][track].iFrameCount > 0 && GetReplayLength(style, track) - gF_Tickrate <= time) // -0.1 to fix rounding issues
|
||||
{
|
||||
@ -2132,7 +2104,7 @@ public int DeleteConfirmation_Callback(Menu menu, MenuAction action, int param1,
|
||||
|
||||
public Action Command_Replay(int client, int args)
|
||||
{
|
||||
if(!IsValidClient(client) || !gB_CentralBot || gA_CentralCache.iClient == -1)
|
||||
if(!IsValidClient(client) || !gCV_CentralBot.BoolValue || gA_CentralCache.iClient == -1)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
@ -2318,7 +2290,7 @@ public int MenuHandler_ReplaySubmenu(Menu menu, MenuAction action, int param1, i
|
||||
|
||||
UpdateReplayInfo(gA_CentralCache.iClient, style, time, gI_Track[param1]);
|
||||
|
||||
CreateTimer((gF_ReplayDelay / 2.0), Timer_StartReplay, style, TIMER_FLAG_NO_MAPCHANGE);
|
||||
CreateTimer((gCV_ReplayDelay.FloatValue / 2.0), Timer_StartReplay, style, TIMER_FLAG_NO_MAPCHANGE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2381,7 +2353,7 @@ int GetReplayStyle(int client)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(gB_CentralBot)
|
||||
if(gCV_CentralBot.BoolValue)
|
||||
{
|
||||
if(gA_CentralCache.iStyle == -1)
|
||||
{
|
||||
@ -2409,7 +2381,7 @@ int GetReplayTrack(int client)
|
||||
return -1;
|
||||
}
|
||||
|
||||
return (gB_CentralBot)? gA_CentralCache.iTrack:Track_Main;
|
||||
return (gCV_CentralBot.BoolValue)? gA_CentralCache.iTrack:Track_Main;
|
||||
}
|
||||
|
||||
int GetSpectatorTarget(int client)
|
||||
@ -2455,8 +2427,7 @@ float GetReplayLength(int style, int track)
|
||||
return gA_FrameCache[style][track].fTime;
|
||||
}
|
||||
|
||||
float fWRTime = 0.0;
|
||||
Shavit_GetWRTime(style, fWRTime, track);
|
||||
float fWRTime = Shavit_GetWorldRecord(style, track);
|
||||
|
||||
return fWRTime;
|
||||
}
|
||||
|
||||
@ -38,9 +38,6 @@ StringMap gSM_RankSounds = null;
|
||||
// cvars
|
||||
ConVar gCV_MinimumWorst = null;
|
||||
|
||||
// cached cvars
|
||||
int gI_MinimumWorst = 10;
|
||||
|
||||
public Plugin myinfo =
|
||||
{
|
||||
name = "[shavit] Sounds",
|
||||
@ -81,16 +78,9 @@ public void OnPluginStart()
|
||||
// cvars
|
||||
gCV_MinimumWorst = CreateConVar("shavit_sounds_minimumworst", "10", "Minimum amount of records to be saved for a \"worst\" sound to play.", 0, true, 1.0);
|
||||
|
||||
gCV_MinimumWorst.AddChangeHook(OnConVarChanged);
|
||||
|
||||
AutoExecConfig();
|
||||
}
|
||||
|
||||
public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] newValue)
|
||||
{
|
||||
gI_MinimumWorst = gCV_MinimumWorst.IntValue;
|
||||
}
|
||||
|
||||
public void OnLibraryAdded(const char[] name)
|
||||
{
|
||||
if(StrEqual(name, "shavit-hud"))
|
||||
@ -195,8 +185,7 @@ public void OnMapStart()
|
||||
|
||||
public void Shavit_OnFinish_Post(int client, int style, float time, int jumps, int strafes, float sync, int rank, int overwrite, int track)
|
||||
{
|
||||
float fOldTime = 0.0;
|
||||
Shavit_GetPlayerPB(client, style, fOldTime, track);
|
||||
float fOldTime = Shavit_GetClientPB(client, style, track);
|
||||
|
||||
char sSound[PLATFORM_MAX_PATH];
|
||||
bool bEveryone = false;
|
||||
@ -234,7 +223,7 @@ public void Shavit_OnFinish_Post(int client, int style, float time, int jumps, i
|
||||
|
||||
public void Shavit_OnWorstRecord(int client, int style, float time, int jumps, int strafes, float sync, int track)
|
||||
{
|
||||
if(gA_WorstSounds.Length != 0 && Shavit_GetRecordAmount(style, track) >= gI_MinimumWorst)
|
||||
if(gA_WorstSounds.Length != 0 && Shavit_GetRecordAmount(style, track) >= gCV_MinimumWorst.IntValue)
|
||||
{
|
||||
char sSound[PLATFORM_MAX_PATH];
|
||||
gA_WorstSounds.GetString(GetRandomInt(0, gA_WorstSounds.Length - 1), sSound, PLATFORM_MAX_PATH);
|
||||
|
||||
@ -59,10 +59,6 @@ bool gB_Late = false;
|
||||
ConVar gCV_MVPRankOnes = null;
|
||||
ConVar gCV_MVPRankOnes_Main = null;
|
||||
|
||||
// cached cvars
|
||||
int gI_MVPRankOnes = 2;
|
||||
bool gB_MVPRankOnes_Main = true;
|
||||
|
||||
// timer settings
|
||||
int gI_Styles = 0;
|
||||
stylestrings_t gS_StyleStrings[STYLE_LIMIT];
|
||||
@ -127,9 +123,6 @@ public void OnPluginStart()
|
||||
gCV_MVPRankOnes = CreateConVar("shavit_stats_mvprankones", "2", "Set the players' amount of MVPs to the amount of #1 times they have.\n0 - Disabled\n1 - Enabled, for all styles.\n2 - Enabled, for default style only.\n(CS:S/CS:GO only)", 0, true, 0.0, true, 2.0);
|
||||
gCV_MVPRankOnes_Main = CreateConVar("shavit_stats_mvprankones_maintrack", "1", "If set to 0, all tracks will be counted for the MVP stars.\nOtherwise, only the main track will be checked.\n\nRequires \"shavit_stats_mvprankones\" set to 1 or above.\n(CS:S/CS:GO only)", 0, true, 0.0, true, 1.0);
|
||||
|
||||
gCV_MVPRankOnes.AddChangeHook(OnConVarChanged);
|
||||
gCV_MVPRankOnes_Main.AddChangeHook(OnConVarChanged);
|
||||
|
||||
AutoExecConfig();
|
||||
|
||||
gB_Rankings = LibraryExists("shavit-rankings");
|
||||
@ -184,12 +177,6 @@ public void Shavit_OnChatConfigLoaded()
|
||||
Shavit_GetChatStrings(sMessageStyle, gS_ChatStrings.sStyle, sizeof(chatstrings_t::sStyle));
|
||||
}
|
||||
|
||||
public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] newValue)
|
||||
{
|
||||
gI_MVPRankOnes = gCV_MVPRankOnes.IntValue;
|
||||
gB_MVPRankOnes_Main = gCV_MVPRankOnes_Main.BoolValue;
|
||||
}
|
||||
|
||||
public void OnClientPutInServer(int client)
|
||||
{
|
||||
if(IsFakeClient(client))
|
||||
@ -273,7 +260,7 @@ void SQL_SetPrefix()
|
||||
|
||||
public void Player_Event(Event event, const char[] name, bool dontBroadcast)
|
||||
{
|
||||
if(gI_MVPRankOnes == 0)
|
||||
if(gCV_MVPRankOnes.IntValue == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -299,14 +286,14 @@ void UpdateWRs(int client)
|
||||
{
|
||||
char sQuery[256];
|
||||
|
||||
if(gI_MVPRankOnes == 2)
|
||||
if(gCV_MVPRankOnes.IntValue == 2)
|
||||
{
|
||||
FormatEx(sQuery, 256, "SELECT COUNT(*) FROM %splayertimes a JOIN (SELECT MIN(time) time FROM %splayertimes WHERE style = 0 %sGROUP by map) b ON a.time = b.time WHERE auth = '%s';", gS_MySQLPrefix, gS_MySQLPrefix, (gB_MVPRankOnes_Main)? "AND track = 0 ":"", sAuthID);
|
||||
FormatEx(sQuery, 256, "SELECT COUNT(*) FROM %splayertimes a JOIN (SELECT MIN(time) time FROM %splayertimes WHERE style = 0 %sGROUP by map) b ON a.time = b.time WHERE auth = '%s';", gS_MySQLPrefix, gS_MySQLPrefix, (gCV_MVPRankOnes_Main.BoolValue)? "AND track = 0 ":"", sAuthID);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
FormatEx(sQuery, 256, "SELECT COUNT(*) FROM %splayertimes a JOIN (SELECT MIN(time) time FROM %splayertimes %sGROUP by map) b ON a.time = b.time WHERE auth = '%s';", gS_MySQLPrefix, gS_MySQLPrefix, (gB_MVPRankOnes_Main)? "WHERE track = 0 ":"", sAuthID);
|
||||
FormatEx(sQuery, 256, "SELECT COUNT(*) FROM %splayertimes a JOIN (SELECT MIN(time) time FROM %splayertimes %sGROUP by map) b ON a.time = b.time WHERE auth = '%s';", gS_MySQLPrefix, gS_MySQLPrefix, (gCV_MVPRankOnes_Main.BoolValue)? "WHERE track = 0 ":"", sAuthID);
|
||||
}
|
||||
|
||||
gH_SQL.Query(SQL_GetWRs_Callback, sQuery, GetClientSerial(client));
|
||||
@ -331,7 +318,7 @@ public void SQL_GetWRs_Callback(Database db, DBResultSet results, const char[] e
|
||||
|
||||
int iWRs = results.FetchInt(0);
|
||||
|
||||
if(gI_MVPRankOnes > 0 && gEV_Type != Engine_TF2)
|
||||
if(gCV_MVPRankOnes.IntValue > 0 && gEV_Type != Engine_TF2)
|
||||
{
|
||||
CS_SetMVPCount(client, iWRs);
|
||||
}
|
||||
|
||||
@ -53,15 +53,6 @@ ConVar gCV_MinimumTimes = null;
|
||||
ConVar gCV_PlayerAmount = null;
|
||||
ConVar gCV_Style = null;
|
||||
|
||||
// cached cvars
|
||||
bool gB_Config = true;
|
||||
float gF_DefaultLimit = 60.0;
|
||||
bool gB_DynamicTimelimits = true;
|
||||
bool gB_ForceMapEnd = true;
|
||||
int gI_MinimumTimes = 5;
|
||||
int gI_PlayerAmount = 25;
|
||||
bool gB_Style = true;
|
||||
|
||||
// misc cache
|
||||
Handle gH_Timer = null;
|
||||
EngineVersion gEV_Type = Engine_Unknown;
|
||||
@ -117,13 +108,7 @@ public void OnPluginStart()
|
||||
gCV_PlayerAmount = CreateConVar("shavit_timelimit_playertime", "25", "Limited amount of times to grab from the database to calculate an average.\nREQUIRES \"shavit_timelimit_dynamic\" TO BE ENABLED!\nSet to 0 to have it \"unlimited\".", 0);
|
||||
gCV_Style = CreateConVar("shavit_timelimit_style", "1", "If set to 1, calculate an average only from times that the first (default: forwards) style was used to set.\nREQUIRES \"shavit_timelimit_dynamic\" TO BE ENABLED!", 0, true, 0.0, true, 1.0);
|
||||
|
||||
gCV_Config.AddChangeHook(OnConVarChanged);
|
||||
gCV_DefaultLimit.AddChangeHook(OnConVarChanged);
|
||||
gCV_DynamicTimelimits.AddChangeHook(OnConVarChanged);
|
||||
gCV_ForceMapEnd.AddChangeHook(OnConVarChanged);
|
||||
gCV_MinimumTimes.AddChangeHook(OnConVarChanged);
|
||||
gCV_PlayerAmount.AddChangeHook(OnConVarChanged);
|
||||
gCV_Style.AddChangeHook(OnConVarChanged);
|
||||
|
||||
AutoExecConfig();
|
||||
|
||||
@ -132,31 +117,20 @@ public void OnPluginStart()
|
||||
|
||||
public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] newValue)
|
||||
{
|
||||
gB_Config = gCV_Config.BoolValue;
|
||||
gF_DefaultLimit = gCV_DefaultLimit.FloatValue;
|
||||
gB_DynamicTimelimits = gCV_DynamicTimelimits.BoolValue;
|
||||
gB_ForceMapEnd = gCV_ForceMapEnd.BoolValue;
|
||||
gI_MinimumTimes = gCV_MinimumTimes.IntValue;
|
||||
gI_PlayerAmount = gCV_PlayerAmount.IntValue;
|
||||
gB_Style = gCV_Style.BoolValue;
|
||||
|
||||
if(convar == gCV_ForceMapEnd)
|
||||
if(view_as<bool>(StringToInt(newValue)) && gEV_Type != Engine_TF2)
|
||||
{
|
||||
if(gB_ForceMapEnd && gEV_Type != Engine_TF2)
|
||||
{
|
||||
gH_Timer = CreateTimer(1.0, Timer_PrintToChat, 0, TIMER_REPEAT);
|
||||
}
|
||||
gH_Timer = CreateTimer(1.0, Timer_PrintToChat, 0, TIMER_REPEAT);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
delete gH_Timer;
|
||||
}
|
||||
else
|
||||
{
|
||||
delete gH_Timer;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnConfigsExecuted()
|
||||
{
|
||||
if(gB_Config)
|
||||
if(gCV_Config.BoolValue)
|
||||
{
|
||||
if(mp_do_warmup_period != null)
|
||||
{
|
||||
@ -182,17 +156,17 @@ public void OnMapStart()
|
||||
return;
|
||||
}
|
||||
|
||||
if(gB_DynamicTimelimits)
|
||||
if(gCV_DynamicTimelimits.BoolValue)
|
||||
{
|
||||
StartCalculating();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
SetLimit(RoundToNearest(gF_DefaultLimit));
|
||||
SetLimit(RoundToNearest(gCV_DefaultLimit.FloatValue));
|
||||
}
|
||||
|
||||
if(gB_ForceMapEnd && gH_Timer == null && gEV_Type != Engine_TF2)
|
||||
if(gCV_ForceMapEnd.BoolValue && gH_Timer == null && gEV_Type != Engine_TF2)
|
||||
{
|
||||
gH_Timer = CreateTimer(1.0, Timer_PrintToChat, 0, TIMER_REPEAT);
|
||||
}
|
||||
@ -262,7 +236,7 @@ void StartCalculating()
|
||||
GetMapDisplayName(sMap, sMap, 160);
|
||||
|
||||
char sQuery[512];
|
||||
FormatEx(sQuery, 512, "SELECT COUNT(*), SUM(t.time) FROM (SELECT r.time, r.style FROM %splayertimes r WHERE r.map = '%s' AND r.track = 0 %sORDER BY r.time LIMIT %d) t;", gS_MySQLPrefix, sMap, (gB_Style)? "AND style = 0 ":"", gI_PlayerAmount);
|
||||
FormatEx(sQuery, 512, "SELECT COUNT(*), SUM(t.time) FROM (SELECT r.time, r.style FROM %splayertimes r WHERE r.map = '%s' AND r.track = 0 %sORDER BY r.time LIMIT %d) t;", gS_MySQLPrefix, sMap, (gCV_Style.BoolValue)? "AND style = 0 ":"", gCV_PlayerAmount.IntValue);
|
||||
|
||||
#if defined DEBUG
|
||||
PrintToServer("%s", sQuery);
|
||||
@ -284,7 +258,7 @@ public void SQL_GetMapTimes(Database db, DBResultSet results, const char[] error
|
||||
results.FetchRow();
|
||||
int iRows = results.FetchInt(0);
|
||||
|
||||
if(iRows >= gI_MinimumTimes)
|
||||
if(iRows >= gCV_MinimumTimes.IntValue)
|
||||
{
|
||||
float fTimeSum = results.FetchFloat(1);
|
||||
float fAverage = (fTimeSum / 60 / iRows);
|
||||
@ -331,7 +305,7 @@ public void SQL_GetMapTimes(Database db, DBResultSet results, const char[] error
|
||||
|
||||
else
|
||||
{
|
||||
SetLimit(RoundToNearest(gF_DefaultLimit));
|
||||
SetLimit(RoundToNearest(gCV_DefaultLimit.FloatValue));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -78,10 +78,6 @@ char gS_MySQLPrefix[32];
|
||||
ConVar gCV_RecordsLimit = null;
|
||||
ConVar gCV_RecentLimit = null;
|
||||
|
||||
// cached cvars
|
||||
int gI_RecordsLimit = 50;
|
||||
int gI_RecentLimit = 50;
|
||||
|
||||
// timer settings
|
||||
int gI_Styles = 0;
|
||||
stylestrings_t gS_StyleStrings[STYLE_LIMIT];
|
||||
@ -168,9 +164,6 @@ public void OnPluginStart()
|
||||
gCV_RecordsLimit = CreateConVar("shavit_wr_recordlimit", "50", "Limit of records shown in the WR menu.\nAdvised to not set above 1,000 because scrolling through so many pages is useless.\n(And can also cause the command to take long time to run)", 0, true, 1.0);
|
||||
gCV_RecentLimit = CreateConVar("shavit_wr_recentlimit", "50", "Limit of records shown in the RR menu.", 0, true, 1.0);
|
||||
|
||||
gCV_RecordsLimit.AddChangeHook(OnConVarChanged);
|
||||
gCV_RecentLimit.AddChangeHook(OnConVarChanged);
|
||||
|
||||
AutoExecConfig();
|
||||
|
||||
// admin menu
|
||||
@ -189,12 +182,6 @@ public void OnPluginStart()
|
||||
SQL_SetPrefix();
|
||||
}
|
||||
|
||||
public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] newValue)
|
||||
{
|
||||
gI_RecordsLimit = gCV_RecordsLimit.IntValue;
|
||||
gI_RecentLimit = gCV_RecentLimit.IntValue;
|
||||
}
|
||||
|
||||
public void OnAdminMenuCreated(Handle topmenu)
|
||||
{
|
||||
if(gH_AdminMenu == null || (topmenu == gH_AdminMenu && gH_TimerCommands != INVALID_TOPMENUOBJECT))
|
||||
@ -1497,7 +1484,7 @@ public void SQL_WR_Callback(Database db, DBResultSet results, const char[] error
|
||||
|
||||
while(results.FetchRow())
|
||||
{
|
||||
if(++iCount <= gI_RecordsLimit)
|
||||
if(++iCount <= gCV_RecordsLimit.IntValue)
|
||||
{
|
||||
// 0 - record id, for statistic purposes.
|
||||
int id = results.FetchInt(0);
|
||||
@ -1644,7 +1631,7 @@ public void SQL_RR_Callback(Database db, DBResultSet results, const char[] error
|
||||
}
|
||||
|
||||
Menu menu = new Menu(RRMenu_Handler);
|
||||
menu.SetTitle("%T:", "RecentRecords", client, gI_RecentLimit);
|
||||
menu.SetTitle("%T:", "RecentRecords", client, gCV_RecentLimit.IntValue);
|
||||
|
||||
while(results.FetchRow())
|
||||
{
|
||||
|
||||
@ -135,15 +135,6 @@ ConVar gCV_Height = null;
|
||||
ConVar gCV_Offset = null;
|
||||
ConVar gCV_EnforceTracks = null;
|
||||
|
||||
// cached cvars
|
||||
float gF_Interval = 1.0;
|
||||
bool gB_TeleportToStart = true;
|
||||
bool gB_TeleportToEnd = true;
|
||||
bool gB_UseCustomSprite = true;
|
||||
float gF_Height = 128.0;
|
||||
float gF_Offset = 0.5;
|
||||
bool gB_EnforceTracks = true;
|
||||
|
||||
// handles
|
||||
Handle gH_DrawEverything = null;
|
||||
|
||||
@ -247,12 +238,8 @@ public void OnPluginStart()
|
||||
gCV_EnforceTracks = CreateConVar("shavit_zones_enforcetracks", "1", "Enforce zone tracks upon entry?\n0 - allow every zone except for start/end to affect users on every zone.\n1- require the user's track to match the zone's track.", 0, true, 0.0, true, 1.0);
|
||||
|
||||
gCV_Interval.AddChangeHook(OnConVarChanged);
|
||||
gCV_TeleportToStart.AddChangeHook(OnConVarChanged);
|
||||
gCV_TeleportToEnd.AddChangeHook(OnConVarChanged);
|
||||
gCV_UseCustomSprite.AddChangeHook(OnConVarChanged);
|
||||
gCV_Height.AddChangeHook(OnConVarChanged);
|
||||
gCV_Offset.AddChangeHook(OnConVarChanged);
|
||||
gCV_EnforceTracks.AddChangeHook(OnConVarChanged);
|
||||
|
||||
AutoExecConfig();
|
||||
|
||||
@ -292,18 +279,10 @@ public void OnPluginStart()
|
||||
|
||||
public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] newValue)
|
||||
{
|
||||
gF_Interval = gCV_Interval.FloatValue;
|
||||
gB_TeleportToStart = gCV_TeleportToStart.BoolValue;
|
||||
gB_UseCustomSprite = gCV_UseCustomSprite.BoolValue;
|
||||
gB_TeleportToEnd = gCV_TeleportToEnd.BoolValue;
|
||||
gF_Height = gCV_Height.FloatValue;
|
||||
gF_Offset = gCV_Offset.FloatValue;
|
||||
gB_EnforceTracks = gCV_EnforceTracks.BoolValue;
|
||||
|
||||
if(convar == gCV_Interval)
|
||||
{
|
||||
delete gH_DrawEverything;
|
||||
gH_DrawEverything = CreateTimer(gF_Interval, Timer_DrawEverything, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
|
||||
gH_DrawEverything = CreateTimer(gCV_Interval.FloatValue, Timer_DrawEverything, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
|
||||
}
|
||||
|
||||
else if(convar == gCV_Offset && gI_MapZones > 0)
|
||||
@ -322,7 +301,7 @@ public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] n
|
||||
gV_MapZones_Visual[i][7][1] = gV_MapZones[i][1][1];
|
||||
gV_MapZones_Visual[i][7][2] = gV_MapZones[i][1][2];
|
||||
|
||||
CreateZonePoints(gV_MapZones_Visual[i], gF_Offset);
|
||||
CreateZonePoints(gV_MapZones_Visual[i], gCV_Offset.FloatValue);
|
||||
}
|
||||
}
|
||||
|
||||
@ -578,7 +557,7 @@ void LoadZoneSettings()
|
||||
SetFailState("Cannot open \"configs/shavit-zones.cfg\". Make sure this file exists and that the server has read permissions to it.");
|
||||
}
|
||||
|
||||
if(gB_UseCustomSprite)
|
||||
if(gCV_UseCustomSprite.BoolValue)
|
||||
{
|
||||
gI_BeamSprite = PrecacheModel(gS_BeamSprite, true);
|
||||
gI_HaloSprite = 0;
|
||||
@ -632,7 +611,7 @@ public void OnMapStart()
|
||||
// start drawing mapzones here
|
||||
if(gH_DrawEverything == null)
|
||||
{
|
||||
gH_DrawEverything = CreateTimer(gF_Interval, Timer_DrawEverything, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
|
||||
gH_DrawEverything = CreateTimer(gCV_Interval.FloatValue, Timer_DrawEverything, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
|
||||
}
|
||||
|
||||
if(gB_Late)
|
||||
@ -911,7 +890,7 @@ public void SQL_RefreshZones_Callback(Database db, DBResultSet results, const ch
|
||||
gV_MapZones[gI_MapZones][1][1] = gV_MapZones_Visual[gI_MapZones][7][1] = results.FetchFloat(5);
|
||||
gV_MapZones[gI_MapZones][1][2] = gV_MapZones_Visual[gI_MapZones][7][2] = results.FetchFloat(6);
|
||||
|
||||
CreateZonePoints(gV_MapZones_Visual[gI_MapZones], gF_Offset);
|
||||
CreateZonePoints(gV_MapZones_Visual[gI_MapZones], gCV_Offset.FloatValue);
|
||||
|
||||
gV_ZoneCenter[gI_MapZones][0] = (gV_MapZones[gI_MapZones][0][0] + gV_MapZones[gI_MapZones][1][0]) / 2.0;
|
||||
gV_ZoneCenter[gI_MapZones][1] = (gV_MapZones[gI_MapZones][0][1] + gV_MapZones[gI_MapZones][1][1]) / 2.0;
|
||||
@ -1708,7 +1687,7 @@ public Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float
|
||||
|
||||
else if(gI_MapStep[client] == 2)
|
||||
{
|
||||
origin[2] += gF_Height;
|
||||
origin[2] += gCV_Height.FloatValue;
|
||||
gV_Point2[client] = origin;
|
||||
|
||||
gI_MapStep[client]++;
|
||||
@ -1726,7 +1705,7 @@ public Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float
|
||||
}
|
||||
}
|
||||
|
||||
if(InsideZone(client, Zone_Slide, (gB_EnforceTracks)? track:-1) && GetEntPropEnt(client, Prop_Send, "m_hGroundEntity") == -1)
|
||||
if(InsideZone(client, Zone_Slide, (gCV_EnforceTracks.BoolValue)? track:-1) && GetEntPropEnt(client, Prop_Send, "m_hGroundEntity") == -1)
|
||||
{
|
||||
// trace down, see if there's 8 distance or less to ground
|
||||
float fPosition[3];
|
||||
@ -2070,7 +2049,7 @@ public Action Timer_DrawEverything(Handle Timer)
|
||||
{
|
||||
DrawZone(gV_MapZones_Visual[i],
|
||||
GetZoneColors(type, track),
|
||||
RoundToCeil(float(gI_MapZones) / iMaxZonesPerFrame) * gF_Interval,
|
||||
RoundToCeil(float(gI_MapZones) / iMaxZonesPerFrame) * gCV_Interval.FloatValue,
|
||||
gA_ZoneSettings[type][track].fWidth,
|
||||
gA_ZoneSettings[type][track].bFlatZone,
|
||||
gV_ZoneCenter[i]);
|
||||
@ -2132,7 +2111,7 @@ public Action Timer_Draw(Handle Timer, any data)
|
||||
|
||||
if(gI_MapStep[client] == 1 || gV_Point2[client][0] == 0.0)
|
||||
{
|
||||
origin[2] = (vPlayerOrigin[2] + gF_Height);
|
||||
origin[2] = (vPlayerOrigin[2] + gCV_Height.FloatValue);
|
||||
}
|
||||
|
||||
else
|
||||
@ -2145,7 +2124,7 @@ public Action Timer_Draw(Handle Timer, any data)
|
||||
float points[8][3];
|
||||
points[0] = gV_Point1[client];
|
||||
points[7] = origin;
|
||||
CreateZonePoints(points, gF_Offset);
|
||||
CreateZonePoints(points, gCV_Offset.FloatValue);
|
||||
|
||||
// This is here to make the zone setup grid snapping be 1:1 to how it looks when done with the setup.
|
||||
origin = points[7];
|
||||
@ -2164,7 +2143,7 @@ public Action Timer_Draw(Handle Timer, any data)
|
||||
|
||||
if(gI_MapStep[client] != 3 && !EmptyVector(origin))
|
||||
{
|
||||
origin[2] -= gF_Height;
|
||||
origin[2] -= gCV_Height.FloatValue;
|
||||
|
||||
TE_SetupBeamPoints(vPlayerOrigin, origin, gI_BeamSprite, gI_HaloSprite, 0, 0, 0.1, 1.0, 1.0, 0, 0.0, {255, 255, 255, 75}, 0);
|
||||
TE_SendToAll(0.0);
|
||||
@ -2434,7 +2413,7 @@ public void SQL_AlterTable2_Callback(Database db, DBResultSet results, const cha
|
||||
|
||||
public void Shavit_OnRestart(int client, int track)
|
||||
{
|
||||
if(gB_TeleportToStart)
|
||||
if(gCV_TeleportToStart.BoolValue)
|
||||
{
|
||||
// custom spawns
|
||||
if(!EmptyVector(gF_CustomSpawn[track]))
|
||||
@ -2480,7 +2459,7 @@ public void Shavit_OnRestart(int client, int track)
|
||||
|
||||
public void Shavit_OnEnd(int client, int track)
|
||||
{
|
||||
if(gB_TeleportToEnd)
|
||||
if(gCV_TeleportToEnd.BoolValue)
|
||||
{
|
||||
int index = GetZoneIndex(Zone_End, track);
|
||||
|
||||
@ -2649,7 +2628,7 @@ public void CreateZoneEntities()
|
||||
public void StartTouchPost(int entity, int other)
|
||||
{
|
||||
if(other < 1 || other > MaxClients || gI_EntityZone[entity] == -1 || !gA_ZoneCache[gI_EntityZone[entity]].bZoneInitialized || IsFakeClient(other) ||
|
||||
(gB_EnforceTracks && gA_ZoneCache[gI_EntityZone[entity]].iZoneType > Zone_End && gA_ZoneCache[gI_EntityZone[entity]].iZoneTrack != Shavit_GetClientTrack(other)))
|
||||
(gCV_EnforceTracks.BoolValue && gA_ZoneCache[gI_EntityZone[entity]].iZoneType > Zone_End && gA_ZoneCache[gI_EntityZone[entity]].iZoneTrack != Shavit_GetClientTrack(other)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -2731,7 +2710,7 @@ public void EndTouchPost(int entity, int other)
|
||||
public void TouchPost(int entity, int other)
|
||||
{
|
||||
if(other < 1 || other > MaxClients || gI_EntityZone[entity] == -1 || IsFakeClient(other) ||
|
||||
(gB_EnforceTracks && gA_ZoneCache[gI_EntityZone[entity]].iZoneType > Zone_End && gA_ZoneCache[gI_EntityZone[entity]].iZoneTrack != Shavit_GetClientTrack(other)))
|
||||
(gCV_EnforceTracks.BoolValue && gA_ZoneCache[gI_EntityZone[entity]].iZoneType > Zone_End && gA_ZoneCache[gI_EntityZone[entity]].iZoneTrack != Shavit_GetClientTrack(other)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user