Merge remote-tracking branch 'origin/master' into rankings

This commit is contained in:
shavitush 2017-08-22 05:35:22 +03:00
commit 19231a8e17
5 changed files with 181 additions and 21 deletions

View File

@ -15,52 +15,71 @@
"Start"
{
"visible" "1"
"red" "67"
"green" "210"
"blue" "230"
"alpha" "255"
"width" "0.5"
}
"End"
{
"visible" "1"
"red" "165"
"green" "19"
"blue" "194"
"alpha" "255"
"width" "0.5"
}
"Glitch_Respawn"
{
"visible" "0"
"red" "255"
"green" "200"
"blue" "0"
"alpha" "255"
"width" "0.5"
}
"Glitch_Stop"
{
"visible" "0"
"red" "255"
"green" "200"
"blue" "0"
"alpha" "255"
"width" "0.5"
}
"Glitch_Slay"
{
"visible" "0"
"red" "255"
"green" "200"
"blue" "0"
"alpha" "255"
"width" "0.5"
}
"Freestyle"
{
"visible" "1"
"red" "25"
"green" "25"
"blue" "255"
"alpha" "195"
"width" "0.5"
}
@ -68,9 +87,11 @@
"Nolimit"
{
"visible" "1"
"red" "247"
"green" "3"
"blue" "255"
"alpha" "50"
"width" "0.5"
}
@ -78,9 +99,11 @@
"Teleport"
{
"visible" "0"
"red" "255"
"green" "200"
"blue" "0"
"alpha" "255"
"width" "4.0"
}
@ -94,9 +117,11 @@
"Easybhop"
{
"visible" "1"
"red" "57"
"green" "196"
"blue" "92"
"alpha" "175"
"width" "2.5"
}

View File

@ -19,9 +19,9 @@
{
"GetPlayerMaxSpeed"
{
"windows" "497"
"linux" "498"
"mac" "498"
"windows" "498"
"linux" "499"
"mac" "499"
}
}
}

View File

@ -2096,7 +2096,17 @@ public Action Shotgun_Shot(const char[] te_name, const int[] Players, int numCli
TE_WriteVector("m_vecOrigin", temp);
TE_WriteFloat("m_vecAngles[0]", TE_ReadFloat("m_vecAngles[0]"));
TE_WriteFloat("m_vecAngles[1]", TE_ReadFloat("m_vecAngles[1]"));
TE_WriteNum("m_iWeaponID", TE_ReadNum("m_iWeaponID"));
if(gEV_Type == Engine_CSS)
{
TE_WriteNum("m_iWeaponID", TE_ReadNum("m_iWeaponID"));
}
else
{
TE_WriteNum("m_weapon", TE_ReadNum("m_weapon"));
}
TE_WriteNum("m_iMode", TE_ReadNum("m_iMode"));
TE_WriteNum("m_iSeed", TE_ReadNum("m_iSeed"));
TE_WriteNum("m_iPlayer", (client - 1));

View File

@ -21,6 +21,7 @@
// original idea from ckSurf.
#include <sourcemod>
#include <cstrike>
#undef REQUIRE_PLUGIN
#include <shavit>
@ -35,18 +36,27 @@
Database gH_SQL = null;
// base cvars
ConVar gCV_TimeLimit = null;
ConVar gCV_RoundTime = null;
ConVar gCV_RestartGame = null;
ConVar mp_do_warmup_period = null;
ConVar mp_freezetime = null;
ConVar mp_ignore_round_win_conditions = null;
ConVar mp_timelimit = null;
ConVar mp_roundtime = null;
ConVar mp_restartgame = null;
// cvars
ConVar gCV_Config = null;
ConVar gCV_DefaultLimit = null;
ConVar gCV_DynamicTimelimits = null;
ConVar gCV_ForceMapEnd = null;
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;
@ -73,18 +83,29 @@ public void OnAllPluginsLoaded()
public void OnPluginStart()
{
gCV_RestartGame = FindConVar("mp_restartgame");
gCV_TimeLimit = FindConVar("mp_timelimit");
LoadTranslations("shavit-common.phrases");
gCV_RoundTime = FindConVar("mp_roundtime");
gCV_RoundTime.SetBounds(ConVarBound_Upper, false);
mp_do_warmup_period = FindConVar("mp_do_warmup_period");
mp_freezetime = FindConVar("mp_freezetime");
mp_ignore_round_win_conditions = FindConVar("mp_ignore_round_win_conditions");
mp_restartgame = FindConVar("mp_restartgame");
mp_timelimit = FindConVar("mp_timelimit");
mp_roundtime = FindConVar("mp_roundtime");
mp_roundtime.SetBounds(ConVarBound_Upper, false);
gCV_Config = CreateConVar("shavit_timelimit_config", "1", "Enables the following game settings:\n\"mp_do_warmup_period\" \"0\"\n\"mp_freezetime\" \"0\"\n\"mp_ignore_round_win_conditions\" \"1\"", 0, true, 0.0, true, 1.0);
gCV_DefaultLimit = CreateConVar("shavit_timelimit_default", "60.0", "Default timelimit to use in case there isn't an average.", 0, true, 10.0);
gCV_MinimumTimes = CreateConVar("shavit_timelimit_minimumtimes", "5", "Minimum amount of times required to calculate an average.", 0, true, 5.0);
gCV_PlayerAmount = CreateConVar("shavit_timelimit_playertime", "25", "Limited amount of times to grab from the database to calculate an average.\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.", 0, true, 0.0, true, 1.0);
gCV_DynamicTimelimits = CreateConVar("shavit_timelimit_dynamic", "1", "Use dynamic timelimits.\n0 - Disabled\n1 - Enabled", 0, true, 0.0, true, 1.0);
gCV_ForceMapEnd = CreateConVar("shavit_timelimit_forcemapend", "1", "Force the map to end after the timelimit.\n0 - Disabled\n1 - Enabled", 0, true, 0.0, true, 1.0);
gCV_MinimumTimes = CreateConVar("shavit_timelimit_minimumtimes", "5", "Minimum amount of times required to calculate an average.\nREQUIRES \"shavit_timelimit_dynamic\" TO BE ENABLED!", 0, true, 5.0);
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);
@ -98,12 +119,36 @@ 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;
}
public void OnConfigsExecuted()
{
if(gB_Config)
{
if(mp_do_warmup_period != null)
{
mp_do_warmup_period.BoolValue = false;
}
if(mp_freezetime != null)
{
mp_freezetime.IntValue = 0;
}
if(mp_ignore_round_win_conditions != null)
{
mp_ignore_round_win_conditions.BoolValue = true;
}
}
}
public Action CheckForSQLInfo(Handle Timer)
{
return SetSQLInfo();
@ -111,7 +156,20 @@ public Action CheckForSQLInfo(Handle Timer)
public void OnMapStart()
{
StartCalculating();
if(gB_DynamicTimelimits)
{
StartCalculating();
}
else
{
SetLimit(RoundToNearest(gF_DefaultLimit));
}
if(gB_ForceMapEnd)
{
CreateTimer(1.0, Timer_PrintToChat, 0, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
}
}
Action SetSQLInfo()
@ -142,7 +200,7 @@ void SQL_SetPrefix()
{
SetFailState("Cannot open \"configs/shavit-prefix.txt\". Make sure this file exists and that the server has read permissions to it.");
}
char[] sLine = new char[PLATFORM_MAX_PATH*2];
while(fFile.ReadLine(sLine, PLATFORM_MAX_PATH*2))
@ -168,7 +226,7 @@ void StartCalculating()
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);
#if defined DEBUG
PrintToServer(sQuery);
PrintToServer("%s", sQuery);
#endif
gH_SQL.Query(SQL_GetMapTimes, sQuery, 0, DBPrio_High);
@ -240,9 +298,65 @@ public void SQL_GetMapTimes(Database db, DBResultSet results, const char[] error
void SetLimit(int time)
{
gCV_TimeLimit.IntValue = time;
gCV_RoundTime.IntValue = time;
gCV_RestartGame.IntValue = 1;
mp_timelimit.IntValue = time;
mp_roundtime.IntValue = time;
mp_restartgame.IntValue = 1;
}
public Action Timer_PrintToChat(Handle Timer)
{
int timelimit = 0;
if(!GetMapTimeLimit(timelimit) || timelimit == 0)
{
return Plugin_Continue;
}
int timeleft = 0;
GetMapTimeLeft(timeleft);
switch(timeleft)
{
case 3600: Shavit_PrintToChatAll("%T", "Minutes", LANG_SERVER, "60");
case 1800: Shavit_PrintToChatAll("%T", "Minutes", LANG_SERVER, "30");
case 1200: Shavit_PrintToChatAll("%T", "Minutes", LANG_SERVER, "20");
case 600: Shavit_PrintToChatAll("%T", "Minutes", LANG_SERVER, "10");
case 300: Shavit_PrintToChatAll("%T", "Minutes", LANG_SERVER, "5");
case 120: Shavit_PrintToChatAll("%T", "Minutes", LANG_SERVER, "2");
case 60: Shavit_PrintToChatAll("%T", "Seconds", LANG_SERVER, "60");
case 30: Shavit_PrintToChatAll("%T", "Seconds", LANG_SERVER, "30");
case 15: Shavit_PrintToChatAll("%T", "Seconds", LANG_SERVER, "15");
case -1:
{
Shavit_StopChatSound();
Shavit_PrintToChatAll("3..");
}
case -2:
{
Shavit_StopChatSound();
Shavit_PrintToChatAll("2..");
}
case -3:
{
Shavit_StopChatSound();
Shavit_PrintToChatAll("1..");
}
}
if(timeleft < -3)
{
CS_TerminateRound(0.0, CSRoundEnd_Draw, true);
}
return Plugin_Continue;
}
public Action CS_OnTerminateRound(float &fDelay, CSRoundEndReason &iReason)
{
return Plugin_Continue;
}
public void Shavit_OnDatabaseLoaded(Database db)

View File

@ -31,4 +31,15 @@
"#format" "{1:s}"
"en" "Usage: {1}"
}
}
// ---------- Timelimit ---------- //
"Minutes"
{
"#format" "{1:s}"
"en" "{1} minutes remaining."
}
"Seconds"
{
"#format" "{1:s}"
"en" "{1} seconds remaining."
}
}