mirror of
https://github.com/shavitush/bhoptimer.git
synced 2025-12-06 18:08:26 +00:00
Added TF2 support. (#549)
Tested most of the things in-game, should be good to go!
This commit is contained in:
parent
594f1cab9f
commit
cfde142e92
@ -20,7 +20,7 @@ Including a records system, map zones (start/end marks etc), bonuses, HUD with u
|
||||
|
||||
# Optional requirements:
|
||||
* [DHooks](http://users.alliedmods.net/~drifter/builds/dhooks/2.0/) - required for 250/260 runspeed for all weapons.
|
||||
* [Bunnyhop Statistics](https://forums.alliedmods.net/showthread.php?t=286135) - to show amount of scrolls for non-auto styles in the key display. CS:S only!
|
||||
* [Bunnyhop Statistics](https://forums.alliedmods.net/showthread.php?t=286135) - to show amount of scrolls for non-auto styles in the key display. Required for TF2 servers.
|
||||
* [SteamWorks](https://forums.alliedmods.net/showthread.php?t=229556) - for the `{serverip}` advertisement variable.
|
||||
* [Chat-Processor](https://github.com/Drixevel/Chat-Processor) - if you're enabling the `shavit-chat` module.
|
||||
* A MySQL database (preferably locally hosted) if your database is likely to grow or want to use the rankings plugin. MySQL server version of 5.5.5 or above (MariaDB equivalent works too) is recommended.
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
//
|
||||
"Messages"
|
||||
{
|
||||
"CS:S"
|
||||
"CS:S" // TF2 is pulled from this too, because both have the same chat capabilities!
|
||||
{
|
||||
"prefix" "{RGB}5e70d0[Timer]"
|
||||
"text" "{RGB}ffffff"
|
||||
|
||||
@ -232,6 +232,11 @@ stock bool IsValidClient(int client, bool bAlive = false)
|
||||
return (client >= 1 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client) && !IsClientSourceTV(client) && (!bAlive || IsPlayerAlive(client)));
|
||||
}
|
||||
|
||||
stock bool IsSource2013(EngineVersion ev)
|
||||
{
|
||||
return (ev == Engine_CSS || ev == Engine_TF2);
|
||||
}
|
||||
|
||||
// time formatting!
|
||||
stock void FormatSeconds(float time, char[] newtime, int newtimesize, bool precise = true)
|
||||
{
|
||||
|
||||
@ -205,7 +205,7 @@ public Action Command_CCHelp(int client, int args)
|
||||
PrintToConsole(client, "%T", "CCHelp_Generic", client);
|
||||
PrintToConsole(client, "%T", "CCHelp_GenericVariables", client);
|
||||
|
||||
if(gEV_Type == Engine_CSS)
|
||||
if(IsSource2013(gEV_Type))
|
||||
{
|
||||
PrintToConsole(client, "%T", "CCHelp_CSS_1", client);
|
||||
PrintToConsole(client, "%T", "CCHelp_CSS_2", client);
|
||||
@ -429,7 +429,7 @@ void FormatRandom(char[] buffer, int size)
|
||||
|
||||
do
|
||||
{
|
||||
if(gEV_Type == Engine_CSS)
|
||||
if(IsSource2013(gEV_Type))
|
||||
{
|
||||
int color = ((RealRandomInt(0, 255) & 0xFF) << 16);
|
||||
color |= ((RealRandomInt(0, 255) & 0xFF) << 8);
|
||||
|
||||
@ -26,6 +26,8 @@
|
||||
|
||||
#undef REQUIRE_PLUGIN
|
||||
#include <adminmenu>
|
||||
#include <bhopstats>
|
||||
|
||||
#define USES_CHAT_COLORS
|
||||
#include <shavit>
|
||||
|
||||
@ -34,7 +36,7 @@
|
||||
|
||||
// #define DEBUG
|
||||
|
||||
// game type (CS:S/CS:GO)
|
||||
// game type (CS:S/CS:GO/TF2)
|
||||
ServerGame gSG_Type = Game_Unknown; // deperecated and here for backwards compatibility
|
||||
EngineVersion gEV_Type = Engine_Unknown;
|
||||
|
||||
@ -131,6 +133,7 @@ char gS_ChatStrings[CHATSETTINGS_SIZE][128];
|
||||
|
||||
// misc cache
|
||||
bool gB_StopChatSound = false;
|
||||
bool gB_HookedJump = false;
|
||||
|
||||
// kz support
|
||||
bool gB_KZMap = false;
|
||||
@ -206,7 +209,7 @@ public void OnPluginStart()
|
||||
// game types
|
||||
gEV_Type = GetEngineVersion();
|
||||
|
||||
if(gEV_Type == Engine_CSS)
|
||||
if(gEV_Type == Engine_CSS || gEV_Type == Engine_TF2)
|
||||
{
|
||||
gSG_Type = Game_CSS;
|
||||
}
|
||||
@ -221,7 +224,7 @@ public void OnPluginStart()
|
||||
|
||||
else
|
||||
{
|
||||
SetFailState("This plugin was meant to be used in CS:S and CS:GO *only*.");
|
||||
SetFailState("This plugin was meant to be used in CS:S, CS:GO and TF2 *only*.");
|
||||
}
|
||||
|
||||
// database connections
|
||||
@ -229,7 +232,7 @@ public void OnPluginStart()
|
||||
SQL_DBConnect();
|
||||
|
||||
// hooks
|
||||
HookEvent("player_jump", Player_Jump);
|
||||
gB_HookedJump = HookEventEx("player_jump", Player_Jump);
|
||||
HookEvent("player_death", Player_Death);
|
||||
HookEvent("player_team", Player_Death);
|
||||
HookEvent("player_spawn", Player_Death);
|
||||
@ -309,7 +312,11 @@ public void OnPluginStart()
|
||||
sv_airaccelerate.Flags &= ~(FCVAR_NOTIFY | FCVAR_REPLICATED);
|
||||
|
||||
sv_enablebunnyhopping = FindConVar("sv_enablebunnyhopping");
|
||||
sv_enablebunnyhopping.Flags &= ~(FCVAR_NOTIFY | FCVAR_REPLICATED);
|
||||
|
||||
if(sv_enablebunnyhopping != null)
|
||||
{
|
||||
sv_enablebunnyhopping.Flags &= ~(FCVAR_NOTIFY | FCVAR_REPLICATED);
|
||||
}
|
||||
|
||||
// late
|
||||
if(gB_Late)
|
||||
@ -813,16 +820,31 @@ void ChangeClientStyle(int client, int style, bool manual)
|
||||
SetClientCookie(client, gH_StyleCookie, sStyle);
|
||||
}
|
||||
|
||||
// used as an alternative for games where player_jump isn't a thing, such as TF2
|
||||
public void Bunnyhop_OnLeaveGround(int client, bool jumped, bool ladder)
|
||||
{
|
||||
if(gB_HookedJump || !jumped || ladder)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DoJump(client);
|
||||
}
|
||||
|
||||
public void Player_Jump(Event event, const char[] name, bool dontBroadcast)
|
||||
{
|
||||
int client = GetClientOfUserId(event.GetInt("userid"));
|
||||
DoJump(GetClientOfUserId(event.GetInt("userid")));
|
||||
}
|
||||
|
||||
void DoJump(int client)
|
||||
{
|
||||
if(gB_TimerEnabled[client])
|
||||
{
|
||||
gI_Jumps[client]++;
|
||||
}
|
||||
|
||||
if((gB_NoStaminaReset && gA_StyleSettings[gBS_Style[client]][bEasybhop]) || Shavit_InsideZone(client, Zone_Easybhop, gI_Track[client]))
|
||||
// TF2 doesn't use stamina
|
||||
if(gEV_Type != Engine_TF2 && (gB_NoStaminaReset && gA_StyleSettings[gBS_Style[client]][bEasybhop]) || Shavit_InsideZone(client, Zone_Easybhop, gI_Track[client]))
|
||||
{
|
||||
SetEntPropFloat(client, Prop_Send, "m_flStamina", 0.0);
|
||||
}
|
||||
@ -1060,7 +1082,7 @@ public int Native_PrintToChat(Handle handler, int numParams)
|
||||
FormatNativeString(0, 2, 3, 300, written, buffer);
|
||||
Format(buffer, 300, "%s %s%s", gS_ChatStrings[sMessagePrefix], gS_ChatStrings[sMessageText], buffer);
|
||||
|
||||
if(gEV_Type == Engine_CSS)
|
||||
if(IsSource2013(gEV_Type))
|
||||
{
|
||||
Handle hSayText2 = StartMessageOne("SayText2", client);
|
||||
|
||||
@ -1596,7 +1618,7 @@ bool LoadMessages()
|
||||
return false;
|
||||
}
|
||||
|
||||
kv.JumpToKey((gEV_Type == Engine_CSS)? "CS:S":"CS:GO");
|
||||
kv.JumpToKey((IsSource2013(gEV_Type))? "CS:S":"CS:GO");
|
||||
|
||||
kv.GetString("prefix", gS_ChatStrings[sMessagePrefix], 128, "\x075e70d0[Timer]");
|
||||
kv.GetString("text", gS_ChatStrings[sMessageText], 128, "\x07ffffff");
|
||||
@ -1816,8 +1838,12 @@ public void PreThinkPost(int client)
|
||||
{
|
||||
if(IsPlayerAlive(client))
|
||||
{
|
||||
sv_airaccelerate.FloatValue = gA_StyleSettings[gBS_Style[client]][fAiraccelerate];
|
||||
sv_enablebunnyhopping.BoolValue = gA_StyleSettings[gBS_Style[client]][bEnableBunnyhopping];
|
||||
sv_airaccelerate.FloatValue = view_as<float>(gA_StyleSettings[gBS_Style[client]][fAiraccelerate]);
|
||||
|
||||
if(sv_enablebunnyhopping != null)
|
||||
{
|
||||
sv_enablebunnyhopping.BoolValue = view_as<bool>(gA_StyleSettings[gBS_Style[client]][bEnableBunnyhopping]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2036,10 +2062,20 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
|
||||
gI_Strafes[client]++;
|
||||
}
|
||||
|
||||
bool bInWater = (GetEntProp(client, Prop_Send, "m_nWaterLevel") >= 2);
|
||||
|
||||
// enable duck-jumping/bhop in tf2
|
||||
if(gEV_Type == Engine_TF2 && gA_StyleSettings[gBS_Style[client]][bEnableBunnyhopping] && (buttons & IN_JUMP) > 0 && iGroundEntity != -1)
|
||||
{
|
||||
float fSpeed[3];
|
||||
GetEntPropVector(client, Prop_Data, "m_vecAbsVelocity", fSpeed);
|
||||
|
||||
fSpeed[2] = 271.0;
|
||||
SetEntPropVector(client, Prop_Data, "m_vecAbsVelocity", fSpeed);
|
||||
}
|
||||
|
||||
if(gA_StyleSettings[gBS_Style[client]][bAutobhop] && gB_Autobhop && gB_Auto[client])
|
||||
{
|
||||
bool bInWater = (GetEntProp(client, Prop_Send, "m_nWaterLevel") >= 2);
|
||||
|
||||
if((buttons & IN_JUMP) > 0 && iGroundEntity == -1 && !bOnLadder && !bInWater)
|
||||
{
|
||||
buttons &= ~IN_JUMP;
|
||||
@ -2078,7 +2114,7 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
|
||||
if(fScale < 1.0)
|
||||
{
|
||||
ScaleVector(fSpeed, fScale);
|
||||
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, fSpeed);
|
||||
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, fSpeed); // maybe change this to SetEntPropVector some time?
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2170,6 +2206,8 @@ void UpdateAiraccelerate(int client)
|
||||
|
||||
void UpdateBunnyhopping(int client)
|
||||
{
|
||||
// No null check here. Pre-OB - no support.
|
||||
sv_enablebunnyhopping.ReplicateToClient(client, (gA_StyleSettings[gBS_Style[client]][bEnableBunnyhopping])? "1":"0");
|
||||
if(sv_enablebunnyhopping != null)
|
||||
{
|
||||
sv_enablebunnyhopping.ReplicateToClient(client, (gA_StyleSettings[gBS_Style[client]][bEnableBunnyhopping])? "1":"0");
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
|
||||
#define HUD_DEFAULT (HUD_MASTER|HUD_CENTER|HUD_ZONEHUD|HUD_OBSERVE|HUD_TOPLEFT|HUD_SYNC|HUD_TIMELEFT|HUD_2DVEL|HUD_SPECTATORS)
|
||||
|
||||
// game type (CS:S/CS:GO)
|
||||
// game type (CS:S/CS:GO/TF2)
|
||||
EngineVersion gEV_Type = Engine_Unknown;
|
||||
|
||||
// modules
|
||||
@ -54,6 +54,8 @@ int gI_LastScrollCount[MAXPLAYERS+1];
|
||||
int gI_ScrollCount[MAXPLAYERS+1];
|
||||
int gBS_Style[MAXPLAYERS+1];
|
||||
int gI_Buttons[MAXPLAYERS+1];
|
||||
float gF_ConnectTime[MAXPLAYERS+1];
|
||||
bool gB_FirstPrint[MAXPLAYERS+1];
|
||||
|
||||
bool gB_Late = false;
|
||||
|
||||
@ -101,7 +103,7 @@ public void OnPluginStart()
|
||||
// game-specific
|
||||
gEV_Type = GetEngineVersion();
|
||||
|
||||
if(gEV_Type == Engine_CSS)
|
||||
if(IsSource2013(gEV_Type))
|
||||
{
|
||||
gI_NameLength = MAX_NAME_LENGTH;
|
||||
}
|
||||
@ -111,6 +113,13 @@ public void OnPluginStart()
|
||||
gI_NameLength = 14; // 14 because long names will make it look spammy in CS:GO due to the font
|
||||
}
|
||||
|
||||
if(gEV_Type == Engine_TF2)
|
||||
{
|
||||
HookEvent("player_changeclass", Player_ChangeClass);
|
||||
HookEvent("player_team", Player_ChangeClass);
|
||||
HookEvent("teamplay_round_start", Teamplay_Round_Start);
|
||||
}
|
||||
|
||||
// prevent errors in case the replay bot isn't loaded
|
||||
gB_Replay = LibraryExists("shavit-replay");
|
||||
gB_Zones = LibraryExists("shavit-zones");
|
||||
@ -259,6 +268,7 @@ public void OnClientPutInServer(int client)
|
||||
gI_LastScrollCount[client] = 0;
|
||||
gI_ScrollCount[client] = 0;
|
||||
gBS_Style[client] = Shavit_GetBhopStyle(client);
|
||||
gB_FirstPrint[client] = false;
|
||||
|
||||
if(IsFakeClient(client))
|
||||
{
|
||||
@ -305,6 +315,53 @@ public void OnClientCookiesCached(int client)
|
||||
gBS_Style[client] = Shavit_GetBhopStyle(client);
|
||||
}
|
||||
|
||||
public void Player_ChangeClass(Event event, const char[] name, bool dontBroadcast)
|
||||
{
|
||||
int client = GetClientOfUserId(event.GetInt("userid"));
|
||||
|
||||
if((gI_HUDSettings[client] & HUD_MASTER) > 0 && (gI_HUDSettings[client] & HUD_CENTER) > 0)
|
||||
{
|
||||
CreateTimer(0.5, Timer_FillerHintText, GetClientSerial(client), TIMER_FLAG_NO_MAPCHANGE);
|
||||
}
|
||||
}
|
||||
|
||||
public void Teamplay_Round_Start(Event event, const char[] name, bool dontBroadcast)
|
||||
{
|
||||
CreateTimer(0.5, Timer_FillerHintTextAll, 0, TIMER_FLAG_NO_MAPCHANGE);
|
||||
}
|
||||
|
||||
public Action Timer_FillerHintTextAll(Handle timer, any data)
|
||||
{
|
||||
for(int i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
if(IsClientConnected(i) && IsClientInGame(i))
|
||||
{
|
||||
FillerHintText(i);
|
||||
}
|
||||
}
|
||||
|
||||
return Plugin_Stop;
|
||||
}
|
||||
|
||||
public Action Timer_FillerHintText(Handle timer, any data)
|
||||
{
|
||||
int client = GetClientFromSerial(data);
|
||||
|
||||
if(client != 0)
|
||||
{
|
||||
FillerHintText(client);
|
||||
}
|
||||
|
||||
return Plugin_Stop;
|
||||
}
|
||||
|
||||
void FillerHintText(int client)
|
||||
{
|
||||
PrintHintText(client, "...");
|
||||
gF_ConnectTime[client] = GetEngineTime();
|
||||
gB_FirstPrint[client] = true;
|
||||
}
|
||||
|
||||
public Action Command_HUD(int client, int args)
|
||||
{
|
||||
return ShowHUDMenu(client, 0);
|
||||
@ -393,6 +450,11 @@ public int MenuHandler_HUD(Menu menu, MenuAction action, int param1, int param2)
|
||||
gI_HUDSettings[param1] ^= iSelection;
|
||||
IntToString(gI_HUDSettings[param1], sCookie, 16); // string recycling Kappa
|
||||
|
||||
if(gEV_Type == Engine_TF2 && iSelection == HUD_CENTER && (gI_HUDSettings[param1] & HUD_MASTER) > 0)
|
||||
{
|
||||
FillerHintText(param1);
|
||||
}
|
||||
|
||||
SetClientCookie(param1, gH_HUDCookie, sCookie);
|
||||
|
||||
ShowHUDMenu(param1, GetMenuSelectionPosition());
|
||||
@ -555,7 +617,8 @@ void UpdateHUD(int client)
|
||||
{
|
||||
int target = GetHUDTarget(client);
|
||||
|
||||
if((gI_HUDSettings[client] & HUD_OBSERVE) == 0 && client != target)
|
||||
if(((gI_HUDSettings[client] & HUD_OBSERVE) == 0 && client != target) ||
|
||||
(gEV_Type == Engine_TF2 && (!gB_FirstPrint[target] || GetEngineTime() - gF_ConnectTime[target] < 1.5))) // TF2 has weird handling for hint text
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -743,7 +806,7 @@ void UpdateHUD(int client)
|
||||
|
||||
if(style == -1)
|
||||
{
|
||||
PrintHintText(client, "%T", "NoReplayData", client);
|
||||
PrintHintText(client, "%T", (gEV_Type != Engine_TF2)? "NoReplayData":"NoReplayDataTF2", client);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -19,7 +19,6 @@
|
||||
*/
|
||||
|
||||
#include <sourcemod>
|
||||
#include <cstrike>
|
||||
#include <sdktools>
|
||||
#include <sdkhooks>
|
||||
#include <clientprefs>
|
||||
@ -27,6 +26,9 @@
|
||||
#undef REQUIRE_EXTENSIONS
|
||||
#include <dhooks>
|
||||
#include <SteamWorks>
|
||||
#include <cstrike>
|
||||
#include <tf2>
|
||||
#include <tf2_stocks>
|
||||
|
||||
#undef REQUIRE_PLUGIN
|
||||
#include <shavit>
|
||||
@ -254,12 +256,16 @@ public void OnPluginStart()
|
||||
HookEvent("player_spawn", Player_Spawn);
|
||||
HookEvent("player_team", Player_Notifications, EventHookMode_Pre);
|
||||
HookEvent("player_death", Player_Notifications, EventHookMode_Pre);
|
||||
HookEvent("weapon_fire", Weapon_Fire);
|
||||
HookEventEx("weapon_fire", Weapon_Fire);
|
||||
AddCommandListener(Command_Drop, "drop");
|
||||
AddTempEntHook("Shotgun Shot", Shotgun_Shot);
|
||||
AddTempEntHook("EffectDispatch", EffectDispatch);
|
||||
AddTempEntHook("World Decal", WorldDecal);
|
||||
|
||||
if(gEV_Type != Engine_TF2)
|
||||
{
|
||||
AddTempEntHook("Shotgun Shot", Shotgun_Shot);
|
||||
}
|
||||
|
||||
// phrases
|
||||
LoadTranslations("common.phrases");
|
||||
LoadTranslations("shavit-common.phrases");
|
||||
@ -330,28 +336,31 @@ public void OnPluginStart()
|
||||
AutoExecConfig();
|
||||
|
||||
// crons
|
||||
CreateTimer(1.0, Timer_Scoreboard, 0, TIMER_REPEAT);
|
||||
|
||||
if(LibraryExists("dhooks"))
|
||||
if(gEV_Type != Engine_TF2)
|
||||
{
|
||||
Handle hGameData = LoadGameConfigFile("shavit.games");
|
||||
CreateTimer(1.0, Timer_Scoreboard, 0, TIMER_REPEAT);
|
||||
|
||||
if(hGameData != null)
|
||||
if(LibraryExists("dhooks"))
|
||||
{
|
||||
int iOffset = GameConfGetOffset(hGameData, "GetPlayerMaxSpeed");
|
||||
Handle hGameData = LoadGameConfigFile("shavit.games");
|
||||
|
||||
if(iOffset != -1)
|
||||
if(hGameData != null)
|
||||
{
|
||||
gH_GetPlayerMaxSpeed = DHookCreate(iOffset, HookType_Entity, ReturnType_Float, ThisPointer_CBaseEntity, DHook_GetMaxPlayerSpeed);
|
||||
int iOffset = GameConfGetOffset(hGameData, "GetPlayerMaxSpeed");
|
||||
|
||||
if(iOffset != -1)
|
||||
{
|
||||
gH_GetPlayerMaxSpeed = DHookCreate(iOffset, HookType_Entity, ReturnType_Float, ThisPointer_CBaseEntity, DHook_GetPlayerMaxSpeed);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
SetFailState("Couldn't get the offset for \"GetPlayerMaxSpeed\" - make sure your gamedata is updated!");
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
SetFailState("Couldn't get the offset for \"GetPlayerMaxSpeed\" - make sure your gamedata is updated!");
|
||||
}
|
||||
delete hGameData;
|
||||
}
|
||||
|
||||
delete hGameData;
|
||||
}
|
||||
|
||||
// late load
|
||||
@ -623,45 +632,50 @@ public Action Command_Jointeam(int client, const char[] command, int args)
|
||||
|
||||
switch(iTeam)
|
||||
{
|
||||
case CS_TEAM_T:
|
||||
case 2:
|
||||
{
|
||||
// if T spawns are available in the map
|
||||
if(FindEntityByClassname(-1, "info_player_terrorist") != -1)
|
||||
if(gEV_Type == Engine_TF2 || FindEntityByClassname(-1, "info_player_terrorist") != -1)
|
||||
{
|
||||
bRespawn = true;
|
||||
|
||||
CS_SwitchTeam(client, CS_TEAM_T);
|
||||
CleanSwitchTeam(client, 2);
|
||||
}
|
||||
}
|
||||
|
||||
case CS_TEAM_CT:
|
||||
case 3:
|
||||
{
|
||||
// if CT spawns are available in the map
|
||||
if(FindEntityByClassname(-1, "info_player_counterterrorist") != -1)
|
||||
if(gEV_Type == Engine_TF2 || FindEntityByClassname(-1, "info_player_counterterrorist") != -1)
|
||||
{
|
||||
bRespawn = true;
|
||||
|
||||
CS_SwitchTeam(client, CS_TEAM_CT);
|
||||
CleanSwitchTeam(client, 3);
|
||||
}
|
||||
}
|
||||
|
||||
// if they chose to spectate, i'll force them to join the spectators
|
||||
case CS_TEAM_SPECTATOR:
|
||||
case 1:
|
||||
{
|
||||
ChangeClientTeam(client, CS_TEAM_SPECTATOR);
|
||||
CleanSwitchTeam(client, 1, false);
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
bRespawn = true;
|
||||
|
||||
CS_SwitchTeam(client, GetRandomInt(2, 3));
|
||||
CleanSwitchTeam(client, GetRandomInt(2, 3));
|
||||
}
|
||||
}
|
||||
|
||||
if(gB_RespawnOnTeam && bRespawn)
|
||||
{
|
||||
CS_RespawnPlayer(client);
|
||||
if(gEV_Type == Engine_TF2)
|
||||
{
|
||||
TF2_RespawnPlayer(client);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
CS_RespawnPlayer(client);
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
@ -669,6 +683,24 @@ public Action Command_Jointeam(int client, const char[] command, int args)
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
void CleanSwitchTeam(int client, int team, bool change = false)
|
||||
{
|
||||
if(gEV_Type == Engine_TF2)
|
||||
{
|
||||
TF2_ChangeClientTeam(client, view_as<TFTeam>(team));
|
||||
}
|
||||
|
||||
else if(change)
|
||||
{
|
||||
CS_SwitchTeam(client, team);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
ChangeClientTeam(client, team);
|
||||
}
|
||||
}
|
||||
|
||||
public Action Command_Radio(int client, const char[] command, int args)
|
||||
{
|
||||
if(gB_DisableRadio)
|
||||
@ -679,9 +711,9 @@ public Action Command_Radio(int client, const char[] command, int args)
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
public MRESReturn DHook_GetMaxPlayerSpeed(int pThis, Handle hReturn)
|
||||
public MRESReturn DHook_GetPlayerMaxSpeed(int pThis, Handle hReturn)
|
||||
{
|
||||
if(!gB_StaticPrestrafe && !IsValidClient(pThis, true))
|
||||
if(!gB_StaticPrestrafe || !IsValidClient(pThis, true))
|
||||
{
|
||||
return MRES_Ignored;
|
||||
}
|
||||
@ -768,6 +800,12 @@ public Action Timer_Advertisement(Handle Timer)
|
||||
|
||||
void UpdateScoreboard(int client)
|
||||
{
|
||||
// this doesn't work on tf2 for some reason
|
||||
if(gEV_Type == Engine_TF2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
float fPB = 0.0;
|
||||
Shavit_GetPlayerPB(client, 0, fPB, Track_Main);
|
||||
|
||||
@ -791,6 +829,12 @@ void UpdateScoreboard(int client)
|
||||
|
||||
void UpdateClanTag(int client)
|
||||
{
|
||||
// no clan tags in tf2
|
||||
if(gEV_Type == Engine_TF2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
char[] sTime = new char[16];
|
||||
|
||||
float fTime = Shavit_GetClientTime(client);
|
||||
@ -847,9 +891,9 @@ void RemoveRagdoll(int client)
|
||||
}
|
||||
}
|
||||
|
||||
public Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float vel[3], float angles[3], TimerStatus status, int track)
|
||||
public Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float vel[3], float angles[3], TimerStatus status, int track, int style, any stylesettings[STYLESETTINGS_SIZE])
|
||||
{
|
||||
bool bNoclip = GetEntityMoveType(client) == MOVETYPE_NOCLIP;
|
||||
bool bNoclip = (GetEntityMoveType(client) == MOVETYPE_NOCLIP);
|
||||
|
||||
// i will not be adding a setting to toggle this off
|
||||
if(bNoclip && status == Timer_Running)
|
||||
@ -909,6 +953,11 @@ public void OnClientPutInServer(int client)
|
||||
SDKHook(client, SDKHook_WeaponDrop, OnWeaponDrop);
|
||||
SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
|
||||
|
||||
if(gEV_Type == Engine_TF2)
|
||||
{
|
||||
SDKHook(client, SDKHook_PreThinkPost, OnPreThink);
|
||||
}
|
||||
|
||||
if(IsFakeClient(client))
|
||||
{
|
||||
return;
|
||||
@ -1049,6 +1098,15 @@ public Action OnSetTransmit(int entity, int client)
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
public void OnPreThink(int client)
|
||||
{
|
||||
if(IsPlayerAlive(client))
|
||||
{
|
||||
// not the best method, but only one i found for tf2
|
||||
SetEntPropFloat(client, Prop_Send, "m_flMaxspeed", view_as<float>(gA_StyleSettings[gBS_Style[client]][fRunspeed]));
|
||||
}
|
||||
}
|
||||
|
||||
public Action OnClientSayCommand(int client, const char[] command, const char[] sArgs)
|
||||
{
|
||||
if(IsChatTrigger())
|
||||
@ -1119,7 +1177,7 @@ public Action Command_Spec(int client, int args)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
ChangeClientTeam(client, CS_TEAM_SPECTATOR);
|
||||
CleanSwitchTeam(client, 1, false);
|
||||
|
||||
if(args > 0)
|
||||
{
|
||||
@ -1254,7 +1312,7 @@ bool Teleport(int client, int targetserial)
|
||||
|
||||
public Action Command_Weapon(int client, int args)
|
||||
{
|
||||
if(!IsValidClient(client))
|
||||
if(!IsValidClient(client) || gEV_Type == Engine_TF2)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
}
|
||||
@ -1894,14 +1952,22 @@ public void Shavit_OnRestart(int client)
|
||||
|
||||
if(!IsPlayerAlive(client))
|
||||
{
|
||||
if(FindEntityByClassname(-1, "info_player_terrorist") != -1)
|
||||
if(gEV_Type == Engine_TF2)
|
||||
{
|
||||
CS_SwitchTeam(client, CS_TEAM_T);
|
||||
TF2_ChangeClientTeam(client, view_as<TFTeam>(3));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
CS_SwitchTeam(client, CS_TEAM_CT);
|
||||
if(FindEntityByClassname(-1, "info_player_terrorist") != -1)
|
||||
{
|
||||
CS_SwitchTeam(client, 2);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
CS_SwitchTeam(client, 3);
|
||||
}
|
||||
}
|
||||
|
||||
CreateTimer(0.1, Respawn, GetClientSerial(client), TIMER_FLAG_NO_MAPCHANGE);
|
||||
@ -1912,9 +1978,17 @@ public Action Respawn(Handle Timer, any data)
|
||||
{
|
||||
int client = GetClientFromSerial(data);
|
||||
|
||||
if(IsValidClient(client) && !IsPlayerAlive(client) && GetClientTeam(client) >= CS_TEAM_T)
|
||||
if(IsValidClient(client) && !IsPlayerAlive(client) && GetClientTeam(client) >= 2)
|
||||
{
|
||||
CS_RespawnPlayer(client);
|
||||
if(gEV_Type == Engine_TF2)
|
||||
{
|
||||
TF2_RespawnPlayer(client);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
CS_RespawnPlayer(client);
|
||||
}
|
||||
|
||||
if(gB_RespawnOnRestart)
|
||||
{
|
||||
@ -2001,7 +2075,7 @@ void RemoveRadar(any data)
|
||||
SetEntProp(client, Prop_Send, "m_iHideHUD", GetEntProp(client, Prop_Send, "m_iHideHUD") | (1 << 12)); // disables player radar
|
||||
}
|
||||
|
||||
else
|
||||
else if(gEV_Type == Engine_CSS)
|
||||
{
|
||||
SetEntPropFloat(client, Prop_Send, "m_flFlashDuration", 3600.0);
|
||||
SetEntPropFloat(client, Prop_Send, "m_flFlashMaxAlpha", 0.5);
|
||||
@ -2274,7 +2348,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))
|
||||
if(!gB_DropAll || !IsValidClient(client) || gEV_Type == Engine_TF2)
|
||||
{
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
@ -19,13 +19,16 @@
|
||||
*/
|
||||
|
||||
#include <sourcemod>
|
||||
#include <cstrike>
|
||||
#include <sdktools>
|
||||
#include <sdkhooks>
|
||||
|
||||
#undef REQUIRE_PLUGIN
|
||||
#include <shavit>
|
||||
|
||||
#undef REQUIRE_EXTENSIONS
|
||||
#include <cstrike>
|
||||
#include <tf2>
|
||||
|
||||
#define REPLAY_FORMAT_V2 "{SHAVITREPLAYFORMAT}{V2}"
|
||||
#define REPLAY_FORMAT_FINAL "{SHAVITREPLAYFORMAT}{FINAL}"
|
||||
#define REPLAY_FORMAT_SUBVERSION 0x01 // for compatibility, if i ever update this code again
|
||||
@ -188,7 +191,7 @@ public void OnPluginStart()
|
||||
gCV_Enabled = CreateConVar("shavit_replay_enabled", "1", "Enable replay bot functionality?", 0, true, 0.0, true, 1.0);
|
||||
gCV_ReplayDelay = CreateConVar("shavit_replay_delay", "5.0", "Time to wait before restarting the replay after it finishes playing.", 0, true, 0.0, true, 10.0);
|
||||
gCV_TimeLimit = CreateConVar("shavit_replay_timelimit", "5400.0", "Maximum amount of time (in seconds) to allow saving to disk.\nDefault is 5400.0 (1:30 hours)\n0 - Disabled");
|
||||
gCV_DefaultTeam = CreateConVar("shavit_replay_defaultteam", "3", "Default team to make the bots join, if possible.\n2 - Terrorists\n3 - Counter Terrorists", 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_Enabled.AddChangeHook(OnConVarChanged);
|
||||
@ -587,8 +590,12 @@ public void OnMapStart()
|
||||
return;
|
||||
}
|
||||
|
||||
bot_quota = FindConVar("bot_quota");
|
||||
bot_quota.Flags &= ~FCVAR_NOTIFY;
|
||||
bot_quota = FindConVar((gEV_Type != Engine_TF2)? "bot_quota":"tf_bot_quota");
|
||||
|
||||
if(bot_quota != null)
|
||||
{
|
||||
bot_quota.Flags &= ~FCVAR_NOTIFY;
|
||||
}
|
||||
|
||||
char[] sTempMap = new char[PLATFORM_MAX_PATH];
|
||||
FormatEx(sTempMap, PLATFORM_MAX_PATH, "maps/%s.nav", gS_Map);
|
||||
@ -615,15 +622,59 @@ public void OnMapStart()
|
||||
delete bot_controllable;
|
||||
}
|
||||
|
||||
FindConVar("bot_stop").BoolValue = true;
|
||||
FindConVar("bot_quota_mode").SetString("normal");
|
||||
FindConVar("mp_autoteambalance").BoolValue = false;
|
||||
FindConVar("mp_limitteams").IntValue = 0;
|
||||
FindConVar("bot_join_after_player").BoolValue = false;
|
||||
FindConVar("bot_chatter").SetString("off");
|
||||
FindConVar("bot_zombie").BoolValue = true;
|
||||
ConVar bot_stop = FindConVar("bot_stop");
|
||||
|
||||
ServerCommand("bot_kick");
|
||||
if(bot_stop != null)
|
||||
{
|
||||
bot_stop.BoolValue = true;
|
||||
delete bot_stop;
|
||||
}
|
||||
|
||||
ConVar bot_quota_mode = FindConVar((gEV_Type != Engine_TF2)? "bot_quota_mode":"tf_bot_quota_mode");
|
||||
|
||||
if(bot_quota_mode != null)
|
||||
{
|
||||
bot_quota_mode.SetString("normal");
|
||||
delete bot_quota_mode;
|
||||
}
|
||||
|
||||
ConVar mp_limitteams = FindConVar("mp_limitteams");
|
||||
|
||||
if(mp_limitteams != null)
|
||||
{
|
||||
mp_limitteams.IntValue = 0;
|
||||
delete mp_limitteams;
|
||||
}
|
||||
|
||||
ConVar bot_join_after_player = FindConVar((gEV_Type != Engine_TF2)? "bot_join_after_player":"tf_bot_join_after_player");
|
||||
|
||||
if(bot_join_after_player != null)
|
||||
{
|
||||
bot_join_after_player.BoolValue = false;
|
||||
delete bot_join_after_player;
|
||||
}
|
||||
|
||||
ConVar bot_chatter = FindConVar("bot_chatter");
|
||||
|
||||
if(bot_chatter != null)
|
||||
{
|
||||
bot_chatter.SetString("off");
|
||||
delete bot_chatter;
|
||||
}
|
||||
|
||||
ConVar bot_zombie = FindConVar("bot_zombie");
|
||||
|
||||
if(bot_zombie != null)
|
||||
{
|
||||
bot_zombie.BoolValue = true;
|
||||
delete bot_zombie;
|
||||
}
|
||||
|
||||
ConVar mp_autoteambalance = FindConVar("mp_autoteambalance");
|
||||
mp_autoteambalance.BoolValue = false;
|
||||
delete mp_autoteambalance;
|
||||
|
||||
ServerCommand((gEV_Type != Engine_TF2)? "bot_kick":"tf_bot_kick all");
|
||||
|
||||
gI_ExpectedBots = 0;
|
||||
|
||||
@ -669,7 +720,7 @@ public void OnMapStart()
|
||||
|
||||
if(!gB_CentralBot)
|
||||
{
|
||||
ServerCommand("bot_add");
|
||||
ServerCommand((gEV_Type != Engine_TF2)? "bot_add":"tf_bot_add");
|
||||
gI_ExpectedBots++;
|
||||
|
||||
if(loaded)
|
||||
@ -684,7 +735,7 @@ public void OnMapStart()
|
||||
if(gB_CentralBot)
|
||||
{
|
||||
gI_ExpectedBots = 1;
|
||||
ServerCommand("bot_add");
|
||||
ServerCommand((gEV_Type != Engine_TF2)? "bot_add":"tf_bot_add");
|
||||
}
|
||||
|
||||
CreateTimer(3.0, Cron, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
|
||||
@ -1037,9 +1088,12 @@ void UpdateReplayInfo(int client, int style, float time, int track)
|
||||
bool central = (gA_CentralCache[iCentralClient] == client);
|
||||
bool idle = (central && gA_CentralCache[iCentralReplayStatus] == Replay_Idle);
|
||||
|
||||
char[] sTag = new char[MAX_NAME_LENGTH];
|
||||
FormatStyle(gS_ReplayStrings[sReplayClanTag], style, central, time, track, sTag, MAX_NAME_LENGTH);
|
||||
CS_SetClientClanTag(client, sTag);
|
||||
if(gEV_Type != Engine_TF2)
|
||||
{
|
||||
char[] sTag = new char[MAX_NAME_LENGTH];
|
||||
FormatStyle(gS_ReplayStrings[sReplayClanTag], style, central, time, track, sTag, MAX_NAME_LENGTH);
|
||||
CS_SetClientClanTag(client, sTag);
|
||||
}
|
||||
|
||||
char[] sName = new char[MAX_NAME_LENGTH];
|
||||
int iFrameCount = view_as<int>(gA_FrameCache[style][track][0]);
|
||||
@ -1064,7 +1118,7 @@ void UpdateReplayInfo(int client, int style, float time, int track)
|
||||
CS_SetClientContributionScore(client, iScore);
|
||||
}
|
||||
|
||||
else
|
||||
else if(gEV_Type == Engine_CSS)
|
||||
{
|
||||
SetEntProp(client, Prop_Data, "m_iFrags", iScore);
|
||||
}
|
||||
@ -1085,7 +1139,15 @@ void UpdateReplayInfo(int client, int style, float time, int track)
|
||||
{
|
||||
if(!IsPlayerAlive(client))
|
||||
{
|
||||
CS_RespawnPlayer(client);
|
||||
if(gEV_Type == Engine_TF2)
|
||||
{
|
||||
TF2_RespawnPlayer(client);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
CS_RespawnPlayer(client);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
@ -1099,7 +1161,7 @@ void UpdateReplayInfo(int client, int style, float time, int track)
|
||||
}
|
||||
|
||||
// Spectating is laggy if the player has no weapons
|
||||
if(GetPlayerWeaponSlot(client, CS_SLOT_KNIFE) == -1)
|
||||
if(gEV_Type != Engine_TF2 && GetPlayerWeaponSlot(client, CS_SLOT_KNIFE) == -1)
|
||||
{
|
||||
GivePlayerItem(client, "weapon_knife");
|
||||
}
|
||||
@ -1107,7 +1169,15 @@ void UpdateReplayInfo(int client, int style, float time, int track)
|
||||
|
||||
if(gI_DefaultTeamSlots >= gI_Styles && GetClientTeam(client) != gI_DefaultTeam)
|
||||
{
|
||||
CS_SwitchTeam(client, gI_DefaultTeam);
|
||||
if(gEV_Type == Engine_TF2)
|
||||
{
|
||||
ChangeClientTeam(client, gI_DefaultTeam);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
CS_SwitchTeam(client, gI_DefaultTeam);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1212,7 +1282,16 @@ public void Shavit_OnFinish(int client, int style, float time, int jumps, int st
|
||||
else if(!gB_CentralBot && gI_ReplayBotClient[style] != 0)
|
||||
{
|
||||
UpdateReplayInfo(gI_ReplayBotClient[style], style, time, track);
|
||||
CS_RespawnPlayer(gI_ReplayBotClient[style]);
|
||||
|
||||
if(gEV_Type == Engine_TF2)
|
||||
{
|
||||
TF2_RespawnPlayer(gI_ReplayBotClient[style]);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
CS_RespawnPlayer(gI_ReplayBotClient[style]);
|
||||
}
|
||||
|
||||
gRS_ReplayStatus[style] = Replay_Running;
|
||||
gI_ReplayTick[style] = 0;
|
||||
@ -1498,9 +1577,21 @@ public void Round_Start(Event event, const char[] name, bool dontBroadcast)
|
||||
{
|
||||
gI_DefaultTeamSlots = 0;
|
||||
|
||||
char[] sEntity = new char[32];
|
||||
|
||||
if(gEV_Type == Engine_TF2)
|
||||
{
|
||||
strcopy(sEntity, 32, "info_player_teamspawn");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
strcopy(sEntity, 32, (gI_DefaultTeam == 2)? "info_player_terrorist":"info_player_counterterrorist");
|
||||
}
|
||||
|
||||
int iEntity = -1;
|
||||
|
||||
while((iEntity = FindEntityByClassname(iEntity, (gI_DefaultTeam == 2)? "info_player_terrorist":"info_player_counterterrorist")) != INVALID_ENT_REFERENCE)
|
||||
while((iEntity = FindEntityByClassname(iEntity, sEntity)) != INVALID_ENT_REFERENCE)
|
||||
{
|
||||
gI_DefaultTeamSlots++;
|
||||
}
|
||||
@ -1531,7 +1622,7 @@ public Action Hook_SayText2(UserMsg msg_id, any msg, const int[] players, int pl
|
||||
delete bfmsg;
|
||||
}
|
||||
|
||||
if(StrEqual(sMessage, "#Cstrike_Name_Change"))
|
||||
if(StrEqual(sMessage, "#Cstrike_Name_Change") || StrEqual(sMessage, "#TF_Name_Change"))
|
||||
{
|
||||
gB_HideNameChange = false;
|
||||
|
||||
|
||||
@ -19,12 +19,14 @@
|
||||
*/
|
||||
|
||||
#include <sourcemod>
|
||||
#include <cstrike>
|
||||
#include <geoip>
|
||||
|
||||
#undef REQUIRE_PLUGIN
|
||||
#include <shavit>
|
||||
|
||||
#undef REQUIRE_EXTENSIONS
|
||||
#include <cstrike>
|
||||
|
||||
#pragma newdecls required
|
||||
#pragma semicolon 1
|
||||
|
||||
@ -49,6 +51,7 @@ int gI_Track[MAXPLAYERS+1];
|
||||
char gS_TargetAuth[MAXPLAYERS+1][32];
|
||||
char gS_TargetName[MAXPLAYERS+1][MAX_NAME_LENGTH];
|
||||
int gI_WRAmount[MAXPLAYERS+1];
|
||||
EngineVersion gEV_Type = Engine_Unknown;
|
||||
|
||||
bool gB_Late = false;
|
||||
|
||||
@ -105,6 +108,8 @@ public void OnAllPluginsLoaded()
|
||||
|
||||
public void OnPluginStart()
|
||||
{
|
||||
gEV_Type = GetEngineVersion();
|
||||
|
||||
// player commands
|
||||
RegConsoleCmd("sm_profile", Command_Profile, "Show the player's profile. Usage: sm_profile [target]");
|
||||
RegConsoleCmd("sm_stats", Command_Profile, "Show the player's profile. Usage: sm_profile [target]");
|
||||
@ -119,8 +124,8 @@ public void OnPluginStart()
|
||||
HookEvent("player_team", Player_Event);
|
||||
|
||||
// cvars
|
||||
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.", 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.", 0, true, 0.0, true, 1.0);
|
||||
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);
|
||||
@ -130,6 +135,17 @@ public void OnPluginStart()
|
||||
gB_Rankings = LibraryExists("shavit-rankings");
|
||||
|
||||
SQL_SetPrefix();
|
||||
|
||||
if(gB_Late)
|
||||
{
|
||||
for(int i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
if(IsClientConnected(i) && IsClientInGame(i))
|
||||
{
|
||||
OnClientPutInServer(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnMapStart()
|
||||
@ -262,7 +278,7 @@ public void Player_Event(Event event, const char[] name, bool dontBroadcast)
|
||||
|
||||
int client = GetClientOfUserId(event.GetInt("userid"));
|
||||
|
||||
if(IsValidClient(client) && !IsFakeClient(client))
|
||||
if(IsValidClient(client) && !IsFakeClient(client) && gEV_Type != Engine_TF2)
|
||||
{
|
||||
CS_SetMVPCount(client, gI_WRAmount[client]);
|
||||
}
|
||||
@ -313,7 +329,7 @@ public void SQL_GetWRs_Callback(Database db, DBResultSet results, const char[] e
|
||||
|
||||
int iWRs = results.FetchInt(0);
|
||||
|
||||
if(gI_MVPRankOnes > 0)
|
||||
if(gI_MVPRankOnes > 0 && gEV_Type != Engine_TF2)
|
||||
{
|
||||
CS_SetMVPCount(client, iWRs);
|
||||
}
|
||||
|
||||
@ -21,11 +21,13 @@
|
||||
// original idea from ckSurf.
|
||||
|
||||
#include <sourcemod>
|
||||
#include <cstrike>
|
||||
|
||||
#undef REQUIRE_PLUGIN
|
||||
#include <shavit>
|
||||
|
||||
#undef REQUIRE_EXTENSIONS
|
||||
#include <cstrike>
|
||||
|
||||
#pragma newdecls required
|
||||
#pragma semicolon 1
|
||||
|
||||
@ -62,6 +64,7 @@ bool gB_Style = true;
|
||||
|
||||
// misc cache
|
||||
Handle gH_Timer = null;
|
||||
EngineVersion gEV_Type = Engine_Unknown;
|
||||
|
||||
// table prefix
|
||||
char gS_MySQLPrefix[32];
|
||||
@ -90,6 +93,8 @@ public void OnAllPluginsLoaded()
|
||||
|
||||
public void OnPluginStart()
|
||||
{
|
||||
gEV_Type = GetEngineVersion();
|
||||
|
||||
LoadTranslations("shavit-common.phrases");
|
||||
|
||||
mp_do_warmup_period = FindConVar("mp_do_warmup_period");
|
||||
@ -97,9 +102,12 @@ public void OnPluginStart()
|
||||
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);
|
||||
|
||||
if(mp_roundtime != null)
|
||||
{
|
||||
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);
|
||||
@ -134,7 +142,7 @@ public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] n
|
||||
|
||||
if(convar == gCV_ForceMapEnd)
|
||||
{
|
||||
if(gB_ForceMapEnd)
|
||||
if(gB_ForceMapEnd && gEV_Type != Engine_TF2)
|
||||
{
|
||||
gH_Timer = CreateTimer(1.0, Timer_PrintToChat, 0, TIMER_REPEAT);
|
||||
}
|
||||
@ -184,7 +192,7 @@ public void OnMapStart()
|
||||
SetLimit(RoundToNearest(gF_DefaultLimit));
|
||||
}
|
||||
|
||||
if(gB_ForceMapEnd && gH_Timer == null)
|
||||
if(gB_ForceMapEnd && gH_Timer == null && gEV_Type != Engine_TF2)
|
||||
{
|
||||
gH_Timer = CreateTimer(1.0, Timer_PrintToChat, 0, TIMER_REPEAT);
|
||||
}
|
||||
@ -330,8 +338,12 @@ public void SQL_GetMapTimes(Database db, DBResultSet results, const char[] error
|
||||
void SetLimit(int time)
|
||||
{
|
||||
mp_timelimit.IntValue = time;
|
||||
mp_roundtime.IntValue = time;
|
||||
mp_restartgame.IntValue = 1;
|
||||
|
||||
if(mp_roundtime != null)
|
||||
{
|
||||
mp_roundtime.IntValue = time;
|
||||
}
|
||||
}
|
||||
|
||||
public Action Timer_PrintToChat(Handle Timer)
|
||||
|
||||
@ -21,12 +21,15 @@
|
||||
#include <sourcemod>
|
||||
#include <sdktools>
|
||||
#include <sdkhooks>
|
||||
#include <cstrike>
|
||||
|
||||
#undef REQUIRE_PLUGIN
|
||||
#include <shavit>
|
||||
#include <adminmenu>
|
||||
|
||||
#undef REQUIRE_EXTENSIONS
|
||||
#include <cstrike>
|
||||
#include <tf2>
|
||||
|
||||
#pragma semicolon 1
|
||||
#pragma dynamic 131072
|
||||
#pragma newdecls required
|
||||
@ -210,8 +213,17 @@ public void OnPluginStart()
|
||||
RegAdminCmd("sm_reloadzonesettings", Command_ReloadZoneSettings, ADMFLAG_ROOT, "Reloads the zone settings.");
|
||||
|
||||
// events
|
||||
if(gEV_Type == Engine_TF2)
|
||||
{
|
||||
HookEvent("teamplay_round_start", Round_Start);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
HookEvent("round_start", Round_Start);
|
||||
}
|
||||
|
||||
HookEvent("player_spawn", Player_Spawn);
|
||||
HookEvent("round_start", Round_Start);
|
||||
|
||||
// forwards
|
||||
gH_Forwards_EnterZone = CreateGlobalForward("Shavit_OnEnterZone", ET_Event, Param_Cell, Param_Cell, Param_Cell, Param_Cell, Param_Cell);
|
||||
@ -498,7 +510,7 @@ void LoadZoneSettings()
|
||||
|
||||
else
|
||||
{
|
||||
if(gEV_Type == Engine_CSS)
|
||||
if(IsSource2013(gEV_Type))
|
||||
{
|
||||
gI_BeamSprite = PrecacheModel("sprites/laser.vmt", true);
|
||||
gI_HaloSprite = PrecacheModel("sprites/halo01.vmt", true);
|
||||
@ -529,7 +541,15 @@ public void OnMapStart()
|
||||
|
||||
LoadZoneSettings();
|
||||
|
||||
PrecacheModel("models/props/cs_office/vending_machine.mdl");
|
||||
if(gEV_Type == Engine_TF2)
|
||||
{
|
||||
PrecacheModel("models/error.mdl");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
PrecacheModel("models/props/cs_office/vending_machine.mdl");
|
||||
}
|
||||
|
||||
// draw
|
||||
// start drawing mapzones here
|
||||
@ -1314,7 +1334,16 @@ void ShowPanel(int client, int step)
|
||||
char[] sSecond = new char[64];
|
||||
FormatEx(sFirst, 64, "%T", "ZoneFirst", client);
|
||||
FormatEx(sSecond, 64, "%T", "ZoneSecond", client);
|
||||
FormatEx(sPanelText, 128, "%T", "ZonePlaceText", client, (step == 1)? sFirst:sSecond);
|
||||
|
||||
if(gEV_Type == Engine_TF2)
|
||||
{
|
||||
FormatEx(sPanelText, 128, "%T", "ZonePlaceTextTF2", client, (step == 1)? sFirst:sSecond);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
FormatEx(sPanelText, 128, "%T", "ZonePlaceText", client, (step == 1)? sFirst:sSecond);
|
||||
}
|
||||
|
||||
pPanel.DrawItem(sPanelText, ITEMDRAW_RAWLINE);
|
||||
char[] sPanelItem = new char[64];
|
||||
@ -1476,14 +1505,11 @@ public bool TraceFilter_World(int entity, int contentsMask)
|
||||
|
||||
public Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float vel[3], float angles[3], TimerStatus status)
|
||||
{
|
||||
if(!IsPlayerAlive(client) || IsFakeClient(client))
|
||||
{
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
if(gI_MapStep[client] > 0 && gI_MapStep[client] != 3)
|
||||
{
|
||||
if((buttons & IN_USE) > 0)
|
||||
int button = (gEV_Type == Engine_TF2)? IN_ATTACK2:IN_USE;
|
||||
|
||||
if((buttons & button) > 0)
|
||||
{
|
||||
if(!gB_Button[client])
|
||||
{
|
||||
@ -2358,7 +2384,7 @@ public void CreateZoneEntities()
|
||||
}
|
||||
|
||||
ActivateEntity(entity);
|
||||
SetEntityModel(entity, "models/props/cs_office/vending_machine.mdl");
|
||||
SetEntityModel(entity, (gEV_Type == Engine_TF2)? "models/error.mdl":"models/props/cs_office/vending_machine.mdl");
|
||||
SetEntProp(entity, Prop_Send, "m_fEffects", 32);
|
||||
|
||||
TeleportEntity(entity, gV_ZoneCenter[i], NULL_VECTOR, NULL_VECTOR);
|
||||
@ -2367,7 +2393,7 @@ public void CreateZoneEntities()
|
||||
float distance_y = Abs(gV_MapZones[i][0][1] - gV_MapZones[i][1][1]) / 2;
|
||||
float distance_z = Abs(gV_MapZones[i][0][2] - gV_MapZones[i][1][2]) / 2;
|
||||
|
||||
float height = ((gEV_Type == Engine_CSS)? 62.0:72.0) / 2;
|
||||
float height = ((IsSource2013(gEV_Type))? 62.0:72.0) / 2;
|
||||
|
||||
float min[3];
|
||||
min[0] = -distance_x + 16.0;
|
||||
|
||||
@ -114,6 +114,10 @@
|
||||
{
|
||||
"en" "No replay data loaded\nPress USE or beat #1 to play"
|
||||
}
|
||||
"NoReplayDataTF2"
|
||||
{
|
||||
"en" "No replay data loaded\n!replay or beat #1 to play"
|
||||
}
|
||||
// ---------- Panels ---------- //
|
||||
"SpectatorPersonal"
|
||||
{
|
||||
|
||||
@ -142,6 +142,11 @@
|
||||
"#format" "{1:s}"
|
||||
"en" "Press USE (default 'E') to set the {1} corner in your current position."
|
||||
}
|
||||
"ZonePlaceTextTF2"
|
||||
{
|
||||
"#format" "{1:s}"
|
||||
"en" "Press ATTACK2 (default 'right click') to set the {1} corner in your current position."
|
||||
}
|
||||
"ZonePoint"
|
||||
{
|
||||
"#format" "{1:d},{2:c}"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user