diff --git a/gamedata/shavit.games.txt b/gamedata/shavit.games.txt new file mode 100644 index 00000000..20a98dc6 --- /dev/null +++ b/gamedata/shavit.games.txt @@ -0,0 +1,26 @@ +"Games" +{ + "cstrike" + { + "Offsets" + { + "GetMaxPlayerSpeed" + { + "windows" "437" + "linux" "438" + } + } + } + + "csgo" + { + "Offsets" + { + "GetMaxPlayerSpeed" + { + "windows" "494" + "linux" "495" + } + } + } +} \ No newline at end of file diff --git a/include/shavit.inc b/scripting/include/shavit.inc similarity index 98% rename from include/shavit.inc rename to scripting/include/shavit.inc index 3af9503b..f1afe9b4 100644 --- a/include/shavit.inc +++ b/scripting/include/shavit.inc @@ -23,11 +23,11 @@ #endif #define _shavit_included -#define SHAVIT_VERSION "1.1b" +#define SHAVIT_VERSION "1.2b" #define PREFIX " \x04[Timer]\x01" #define MAX_STYLES 2 // I could probably do sizeof(BhopStyle) but I suck -#define MAX_ZONES 4 +#define MAX_ZONES 5 // game types enum ServerGame(+=1) @@ -45,12 +45,13 @@ enum BhopStyle(+=1) }; // map zones -enum MapZones +enum MapZones(+=1) { Zone_Start = 0, - Zone_End = 1, - Zone_Respawn = 2, - Zone_Stop = 3 + Zone_End, + Zone_Respawn, + Zone_Stop, + Zone_Slay }; // let's not throw errors k? diff --git a/shavit-core.sp b/scripting/shavit-core.sp similarity index 100% rename from shavit-core.sp rename to scripting/shavit-core.sp diff --git a/shavit-hud.sp b/scripting/shavit-hud.sp similarity index 100% rename from shavit-hud.sp rename to scripting/shavit-hud.sp diff --git a/shavit-misc.sp b/scripting/shavit-misc.sp similarity index 81% rename from shavit-misc.sp rename to scripting/shavit-misc.sp index e98abfb9..374ed8ab 100644 --- a/shavit-misc.sp +++ b/scripting/shavit-misc.sp @@ -24,6 +24,9 @@ #include #include +#undef REQUIRE_EXTENSIONS +#include + #pragma semicolon 1 #pragma dynamic 131072 // let's make stuff faster #pragma newdecls required // We're at 2015 :D @@ -31,6 +34,13 @@ bool gB_Hide[MAXPLAYERS+1]; bool gB_Late; +// cvars +ConVar gCV_GodMode = null; +int gI_GodMode = 3; + +// dhooks +Handle gH_GetMaxPlayerSpeed = null; + public Plugin myinfo = { name = "[shavit] Miscellaneous", @@ -83,7 +93,27 @@ public void OnPluginStart() LogError("idk what's wrong but for some reason, your CS:GO server is missing the \"mp_death_drop_gun\" cvar. go find what's causing it because I dunno"); } } - + + // 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."); + HookConVarChange(gCV_GodMode, OnConVarChanged); + + AutoExecConfig(); + gI_GodMode = GetConVarInt(gCV_GodMode); + + if(LibraryExists("dhooks")) + { + Handle hGameData = LoadGameConfigFile("shavit.games"); + + if(hGameData != null) + { + int iOffset = GameConfGetOffset(hGameData, "GetMaxPlayerSpeed"); + gH_GetMaxPlayerSpeed = DHookCreate(iOffset, HookType_Entity, ReturnType_Float, ThisPointer_CBaseEntity, DHook_GetMaxPlayerSpeed); + } + + CloseHandle(hGameData); + } + // late load if(gB_Late) { @@ -97,6 +127,27 @@ public void OnPluginStart() } } +public void OnConVarChanged(ConVar cvar, const char[] sOld, const char[] sNew) +{ + // using an if() statement just incase I'll add more cvars. + if(cvar == gCV_GodMode) + { + gI_GodMode = StringToInt(sNew); + } +} + +public MRESReturn DHook_GetMaxPlayerSpeed(int pThis, Handle hReturn) +{ + if(IsValidClient(pThis, true)) + { + DHookSetReturn(hReturn, 250.000); + + return MRES_Override; + } + + return MRES_Ignored; +} + public Action Timer_Message(Handle Timer) { PrintToChatAll("%s You may write !hide to hide other players.", PREFIX); @@ -154,11 +205,44 @@ public void OnClientPutInServer(int client) SDKHook(client, SDKHook_SetTransmit, OnSetTransmit); SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage); + + if(gH_GetMaxPlayerSpeed != null) + { + DHookEntity(gH_GetMaxPlayerSpeed, true, client); + } } -public Action OnTakeDamage(int victim) +public Action OnTakeDamage(int victim, int attacker) { - return Plugin_Handled; + switch(gI_GodMode) + { + case 0: + { + return Plugin_Continue; + } + + case 1: + { + // 0 - world/fall damage + if(attacker == 0) + { + return Plugin_Handled; + } + } + + case 2: + { + if(IsValidClient(attacker, true)) + { + return Plugin_Handled; + } + } + + // else + default: return Plugin_Handled; + } + + return Plugin_Continue; } // hide diff --git a/shavit-wr.sp b/scripting/shavit-wr.sp similarity index 100% rename from shavit-wr.sp rename to scripting/shavit-wr.sp diff --git a/shavit-zones.sp b/scripting/shavit-zones.sp similarity index 95% rename from shavit-zones.sp rename to scripting/shavit-zones.sp index ee954be5..3b279bab 100644 --- a/shavit-zones.sp +++ b/scripting/shavit-zones.sp @@ -39,7 +39,8 @@ char gS_ZoneNames[MAX_ZONES][] = "Start Zone", "End Zone", "Glitch Zone (Respawn Player)", - "Glitch Zone (Stop Timer)" + "Glitch Zone (Stop Timer)", + "Slay Player" }; MapZones gMZ_Type[MAXPLAYERS+1]; @@ -67,6 +68,10 @@ Handle gH_AdminMenu = INVALID_HANDLE; bool gB_Late; +// cvars +ConVar gCV_ZoneStyle = null; +bool gB_ZoneStyle = false; + public Plugin myinfo = { name = "[shavit] Map Zones", @@ -117,6 +122,22 @@ public void OnPluginStart() { OnAdminMenuReady(null); } + + // cvars and stuff + gCV_ZoneStyle = CreateConVar("shavit_zones_style", "0", "Style for mapzone drawing.\n0 - 3D box\n1 - 2D box"); + HookConVarChange(gCV_ZoneStyle, OnConVarChanged); + + AutoExecConfig(); + gB_ZoneStyle = GetConVarBool(gCV_ZoneStyle); +} + +public void OnConVarChanged(ConVar cvar, const char[] sOld, const char[] sNew) +{ + // using an if() statement just incase I'll add more cvars. + if(cvar == gCV_ZoneStyle) + { + gB_ZoneStyle = view_asStringToInt(sNew); + } } public void OnAdminMenuReady(Handle topmenu) @@ -212,6 +233,7 @@ public void SetupColors() // glitches - invisible but orange for placement gI_Colors[Zone_Respawn] = {255, 200, 0, 255}; gI_Colors[Zone_Stop] = {255, 200, 0, 255}; + gI_Colors[Zone_Slay] = {255, 200, 0, 255}; } public void OnMapStart() @@ -618,6 +640,13 @@ public Action OnPlayerRunCmd(int client, int &buttons) if(bStarted) { + if(InsideZone(client, gV_MapZones[Zone_Slay][0], gV_MapZones[Zone_Slay][1])) + { + Shavit_StopTimer(client); + + ForcePlayerSuicide(client); + } + if(InsideZone(client, gV_MapZones[Zone_Stop][0], gV_MapZones[Zone_Stop][1])) { Shavit_StopTimer(client); @@ -715,6 +744,11 @@ public Action Timer_DrawEverything(Handle Timer, any data) vPoints[0] = gV_MapZones[i][0]; vPoints[7] = gV_MapZones[i][1]; + if(gB_ZoneStyle) + { + vPoints[7][2] = vPoints[0][2]; + } + CreateZonePoints(vPoints); DrawZone(0, vPoints, gI_BeamSprite, 0, gI_Colors[i], 0.10);