Merge pull request #669 from shavitush/very_good_yes

very good, yes... (2.3.0)
This commit is contained in:
shavit 2018-09-14 17:54:04 +03:00 committed by GitHub
commit c774f41ac8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 486 additions and 114 deletions

View File

@ -4,6 +4,9 @@
// "message" - a prefix to the message itself. Default: "" // "message" - a prefix to the message itself. Default: ""
// "display" - display text in the !chatranks menu. "<n>" for a new line. Filling this is required. // "display" - display text in the !chatranks menu. "<n>" for a new line. Filling this is required.
// "free" - is this title available for everyone to use? Default: "0" // "free" - is this title available for everyone to use? Default: "0"
// "easteregg" - is this title an easter egg? Set to 1 to hide it from the !ranks menu. Default: "0"
// "flag" - set to an admin flag to require privileges for this title. Can use an override instead of a flag.
// Combine with "free" "1" to instantly give access to privileged users. Default: ""
// //
// Global variables: // Global variables:
// {default} - default color // {default} - default color

View File

@ -23,9 +23,10 @@
#endif #endif
#define _shavit_included #define _shavit_included
#define SHAVIT_VERSION "2.2.0" #define SHAVIT_VERSION "2.3.0"
#define STYLE_LIMIT 256 #define STYLE_LIMIT 256
#define MAX_ZONES 64 #define MAX_ZONES 64
#define MAX_NAME_LENGTH_SQL 32
// HUD // HUD
#define HUD_NONE (0) #define HUD_NONE (0)

View File

@ -34,6 +34,7 @@
#define MAXLENGTH_NAME 192 #define MAXLENGTH_NAME 192
#define MAXLENGTH_TEXT 192 #define MAXLENGTH_TEXT 192
#define MAXLENGTH_MESSAGE 255 #define MAXLENGTH_MESSAGE 255
#define MAXLENGTH_DISPLAY 192
#define MAXLENGTH_CMESSAGE 16 #define MAXLENGTH_CMESSAGE 16
#define MAXLENGTH_BUFFER 255 #define MAXLENGTH_BUFFER 255
@ -43,9 +44,11 @@ enum ChatRanksCache
Float:fCRFrom, Float:fCRFrom,
Float:fCRTo, Float:fCRTo,
bool:bCRFree, bool:bCRFree,
bool:bCREasterEgg,
String:sCRAdminFlag[32],
String:sCRName[MAXLENGTH_NAME], String:sCRName[MAXLENGTH_NAME],
String:sCRMessage[MAXLENGTH_MESSAGE], String:sCRMessage[MAXLENGTH_MESSAGE],
String:sCRDisplay[192], String:sCRDisplay[MAXLENGTH_DISPLAY],
CRCACHE_SIZE CRCACHE_SIZE
} }
@ -135,6 +138,7 @@ public void OnPluginStart()
RegConsoleCmd("sm_ccmessage", Command_CCMessage, "Toggles/sets a custom chat message color. Usage: sm_ccmessage <color> or sm_ccmessage \"off\" to disable."); RegConsoleCmd("sm_ccmessage", Command_CCMessage, "Toggles/sets a custom chat message color. Usage: sm_ccmessage <color> or sm_ccmessage \"off\" to disable.");
RegConsoleCmd("sm_chatrank", Command_ChatRanks, "View a menu with the chat ranks available to you."); RegConsoleCmd("sm_chatrank", Command_ChatRanks, "View a menu with the chat ranks available to you.");
RegConsoleCmd("sm_chatranks", Command_ChatRanks, "View a menu with the chat ranks available to you."); RegConsoleCmd("sm_chatranks", Command_ChatRanks, "View a menu with the chat ranks available to you.");
RegConsoleCmd("sm_ranks", Command_Ranks, "View a menu with all the obtainable chat ranks.");
RegAdminCmd("sm_cclist", Command_CCList, ADMFLAG_CHAT, "Print the custom chat setting of all online players."); RegAdminCmd("sm_cclist", Command_CCList, ADMFLAG_CHAT, "Print the custom chat setting of all online players.");
RegAdminCmd("sm_reloadchatranks", Command_ReloadChatRanks, ADMFLAG_ROOT, "Reloads the chatranks config file."); RegAdminCmd("sm_reloadchatranks", Command_ReloadChatRanks, ADMFLAG_ROOT, "Reloads the chatranks config file.");
@ -235,10 +239,12 @@ bool LoadChatConfig()
} }
aChatTitle[bCRFree] = view_as<bool>(kv.GetNum("free", false)); aChatTitle[bCRFree] = view_as<bool>(kv.GetNum("free", false));
aChatTitle[bCREasterEgg] = view_as<bool>(kv.GetNum("easteregg", false));
kv.GetString("name", aChatTitle[sCRName], MAXLENGTH_NAME, "{name}"); kv.GetString("name", aChatTitle[sCRName], MAXLENGTH_NAME, "{name}");
kv.GetString("message", aChatTitle[sCRMessage], MAXLENGTH_MESSAGE, ""); kv.GetString("message", aChatTitle[sCRMessage], MAXLENGTH_MESSAGE, "");
kv.GetString("display", aChatTitle[sCRDisplay], 192, ""); kv.GetString("display", aChatTitle[sCRDisplay], MAXLENGTH_DISPLAY, "");
kv.GetString("flag", aChatTitle[sCRAdminFlag], 32, "");
if(strlen(aChatTitle[sCRDisplay]) > 0) if(strlen(aChatTitle[sCRDisplay]) > 0)
{ {
@ -512,8 +518,6 @@ void Frame_SendText(DataPack pack)
} }
EndMessage(); EndMessage();
return;
} }
public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] newValue) public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] newValue)
@ -782,13 +786,13 @@ Action ShowChatRanksMenu(int client, int item)
Menu menu = new Menu(MenuHandler_ChatRanks); Menu menu = new Menu(MenuHandler_ChatRanks);
menu.SetTitle("%T\n ", "SelectChatRank", client); menu.SetTitle("%T\n ", "SelectChatRank", client);
char[] sDisplay = new char[128]; char[] sDisplay = new char[MAXLENGTH_DISPLAY];
FormatEx(sDisplay, 128, "%T\n ", "AutoAssign", client); FormatEx(sDisplay, MAXLENGTH_DISPLAY, "%T\n ", "AutoAssign", client);
menu.AddItem("-2", sDisplay, (gI_ChatSelection[client] == -2)? ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT); 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(gI_CustomChat > 0 && (CheckCommandAccess(client, "shavit_chat", ADMFLAG_CHAT) || gI_CustomChat == 2))
{ {
FormatEx(sDisplay, 128, "%T\n ", "CustomChat", client); FormatEx(sDisplay, MAXLENGTH_DISPLAY, "%T\n ", "CustomChat", client);
menu.AddItem("-1", sDisplay, (gI_ChatSelection[client] == -1)? ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT); menu.AddItem("-1", sDisplay, (gI_ChatSelection[client] == -1)? ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
} }
@ -804,14 +808,15 @@ Action ShowChatRanksMenu(int client, int item)
any[] aCache = new any[CRCACHE_SIZE]; any[] aCache = new any[CRCACHE_SIZE];
gA_ChatRanks.GetArray(i, aCache, view_as<int>(CRCACHE_SIZE)); gA_ChatRanks.GetArray(i, aCache, view_as<int>(CRCACHE_SIZE));
strcopy(sDisplay, 192, aCache[sCRDisplay]); char[] sMenuDisplay = new char[MAXLENGTH_DISPLAY];
ReplaceString(sDisplay, 192, "<n>", "\n"); strcopy(sMenuDisplay, MAXLENGTH_DISPLAY, aCache[sCRDisplay]);
StrCat(sDisplay, 192, "\n "); // to add spacing between each entry ReplaceString(sMenuDisplay, MAXLENGTH_DISPLAY, "<n>", "\n");
StrCat(sMenuDisplay, MAXLENGTH_DISPLAY, "\n "); // to add spacing between each entry
char[] sInfo = new char[8]; char[] sInfo = new char[8];
IntToString(i, sInfo, 8); IntToString(i, sInfo, 8);
menu.AddItem(sInfo, sDisplay, (gI_ChatSelection[client] == i)? ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT); menu.AddItem(sInfo, sMenuDisplay, (gI_ChatSelection[client] == i)? ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
} }
menu.ExitButton = true; menu.ExitButton = true;
@ -842,6 +847,240 @@ public int MenuHandler_ChatRanks(Menu menu, MenuAction action, int param1, int p
} }
} }
public Action Command_Ranks(int client, int args)
{
if(client == 0)
{
return Plugin_Handled;
}
return ShowRanksMenu(client, 0);
}
Action ShowRanksMenu(int client, int item)
{
Menu menu = new Menu(MenuHandler_Ranks);
menu.SetTitle("%T\n ", "ChatRanksMenu", client);
int iLength = gA_ChatRanks.Length;
for(int i = 0; i < iLength; i++)
{
any[] aCache = new any[CRCACHE_SIZE];
gA_ChatRanks.GetArray(i, aCache, view_as<int>(CRCACHE_SIZE));
char[] sFlag = new char[32];
strcopy(sFlag, 32, aCache[sCRAdminFlag]);
bool bFlagAccess = false;
int iSize = strlen(sFlag);
if(iSize == 0)
{
bFlagAccess = true;
}
else if(iSize == 1)
{
AdminFlag afFlag = view_as<AdminFlag>(0);
if(FindFlagByChar(sFlag[0], afFlag))
{
bFlagAccess = GetAdminFlag(GetUserAdmin(client), afFlag);
}
}
else
{
bFlagAccess = CheckCommandAccess(client, sFlag, 0, true);
}
if(aCache[bCREasterEgg] || !bFlagAccess)
{
continue;
}
char[] sDisplay = new char[MAXLENGTH_DISPLAY];
strcopy(sDisplay, MAXLENGTH_DISPLAY, aCache[sCRDisplay]);
ReplaceString(sDisplay, MAXLENGTH_DISPLAY, "<n>", "\n");
char[][] sExplodedString = new char[2][32];
ExplodeString(sDisplay, "\n", sExplodedString, 2, 64);
FormatEx(sDisplay, MAXLENGTH_DISPLAY, "%s\n ", sExplodedString[0]);
char[] sRequirements = new char[64];
if(!aCache[bCRFree])
{
if(aCache[fCRFrom] == 0)
{
FormatEx(sRequirements, 64, "%T", "ChatRanksMenu_Unranked", client);
}
else
{
// this is really ugly
bool bRanged = (aCache[fCRFrom] != aCache[fCRTo] && aCache[fCRTo] != 2147483648.0);
if(aCache[iCRRangeType] == Rank_Flat)
{
if(bRanged)
{
FormatEx(sRequirements, 64, "%T", "ChatRanksMenu_Flat_Ranged", client, RoundToZero(aCache[fCRFrom]), RoundToZero(aCache[fCRTo]));
}
else
{
FormatEx(sRequirements, 64, "%T", "ChatRanksMenu_Flat", client, RoundToZero(aCache[fCRFrom]));
}
}
else if(aCache[iCRRangeType] == Rank_Percentage)
{
if(bRanged)
{
FormatEx(sRequirements, 64, "%T", "ChatRanksMenu_Percentage_Ranged", client, aCache[fCRFrom], '%', aCache[fCRTo], '%');
}
else
{
FormatEx(sRequirements, 64, "%T", "ChatRanksMenu_Percentage", client, aCache[fCRFrom], '%');
}
}
else if(aCache[iCRRangeType] == Rank_Points)
{
if(bRanged)
{
FormatEx(sRequirements, 64, "%T", "ChatRanksMenu_Points_Ranged", client, RoundToZero(aCache[fCRFrom]), RoundToZero(aCache[fCRTo]));
}
else
{
FormatEx(sRequirements, 64, "%T", "ChatRanksMenu_Points", client, RoundToZero(aCache[fCRFrom]));
}
}
}
}
StrCat(sDisplay, MAXLENGTH_DISPLAY, sRequirements);
StrCat(sDisplay, MAXLENGTH_DISPLAY, "\n ");
char[] sInfo = new char[8];
IntToString(i, sInfo, 8);
menu.AddItem(sInfo, sDisplay);
}
// why even
if(menu.ItemCount == 0)
{
menu.AddItem("-1", "Nothing");
}
menu.ExitButton = true;
menu.DisplayAt(client, item, MENU_TIME_FOREVER);
return Plugin_Handled;
}
public int MenuHandler_Ranks(Menu menu, MenuAction action, int param1, int param2)
{
if(action == MenuAction_Select)
{
char[] sInfo = new char[8];
menu.GetItem(param2, sInfo, 8);
PreviewChat(param1, StringToInt(sInfo));
ShowRanksMenu(param1, GetMenuSelectionPosition());
}
else if(action == MenuAction_End)
{
delete menu;
}
}
void PreviewChat(int client, int rank)
{
char[] sTextFormatting = new char[MAXLENGTH_BUFFER];
gSM_Messages.GetString((gEV_Type != Engine_TF2)? "Cstrike_Chat_All":"TF_Chat_All", sTextFormatting, MAXLENGTH_BUFFER);
Format(sTextFormatting, MAXLENGTH_BUFFER, "\x01%s", sTextFormatting);
char[] sOriginalName = new char[MAXLENGTH_NAME];
GetClientName(client, sOriginalName, MAXLENGTH_NAME);
// remove control characters
for(int i = 0; i < sizeof(gS_ControlCharacters); i++)
{
ReplaceString(sOriginalName, MAXLENGTH_NAME, gS_ControlCharacters[i], "");
}
any[] aCache = new any[CRCACHE_SIZE];
gA_ChatRanks.GetArray(rank, aCache, view_as<int>(CRCACHE_SIZE));
char[] sName = new char[MAXLENGTH_NAME];
strcopy(sName, MAXLENGTH_NAME, aCache[sCRName]);
char[] sCMessage = new char[MAXLENGTH_CMESSAGE];
strcopy(sCMessage, MAXLENGTH_CMESSAGE, aCache[sCRMessage]);
FormatChat(client, sName, MAXLENGTH_NAME);
if(gEV_Type == Engine_CSGO)
{
FormatEx(sOriginalName, MAXLENGTH_NAME, " %s", sName);
}
else
{
strcopy(sOriginalName, MAXLENGTH_NAME, sName);
}
FormatChat(client, sCMessage, MAXLENGTH_CMESSAGE);
char[] sSampleText = new char[MAXLENGTH_MESSAGE];
strcopy(sSampleText, MAXLENGTH_MESSAGE, "The quick brown fox jumps over the lazy dog");
Format(sSampleText, MAXLENGTH_MESSAGE, "%s%s", sCMessage, sSampleText);
ReplaceString(sTextFormatting, MAXLENGTH_BUFFER, "{name}", sOriginalName);
ReplaceString(sTextFormatting, MAXLENGTH_BUFFER, "{def}", "\x01");
ReplaceString(sTextFormatting, MAXLENGTH_BUFFER, "{colon}", gS_Colon);
ReplaceString(sTextFormatting, MAXLENGTH_BUFFER, "{msg}", sSampleText);
Handle hSayText2 = StartMessageOne("SayText2", client, USERMSG_RELIABLE|USERMSG_BLOCKHOOKS);
if(hSayText2 != null)
{
if(gB_Protobuf)
{
Protobuf pbmsg = view_as<any>(hSayText2);
pbmsg.SetInt("ent_idx", client);
pbmsg.SetBool("chat", true);
pbmsg.SetString("msg_name", sTextFormatting);
for(int i = 1; i <= 4; i++)
{
pbmsg.AddString("params", "");
}
delete pbmsg;
}
else
{
BfWrite bfmsg = view_as<any>(hSayText2);
bfmsg.WriteByte(client);
bfmsg.WriteByte(true);
bfmsg.WriteString(sTextFormatting);
delete bfmsg;
}
}
EndMessage();
}
bool HasRankAccess(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 = gI_CustomChat > 0 && (CheckCommandAccess(client, "shavit_chat", ADMFLAG_CHAT) || gI_CustomChat == 2);
@ -857,8 +1096,39 @@ bool HasRankAccess(int client, int rank)
return false; return false;
} }
static any aCache[view_as<int>(bCRFree)+1]; any[] aCache = new any[CRCACHE_SIZE];
gA_ChatRanks.GetArray(rank, aCache[0], sizeof(aCache)); // a hack to only retrieve up to what we want gA_ChatRanks.GetArray(rank, aCache, view_as<int>(CRCACHE_SIZE));
char[] sFlag = new char[32];
strcopy(sFlag, 32, aCache[sCRAdminFlag]);
bool bFlagAccess = false;
int iSize = strlen(sFlag);
if(iSize == 0)
{
bFlagAccess = true;
}
else if(iSize == 1)
{
AdminFlag afFlag = view_as<AdminFlag>(0);
if(FindFlagByChar(sFlag[0], afFlag))
{
bFlagAccess = GetAdminFlag(GetUserAdmin(client), afFlag);
}
}
else
{
bFlagAccess = CheckCommandAccess(client, sFlag, 0, true);
}
if(!bFlagAccess)
{
return false;
}
if(aCache[bCRFree]) if(aCache[bCRFree])
{ {

View File

@ -135,6 +135,7 @@ bool gB_StopChatSound = false;
bool gB_HookedJump = false; bool gB_HookedJump = false;
char gS_LogPath[PLATFORM_MAX_PATH]; char gS_LogPath[PLATFORM_MAX_PATH];
int gI_GroundTicks[MAXPLAYERS+1]; int gI_GroundTicks[MAXPLAYERS+1];
MoveType gMT_MoveType[MAXPLAYERS+1];
// flags // flags
int gI_StyleFlag[STYLE_LIMIT]; int gI_StyleFlag[STYLE_LIMIT];
@ -797,11 +798,6 @@ void VelocityChanges(int data)
return; return;
} }
if(view_as<float>(gA_StyleSettings[gI_Style[client]][fGravityMultiplier]) != 1.0)
{
SetEntityGravity(client, view_as<float>(gA_StyleSettings[gI_Style[client]][fGravityMultiplier]));
}
if(view_as<float>(gA_StyleSettings[gI_Style[client]][fSpeedMultiplier]) != 1.0) if(view_as<float>(gA_StyleSettings[gI_Style[client]][fSpeedMultiplier]) != 1.0)
{ {
SetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue", view_as<float>(gA_StyleSettings[gI_Style[client]][fSpeedMultiplier])); SetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue", view_as<float>(gA_StyleSettings[gI_Style[client]][fSpeedMultiplier]));
@ -1400,9 +1396,9 @@ public void OnClientPutInServer(int client)
return; return;
} }
char[] sName = new char[MAX_NAME_LENGTH]; char[] sName = new char[MAX_NAME_LENGTH_SQL];
GetClientName(client, sName, MAX_NAME_LENGTH); GetClientName(client, sName, MAX_NAME_LENGTH_SQL);
ReplaceString(sName, MAX_NAME_LENGTH, "#", "?"); // to avoid this: https://user-images.githubusercontent.com/3672466/28637962-0d324952-724c-11e7-8b27-15ff021f0a59.png ReplaceString(sName, MAX_NAME_LENGTH_SQL, "#", "?"); // to avoid this: https://user-images.githubusercontent.com/3672466/28637962-0d324952-724c-11e7-8b27-15ff021f0a59.png
int iLength = ((strlen(sName) * 2) + 1); int iLength = ((strlen(sName) * 2) + 1);
char[] sEscapedName = new char[iLength]; char[] sEscapedName = new char[iLength];
@ -1827,6 +1823,17 @@ public void PreThinkPost(int client)
{ {
sv_enablebunnyhopping.BoolValue = view_as<bool>(gA_StyleSettings[gI_Style[client]][bEnableBunnyhopping]); sv_enablebunnyhopping.BoolValue = view_as<bool>(gA_StyleSettings[gI_Style[client]][bEnableBunnyhopping]);
} }
MoveType mtMoveType = GetEntityMoveType(client);
if(view_as<float>(gA_StyleSettings[gI_Style[client]][fGravityMultiplier]) != 1.0 &&
(mtMoveType == MOVETYPE_WALK || mtMoveType == MOVETYPE_ISOMETRIC) &&
(gMT_MoveType[client] == MOVETYPE_LADDER || GetEntityGravity(client) == 1.0))
{
SetEntityGravity(client, view_as<float>(gA_StyleSettings[gI_Style[client]][fGravityMultiplier]));
}
gMT_MoveType[client] = mtMoveType;
} }
} }
@ -2272,4 +2279,6 @@ void UpdateStyleSettings(int client)
char[] sAiraccelerate = new char[8]; char[] sAiraccelerate = new char[8];
FloatToString(gA_StyleSettings[gI_Style[client]][fAiraccelerate], sAiraccelerate, 8); FloatToString(gA_StyleSettings[gI_Style[client]][fAiraccelerate], sAiraccelerate, 8);
sv_airaccelerate.ReplicateToClient(client, sAiraccelerate); sv_airaccelerate.ReplicateToClient(client, sAiraccelerate);
SetEntityGravity(client, view_as<float>(gA_StyleSettings[gI_Style[client]][fGravityMultiplier]));
} }

View File

@ -623,6 +623,14 @@ void TriggerHUDUpdate(int client, bool keysonly = false) // keysonly because CS:
} }
} }
void FixCSGOText(char[] buffer, int maxlen)
{
if(gEV_Type == Engine_CSGO)
{
Format(buffer, maxlen, "<pre>%s</pre>", buffer);
}
}
void UpdateHUD(int client) void UpdateHUD(int client)
{ {
int target = GetHUDTarget(client); int target = GetHUDTarget(client);
@ -675,7 +683,8 @@ void UpdateHUD(int client)
if(strlen(sHintText) > 0) if(strlen(sHintText) > 0)
{ {
PrintHintText(client, sHintText); FixCSGOText(sHintText, 512);
PrintHintText(client, "%s", sHintText);
} }
else if((gI_HUDSettings[client] & HUD_CENTER) > 0) else if((gI_HUDSettings[client] & HUD_CENTER) > 0)
@ -807,6 +816,7 @@ void UpdateHUD(int client)
} }
} }
FixCSGOText(sHintText, 512);
PrintHintText(client, "%s", sHintText); PrintHintText(client, "%s", sHintText);
} }
@ -816,11 +826,13 @@ void UpdateHUD(int client)
if(style == -1) if(style == -1)
{ {
FixCSGOText(sHintText, 512);
PrintHintText(client, "%T", (gEV_Type != Engine_TF2)? "NoReplayData":"NoReplayDataTF2", client); PrintHintText(client, "%T", (gEV_Type != Engine_TF2)? "NoReplayData":"NoReplayDataTF2", client);
return; return;
} }
iSpeed = RoundToNearest(float(iSpeed) / view_as<float>(gA_StyleSettings[style][fSpeedMultiplier]));
track = Shavit_GetReplayBotTrack(target); track = Shavit_GetReplayBotTrack(target);
float fReplayTime = Shavit_GetReplayTime(style, track); float fReplayTime = Shavit_GetReplayTime(style, track);
@ -864,6 +876,7 @@ void UpdateHUD(int client)
Format(sHintText, 512, "%s\n%T: %d", sHintText, "HudSpeedText", client, iSpeed); Format(sHintText, 512, "%s\n%T: %d", sHintText, "HudSpeedText", client, iSpeed);
} }
FixCSGOText(sHintText, 512);
PrintHintText(client, "%s", sHintText); PrintHintText(client, "%s", sHintText);
} }
} }
@ -977,7 +990,7 @@ void UpdateSpectatorList(int client, Panel panel, bool &draw)
for(int i = 1; i <= MaxClients; i++) for(int i = 1; i <= MaxClients; i++)
{ {
if(i == client || !IsValidClient(i) || IsFakeClient(i) || !IsClientObserver(i) || GetClientTeam(i) < 1 || GetHUDTarget(i) != client) if(i == client || !IsValidClient(i) || IsFakeClient(i) || !IsClientObserver(i) || GetClientTeam(i) < 1 || GetHUDTarget(i) != target)
{ {
continue; continue;
} }
@ -1118,7 +1131,7 @@ void UpdateKeyHint(int client)
for(int i = 1; i <= MaxClients; i++) for(int i = 1; i <= MaxClients; i++)
{ {
if(i == client || !IsValidClient(i) || IsFakeClient(i) || !IsClientObserver(i) || GetClientTeam(i) < 1 || GetHUDTarget(i) != client) if(i == client || !IsValidClient(i) || IsFakeClient(i) || !IsClientObserver(i) || GetClientTeam(i) < 1 || GetHUDTarget(i) != target)
{ {
continue; continue;
} }

View File

@ -39,7 +39,6 @@ enum CheckpointsCache
Float:fCPPosition[3], Float:fCPPosition[3],
Float:fCPAngles[3], Float:fCPAngles[3],
Float:fCPVelocity[3], Float:fCPVelocity[3],
Float:fCPBaseVelocity[3],
MoveType:mtCPMoveType, MoveType:mtCPMoveType,
Float:fCPGravity, Float:fCPGravity,
Float:fCPSpeed, Float:fCPSpeed,
@ -54,7 +53,8 @@ enum CheckpointsCache
iCPClassname, iCPClassname,
ArrayList:aCPFrames, ArrayList:aCPFrames,
bool:bCPSegmented, bool:bCPSegmented,
bool:bCPSpectated, iCPSerial,
bool:bCPPractice,
iCPGroundEntity, iCPGroundEntity,
PCPCACHE_SIZE PCPCACHE_SIZE
} }
@ -247,8 +247,8 @@ public void OnPluginStart()
RegConsoleCmd("sm_cp", Command_Checkpoints, "Opens the checkpoints menu. Alias for sm_cpmenu."); RegConsoleCmd("sm_cp", Command_Checkpoints, "Opens the checkpoints menu. Alias for sm_cpmenu.");
RegConsoleCmd("sm_checkpoint", Command_Checkpoints, "Opens the checkpoints menu. Alias for sm_cpmenu."); RegConsoleCmd("sm_checkpoint", Command_Checkpoints, "Opens the checkpoints menu. Alias for sm_cpmenu.");
RegConsoleCmd("sm_checkpoints", Command_Checkpoints, "Opens the checkpoints menu. Alias for sm_cpmenu."); RegConsoleCmd("sm_checkpoints", Command_Checkpoints, "Opens the checkpoints menu. Alias for sm_cpmenu.");
RegConsoleCmd("sm_save", Command_Save, "Saves checkpoint (default: 1). Usage: sm_save [number]"); RegConsoleCmd("sm_save", Command_Save, "Saves checkpoint.");
RegConsoleCmd("sm_tele", Command_Tele, "Teleports to checkpoint (default: 1). Usage: sm_tele [number]"); RegConsoleCmd("sm_tele", Command_Tele, "Teleports to checkpoint. Usage: sm_tele [number]");
gH_CheckpointsCookie = RegClientCookie("shavit_checkpoints", "Checkpoints settings", CookieAccess_Protected); gH_CheckpointsCookie = RegClientCookie("shavit_checkpoints", "Checkpoints settings", CookieAccess_Protected);
gSM_Checkpoints = new StringMap(); gSM_Checkpoints = new StringMap();
gA_Targetnames = new ArrayList(ByteCountToCells(32)); gA_Targetnames = new ArrayList(ByteCountToCells(32));
@ -302,7 +302,7 @@ public void OnPluginStart()
// cvars and stuff // 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); 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);
gCV_PreSpeed = CreateConVar("shavit_misc_prespeed", "1", "Stop prespeeding in the start zone?\n0 - Disabled, fully allow prespeeding.\n1 - Limit relatively to prestrafelimit.\n2 - Block bunnyhopping in startzone.\n3 - Limit to prestrafelimit and block bunnyhopping.\n4 - Limit to prestrafelimit but allow prespeeding.", 0, true, 0.0, true, 4.0); gCV_PreSpeed = CreateConVar("shavit_misc_prespeed", "1", "Stop prespeeding in the start zone?\n0 - Disabled, fully allow prespeeding.\n1 - Limit relatively to prestrafelimit.\n2 - Block bunnyhopping in startzone.\n3 - Limit to prestrafelimit and block bunnyhopping.\n4 - Limit to prestrafelimit but allow prespeeding. Combine with shavit_core_nozaxisspeed 1 for SourceCode timer's behavior.", 0, true, 0.0, true, 4.0);
gCV_HideTeamChanges = CreateConVar("shavit_misc_hideteamchanges", "1", "Hide team changes in chat?\n0 - Disabled\n1 - Enabled", 0, true, 0.0, true, 1.0); gCV_HideTeamChanges = CreateConVar("shavit_misc_hideteamchanges", "1", "Hide team changes in chat?\n0 - Disabled\n1 - Enabled", 0, true, 0.0, true, 1.0);
gCV_RespawnOnTeam = CreateConVar("shavit_misc_respawnonteam", "1", "Respawn whenever a player joins a team?\n0 - Disabled\n1 - Enabled", 0, true, 0.0, true, 1.0); gCV_RespawnOnTeam = CreateConVar("shavit_misc_respawnonteam", "1", "Respawn whenever a player joins a team?\n0 - Disabled\n1 - Enabled", 0, true, 0.0, true, 1.0);
gCV_RespawnOnRestart = CreateConVar("shavit_misc_respawnonrestart", "1", "Respawn a dead player if they use the timer restart command?\n0 - Disabled\n1 - Enabled", 0, true, 0.0, true, 1.0); gCV_RespawnOnRestart = CreateConVar("shavit_misc_respawnonrestart", "1", "Respawn a dead player if they use the timer restart command?\n0 - Disabled\n1 - Enabled", 0, true, 0.0, true, 1.0);
@ -1011,15 +1011,13 @@ public Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float
if(gI_PreSpeed == 1 || gI_PreSpeed >= 3) if(gI_PreSpeed == 1 || gI_PreSpeed >= 3)
{ {
float fLimit = gF_PrestrafeLimit;
float fSpeed[3]; float fSpeed[3];
GetEntPropVector(client, Prop_Data, "m_vecAbsVelocity", fSpeed); GetEntPropVector(client, Prop_Data, "m_vecAbsVelocity", fSpeed);
float fLimit = view_as<float>(gA_StyleSettings[gI_Style[client]][fRunspeed]) + gF_PrestrafeLimit;
if(gI_PreSpeed < 4) if(gI_PreSpeed < 4)
{ {
fLimit = view_as<float>(gA_StyleSettings[gI_Style[client]][fRunspeed]) + gF_PrestrafeLimit;
// if trying to jump, add a very low limit to stop prespeeding in an elegant way // 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) // otherwise, make sure nothing weird is happening (such as sliding at ridiculous speeds, at zone enter)
if(fSpeed[2] > 0.0) if(fSpeed[2] > 0.0)
@ -1517,55 +1515,46 @@ public Action Command_Save(int client, int args)
} }
int iMaxCPs = GetMaxCPs(client); int iMaxCPs = GetMaxCPs(client);
bool bSegmenting = CanSegment(client);
if(gI_CheckpointsCache[client][iCheckpoints] >= iMaxCPs)
{
return Plugin_Handled;
}
bool bSegmented = CanSegment(client); if(!gB_Checkpoints && !bSegmenting)
if(!gB_Checkpoints && !bSegmented)
{ {
Shavit_PrintToChat(client, "%T", "FeatureDisabled", client, gS_ChatStrings[sMessageWarning], gS_ChatStrings[sMessageText]); Shavit_PrintToChat(client, "%T", "FeatureDisabled", client, gS_ChatStrings[sMessageWarning], gS_ChatStrings[sMessageText]);
return Plugin_Handled; return Plugin_Handled;
} }
int index = gI_CheckpointsCache[client][iCheckpoints]; bool bOverflow = gI_CheckpointsCache[client][iCheckpoints] >= iMaxCPs;
int index = gI_CheckpointsCache[client][iCheckpoints] + 1;
if(args > 0)
{
char[] arg = new char[4];
GetCmdArg(1, arg, 4);
int parsed = StringToInt(arg);
if(parsed > 0 && parsed <= iMaxCPs)
{
index = (parsed - 1);
}
}
bool bSegmenting = CanSegment(client);
bool bSaved = false;
if(!bSegmenting) if(!bSegmenting)
{ {
bSaved = SaveCheckpoint(client, gI_CheckpointsCache[client][iCheckpoints]); if(index > iMaxCPs)
gI_CheckpointsCache[client][iCurrentCheckpoint] = ++gI_CheckpointsCache[client][iCheckpoints]; {
index = iMaxCPs;
}
if(bOverflow)
{
Shavit_PrintToChat(client, "%T", "MiscCheckpointsOverflow", client, index, gS_ChatStrings[sMessageVariable], gS_ChatStrings[sMessageText]);
return Plugin_Handled;
}
if(SaveCheckpoint(client, index))
{
gI_CheckpointsCache[client][iCurrentCheckpoint] = ++gI_CheckpointsCache[client][iCheckpoints];
Shavit_PrintToChat(client, "%T", "MiscCheckpointsSaved", client, gI_CheckpointsCache[client][iCurrentCheckpoint], gS_ChatStrings[sMessageVariable], gS_ChatStrings[sMessageText]);
}
} }
else else
{ {
bool bOverflow = gI_CheckpointsCache[client][iCheckpoints] >= iMaxCPs; if(SaveCheckpoint(client, index, bOverflow))
bSaved = SaveCheckpoint(client, gI_CheckpointsCache[client][iCheckpoints], bOverflow); {
gI_CheckpointsCache[client][iCurrentCheckpoint] = (bOverflow)? iMaxCPs:++gI_CheckpointsCache[client][iCheckpoints]; gI_CheckpointsCache[client][iCurrentCheckpoint] = (bOverflow)? iMaxCPs:++gI_CheckpointsCache[client][iCheckpoints];
} Shavit_PrintToChat(client, "%T", "MiscCheckpointsSaved", client, gI_CheckpointsCache[client][iCurrentCheckpoint], gS_ChatStrings[sMessageVariable], gS_ChatStrings[sMessageText]);
}
if(bSaved)
{
Shavit_PrintToChat(client, "%T", "MiscCheckpointsSaved", client, (index + 1), gS_ChatStrings[sMessageVariable], gS_ChatStrings[sMessageText]);
} }
return Plugin_Handled; return Plugin_Handled;
@ -1587,7 +1576,7 @@ public Action Command_Tele(int client, int args)
return Plugin_Handled; return Plugin_Handled;
} }
int index = (gI_CheckpointsCache[client][iCurrentCheckpoint] - 1); int index = gI_CheckpointsCache[client][iCurrentCheckpoint];
if(args > 0) if(args > 0)
{ {
@ -1596,9 +1585,9 @@ public Action Command_Tele(int client, int args)
int parsed = StringToInt(arg); int parsed = StringToInt(arg);
if(parsed > 0 && parsed <= gI_MaxCP) if(0 < parsed <= gI_MaxCP)
{ {
index = (parsed - 1); index = parsed;
} }
} }
@ -1678,7 +1667,6 @@ public int MenuHandler_Checkpoints(Menu menu, MenuAction action, int param1, int
{ {
if(action == MenuAction_Select) if(action == MenuAction_Select)
{ {
bool bSegmenting = CanSegment(param1);
int iMaxCPs = GetMaxCPs(param1); int iMaxCPs = GetMaxCPs(param1);
int iCurrent = gI_CheckpointsCache[param1][iCurrentCheckpoint]; int iCurrent = gI_CheckpointsCache[param1][iCurrentCheckpoint];
@ -1686,29 +1674,31 @@ public int MenuHandler_Checkpoints(Menu menu, MenuAction action, int param1, int
{ {
case 0: case 0:
{ {
bool bSegmenting = CanSegment(param1);
bool bOverflow = gI_CheckpointsCache[param1][iCheckpoints] >= iMaxCPs;
if(!bSegmenting) if(!bSegmenting)
{ {
// fight an exploit // fight an exploit
if(gI_CheckpointsCache[param1][iCheckpoints] >= iMaxCPs) if(bOverflow)
{ {
return 0; return 0;
} }
SaveCheckpoint(param1, gI_CheckpointsCache[param1][iCheckpoints]); SaveCheckpoint(param1, ++gI_CheckpointsCache[param1][iCheckpoints]);
gI_CheckpointsCache[param1][iCurrentCheckpoint] = ++gI_CheckpointsCache[param1][iCheckpoints]; gI_CheckpointsCache[param1][iCurrentCheckpoint] = gI_CheckpointsCache[param1][iCheckpoints];
} }
else else
{ {
bool bOverflow = gI_CheckpointsCache[param1][iCheckpoints] >= iMaxCPs; SaveCheckpoint(param1, gI_CheckpointsCache[param1][iCheckpoints] + 1, bOverflow);
SaveCheckpoint(param1, gI_CheckpointsCache[param1][iCheckpoints], bOverflow);
gI_CheckpointsCache[param1][iCurrentCheckpoint] = (bOverflow)? iMaxCPs:++gI_CheckpointsCache[param1][iCheckpoints]; gI_CheckpointsCache[param1][iCurrentCheckpoint] = (bOverflow)? iMaxCPs:++gI_CheckpointsCache[param1][iCheckpoints];
} }
} }
case 1: case 1:
{ {
TeleportToCheckpoint(param1, iCurrent - 1, true); TeleportToCheckpoint(param1, iCurrent, true);
} }
case 2: case 2:
@ -1820,9 +1810,6 @@ bool SaveCheckpoint(int client, int index, bool overflow = false)
GetEntPropVector(target, Prop_Data, "m_vecAbsVelocity", temp); GetEntPropVector(target, Prop_Data, "m_vecAbsVelocity", temp);
CopyArray(temp, cpcache[fCPVelocity], 3); CopyArray(temp, cpcache[fCPVelocity], 3);
GetEntPropVector(target, Prop_Data, "m_vecBaseVelocity", temp);
CopyArray(temp, cpcache[fCPBaseVelocity], 3);
char[] sTargetname = new char[32]; char[] sTargetname = new char[32];
GetEntPropString(target, Prop_Data, "m_iName", sTargetname, 32); GetEntPropString(target, Prop_Data, "m_iName", sTargetname, 32);
@ -1927,13 +1914,14 @@ bool SaveCheckpoint(int client, int index, bool overflow = false)
cpcache[bCPSegmented] = false; cpcache[bCPSegmented] = false;
} }
cpcache[bCPSpectated] = (client != target); cpcache[iCPSerial] = GetClientSerial(target);
cpcache[bCPPractice] = Shavit_IsPracticeMode(target);
if(overflow) if(overflow)
{ {
int iMaxCPs = GetMaxCPs(client); int iMaxCPs = GetMaxCPs(client);
for(int i = 0; i < iMaxCPs; i++) for(int i = 1; i <= iMaxCPs; i++)
{ {
CheckpointsCache cpcacheold[PCPCACHE_SIZE]; CheckpointsCache cpcacheold[PCPCACHE_SIZE];
FormatEx(sKey, 32, "%d_%d", iSerial, i); FormatEx(sKey, 32, "%d_%d", iSerial, i);
@ -1943,7 +1931,7 @@ bool SaveCheckpoint(int client, int index, bool overflow = false)
continue; // ??? continue; // ???
} }
if(i == 0) if(i == 1)
{ {
delete cpcacheold[aCPFrames]; delete cpcacheold[aCPFrames];
gSM_Checkpoints.Remove(sKey); gSM_Checkpoints.Remove(sKey);
@ -1956,17 +1944,20 @@ bool SaveCheckpoint(int client, int index, bool overflow = false)
gSM_Checkpoints.SetArray(sKey, cpcacheold[0], view_as<int>(PCPCACHE_SIZE)); gSM_Checkpoints.SetArray(sKey, cpcacheold[0], view_as<int>(PCPCACHE_SIZE));
} }
index = (iMaxCPs - 1); SetCheckpoint(client, iMaxCPs, cpcache);
} }
SetCheckpoint(client, index, cpcache); else
{
SetCheckpoint(client, index, cpcache);
}
return true; return true;
} }
void TeleportToCheckpoint(int client, int index, bool suppressMessage) void TeleportToCheckpoint(int client, int index, bool suppressMessage)
{ {
if(index < 0 || index >= gI_MaxCP || (!gB_Checkpoints && !CanSegment(client))) if(index < 0 || index > gI_MaxCP || (!gB_Checkpoints && !CanSegment(client)))
{ {
return; return;
} }
@ -1975,7 +1966,7 @@ void TeleportToCheckpoint(int client, int index, bool suppressMessage)
if(!GetCheckpoint(client, index, cpcache)) if(!GetCheckpoint(client, index, cpcache))
{ {
Shavit_PrintToChat(client, "%T", "MiscCheckpointsEmpty", client, (index + 1), gS_ChatStrings[sMessageWarning], gS_ChatStrings[sMessageText]); Shavit_PrintToChat(client, "%T", "MiscCheckpointsEmpty", client, index, gS_ChatStrings[sMessageWarning], gS_ChatStrings[sMessageText]);
return; return;
} }
@ -1995,18 +1986,11 @@ void TeleportToCheckpoint(int client, int index, bool suppressMessage)
return; return;
} }
bool bInStart = Shavit_InsideZone(client, Zone_Start, -1); if(Shavit_InsideZone(client, Zone_Start, -1))
if(bInStart)
{ {
Shavit_StopTimer(client); Shavit_StopTimer(client);
} }
if(!cpcache[bCPSegmented] || cpcache[bCPSpectated])
{
Shavit_SetPracticeMode(client, true, !bInStart);
}
any snapshot[TIMERSNAPSHOT_SIZE]; any snapshot[TIMERSNAPSHOT_SIZE];
CopyArray(cpcache[aCPSnapshot], snapshot, TIMERSNAPSHOT_SIZE); CopyArray(cpcache[aCPSnapshot], snapshot, TIMERSNAPSHOT_SIZE);
Shavit_LoadSnapshot(client, snapshot); Shavit_LoadSnapshot(client, snapshot);
@ -2014,19 +1998,25 @@ void TeleportToCheckpoint(int client, int index, bool suppressMessage)
float ang[3]; float ang[3];
CopyArray(cpcache[fCPAngles], ang, 3); CopyArray(cpcache[fCPAngles], ang, 3);
TeleportEntity(client, pos, float vel[3];
((gI_CheckpointsSettings[client] & CP_ANGLES) > 0 || cpcache[bCPSegmented])? ang:NULL_VECTOR,
NULL_VECTOR);
if((gI_CheckpointsSettings[client] & CP_VELOCITY) > 0 || cpcache[bCPSegmented]) if((gI_CheckpointsSettings[client] & CP_VELOCITY) > 0 || cpcache[bCPSegmented])
{ {
float basevel[3];
CopyArray(cpcache[fCPBaseVelocity], basevel, 3);
SetEntPropVector(client, Prop_Data, "m_vecBaseVelocity", basevel);
float vel[3];
CopyArray(cpcache[fCPVelocity], vel, 3); CopyArray(cpcache[fCPVelocity], vel, 3);
SetEntPropVector(client, Prop_Data, "m_vecAbsVelocity", vel); }
else
{
vel = NULL_VECTOR;
}
TeleportEntity(client, pos,
((gI_CheckpointsSettings[client] & CP_ANGLES) > 0 || cpcache[bCPSegmented])? ang:NULL_VECTOR,
vel);
if(cpcache[bCPPractice] || !cpcache[bCPSegmented] || GetClientSerial(client) != cpcache[iCPSerial])
{
Shavit_SetPracticeMode(client, true, true);
} }
MoveType mt = cpcache[mtCPMoveType]; MoveType mt = cpcache[mtCPMoveType];
@ -2095,7 +2085,7 @@ void TeleportToCheckpoint(int client, int index, bool suppressMessage)
if(!suppressMessage) if(!suppressMessage)
{ {
Shavit_PrintToChat(client, "%T", "MiscCheckpointsTeleported", client, (index + 1), gS_ChatStrings[sMessageVariable], gS_ChatStrings[sMessageText]); Shavit_PrintToChat(client, "%T", "MiscCheckpointsTeleported", client, index, gS_ChatStrings[sMessageVariable], gS_ChatStrings[sMessageText]);
} }
} }

View File

@ -109,6 +109,8 @@ ConVar gCV_TimeLimit = null;
ConVar gCV_DefaultTeam = null; ConVar gCV_DefaultTeam = null;
ConVar gCV_CentralBot = null; ConVar gCV_CentralBot = null;
ConVar gCV_BotShooting = null; ConVar gCV_BotShooting = null;
ConVar gCV_BotPlusUse = null;
ConVar gCV_BotWeapon = null;
// cached cvars // cached cvars
bool gB_Enabled = true; bool gB_Enabled = true;
@ -117,6 +119,8 @@ float gF_TimeLimit = 5400.0;
int gI_DefaultTeam = 3; int gI_DefaultTeam = 3;
bool gB_CentralBot = true; bool gB_CentralBot = true;
int gI_BotShooting = 3; int gI_BotShooting = 3;
bool gB_BotPlusUse = true;
char gS_BotWeapon[32] = "";
// timer settings // timer settings
int gI_Styles = 0; int gI_Styles = 0;
@ -211,6 +215,8 @@ public void OnPluginStart()
gCV_DefaultTeam = CreateConVar("shavit_replay_defaultteam", "3", "Default team to make the bots join, if possible.\n2 - Terrorists/RED\n3 - Counter Terrorists/BLU", 0, true, 2.0, true, 3.0); gCV_DefaultTeam = CreateConVar("shavit_replay_defaultteam", "3", "Default team to make the bots join, if possible.\n2 - Terrorists/RED\n3 - Counter Terrorists/BLU", 0, true, 2.0, true, 3.0);
gCV_CentralBot = CreateConVar("shavit_replay_centralbot", "1", "Have one central bot instead of one bot per replay.\nTriggered with !replay.\nRestart the map for changes to take effect.\nThe disabled setting is not supported - use at your own risk.\n0 - Disabled\n1 - Enabled", 0, true, 0.0, true, 1.0); gCV_CentralBot = CreateConVar("shavit_replay_centralbot", "1", "Have one central bot instead of one bot per replay.\nTriggered with !replay.\nRestart the map for changes to take effect.\nThe disabled setting is not supported - use at your own risk.\n0 - Disabled\n1 - Enabled", 0, true, 0.0, true, 1.0);
gCV_BotShooting = CreateConVar("shavit_replay_botshooting", "3", "Attacking buttons to allow for bots.\n0 - none\1 - +attack\n2 - +attack2\n3 - both", 0, true, 0.0, true, 3.0); gCV_BotShooting = CreateConVar("shavit_replay_botshooting", "3", "Attacking buttons to allow for bots.\n0 - none\1 - +attack\n2 - +attack2\n3 - both", 0, true, 0.0, true, 3.0);
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_Enabled.AddChangeHook(OnConVarChanged);
gCV_ReplayDelay.AddChangeHook(OnConVarChanged); gCV_ReplayDelay.AddChangeHook(OnConVarChanged);
@ -218,6 +224,8 @@ public void OnPluginStart()
gCV_DefaultTeam.AddChangeHook(OnConVarChanged); gCV_DefaultTeam.AddChangeHook(OnConVarChanged);
gCV_CentralBot.AddChangeHook(OnConVarChanged); gCV_CentralBot.AddChangeHook(OnConVarChanged);
gCV_BotShooting.AddChangeHook(OnConVarChanged); gCV_BotShooting.AddChangeHook(OnConVarChanged);
gCV_BotPlusUse.AddChangeHook(OnConVarChanged);
gCV_BotWeapon.AddChangeHook(OnConVarChanged);
AutoExecConfig(); AutoExecConfig();
@ -253,6 +261,8 @@ public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] n
gI_DefaultTeam = gCV_DefaultTeam.IntValue; gI_DefaultTeam = gCV_DefaultTeam.IntValue;
gB_CentralBot = gCV_CentralBot.BoolValue; gB_CentralBot = gCV_CentralBot.BoolValue;
gI_BotShooting = gCV_BotShooting.IntValue; gI_BotShooting = gCV_BotShooting.IntValue;
gB_BotPlusUse = gCV_BotPlusUse.BoolValue;
gCV_BotWeapon.GetString(gS_BotWeapon, 32);
if(convar == gCV_CentralBot) if(convar == gCV_CentralBot)
{ {
@ -1264,10 +1274,39 @@ void UpdateReplayInfo(int client, int style, float time, int track)
} }
} }
// Spectating is laggy if the player has no weapons if(gEV_Type != Engine_TF2 && strlen(gS_BotWeapon) > 0)
if(gEV_Type != Engine_TF2 && GetPlayerWeaponSlot(client, CS_SLOT_KNIFE) == -1)
{ {
GivePlayerItem(client, "weapon_knife"); int iWeapon = GetEntPropEnt(client, Prop_Data, "m_hActiveWeapon");
if(StrEqual(gS_BotWeapon, "none"))
{
if(iWeapon != -1 && IsValidEntity(iWeapon))
{
CS_DropWeapon(client, iWeapon, false);
AcceptEntityInput(iWeapon, "Kill");
}
}
else
{
char[] sClassname = new char[32];
if(iWeapon != -1 && IsValidEntity(iWeapon))
{
GetEntityClassname(iWeapon, sClassname, 32);
if(!StrEqual(gS_BotWeapon, sClassname))
{
CS_DropWeapon(client, iWeapon, false);
AcceptEntityInput(iWeapon, "Kill");
}
}
else
{
GivePlayerItem(client, gS_BotWeapon);
}
}
} }
} }
@ -1544,6 +1583,11 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
buttons &= ~IN_ATTACK2; buttons &= ~IN_ATTACK2;
} }
if(!gB_BotPlusUse)
{
buttons &= ~IN_USE;
}
MoveType mt = MOVETYPE_NOCLIP; MoveType mt = MOVETYPE_NOCLIP;
if(gA_FrameCache[style][track][3] >= 0x02) if(gA_FrameCache[style][track][3] >= 0x02)
@ -1599,7 +1643,7 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
} }
} }
else if(Shavit_GetTimerStatus(client) == Timer_Running && ReplayEnabled(Shavit_GetBhopStyle(client)) && Shavit_GetTimerStatus(client) == Timer_Running) else if(ReplayEnabled(Shavit_GetBhopStyle(client)) && Shavit_GetTimerStatus(client) == Timer_Running)
{ {
gA_PlayerFrames[client].Resize(gI_PlayerFrames[client] + 1); gA_PlayerFrames[client].Resize(gI_PlayerFrames[client] + 1);

View File

@ -2308,7 +2308,7 @@ public void SQL_UpdateLeaderboards_Callback(Database db, DBResultSet results, co
int GetRankForTime(int style, float time, int track) int GetRankForTime(int style, float time, int track)
{ {
if(time < gF_WRTime[style][track] || gI_RecordAmount[style][track] <= 0) if(time <= gF_WRTime[style][track] || gI_RecordAmount[style][track] <= 0)
{ {
return 1; return 1;
} }

View File

@ -59,4 +59,42 @@
{ {
"en" "Custom\nUse custom chat settings. See !cchelp for more information." "en" "Custom\nUse custom chat settings. See !cchelp for more information."
} }
"ChatRanksMenu"
{
"en" "Obtainable chat ranks:\nSelect an entry to preview.\n"
}
"ChatRanksMenu_Unranked"
{
"en" "Unranked"
}
"ChatRanksMenu_Points"
{
"#format" "{1:d}"
"en" "Have {1} points"
}
"ChatRanksMenu_Points_Ranged"
{
"#format" "{1:d},{2:d}"
"en" "Have between {1} and {2} points"
}
"ChatRanksMenu_Flat"
{
"#format" "{1:d}"
"en" "Ranked #{1} or better"
}
"ChatRanksMenu_Flat_Ranged"
{
"#format" "{1:d},{2:d}"
"en" "Ranked between #{1} and #{2}"
}
"ChatRanksMenu_Percentage"
{
"#format" "{1:.1f},{2:c}"
"en" "Top {1}{2}"
}
"ChatRanksMenu_Percentage_Ranged"
{
"#format" "{1:.1f},{2:c},{3:.1f},{4:c}"
"en" "Between top {1}{2} and {3}{4}"
}
} }

View File

@ -83,6 +83,10 @@
"#format" "{1:d},{2:s},{3:s}" "#format" "{1:d},{2:s},{3:s}"
"en" "Checkpoint {1} is {2}empty{3}." "en" "Checkpoint {1} is {2}empty{3}."
} }
"MiscCheckpointsOverflow"
{
"en" "Unable to save due to checkpoint overflow."
}
"MiscSegmentedCommand" "MiscSegmentedCommand"
{ {
"#format" "{1:s},{2:s}" "#format" "{1:s},{2:s}"