diff --git a/README.md b/README.md index 6f0f1d94..e6273332 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [AlliedModders thread](https://forums.alliedmods.net/showthread.php?t=265456) -[Download](https://github.com/Shavitush/bhoptimer/releases) +[Download](https://github.com/shavitush/bhoptimer/releases) # shavit's simple bhop timer a bhop server should be simple @@ -56,7 +56,7 @@ a bhop server should be simple 2. Copy the desired .smx files to your plugins (addons/sourcemod/plugins) folder 2.1. Copy shavit.games.txt to /gamedata if you have DHooks installed. 3. Copy base.nav to the `maps` folder. -4. Copy the files from the `sound` folder to the one on your server. Make sure to also have equivelant bz2 files on your FastDL server! +4. Copy the files from the `sound` folder to the one on your server. Make sure to also have equivalent bz2 files on your FastDL server! 4.1. Do the same for the `materials` folder. 5. Copy the `configs` file to your server and modify `shavit-sounds.cfg` if you wish to. 5.1. Changing `shavit-prefix.txt` to contain your MySQL database prefix might be needed depending on your usage. diff --git a/scripting/include/shavit.inc b/scripting/include/shavit.inc index 7959c9ad..34d70322 100644 --- a/scripting/include/shavit.inc +++ b/scripting/include/shavit.inc @@ -754,9 +754,9 @@ public SharedPlugin __pl_shavit = name = "shavit", file = "shavit-core.smx", #if defined REQUIRE_PLUGIN - required = 1, + required = 1 #else - required = 0, + required = 0 #endif }; diff --git a/scripting/shavit-core.sp b/scripting/shavit-core.sp index 0399ded8..98ab282d 100644 --- a/scripting/shavit-core.sp +++ b/scripting/shavit-core.sp @@ -82,7 +82,6 @@ bool gB_Late = false; // modules bool gB_Zones = false; -bool gB_HUD = false; // cvars ConVar gCV_Autobhop = null; @@ -254,7 +253,6 @@ public void OnPluginStart() } gB_Zones = LibraryExists("shavit-zones"); - gB_HUD = LibraryExists("shavit-hud"); } public void OnLibraryAdded(const char[] name) @@ -263,11 +261,6 @@ public void OnLibraryAdded(const char[] name) { gB_Zones = true; } - - else if(StrEqual(name, "shavit-hud")) - { - gB_HUD = true; - } } public void OnLibraryRemoved(const char[] name) @@ -276,11 +269,6 @@ public void OnLibraryRemoved(const char[] name) { gB_Zones = false; } - - else if(StrEqual(name, "shavit-hud")) - { - gB_HUD = false; - } } public void OnAdminMenuReady(Handle topmenu) @@ -1166,11 +1154,6 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3 buttons |= IN_JUMP; } - if(gI_ButtonCache[client] != buttons && gB_HUD) - { - Shavit_ForceHUDUpdate(client, true); - } - // velocity limit if(iGroundEntity != -1 && gI_StyleProperties[gBS_Style[client]] & STYLE_VEL_LIMIT && gF_VelocityLimit[gBS_Style[client]] != VELOCITY_UNLIMITED && (!gB_Zones || !Shavit_InsideZone(client, Zone_NoVelLimit))) { diff --git a/scripting/shavit-hud.sp b/scripting/shavit-hud.sp index b575f1f4..6cee7fce 100644 --- a/scripting/shavit-hud.sp +++ b/scripting/shavit-hud.sp @@ -308,9 +308,10 @@ public void TriggerHUDUpdate(int client) { UpdateTopLeftHUD(client, true); UpdateKeyHint(client); + UpdateCenterKeys(client); } - if((gI_HUDSettings[client] & HUD_KEYOVERLAY || gI_HUDSettings[client] & HUD_SPECTATORS) && (!gB_Zones || !Shavit_IsClientCreatingZone(client)) && (GetClientMenu(client, null) == MenuSource_None || GetClientMenu(client, null) == MenuSource_RawPanel)) + else if((gI_HUDSettings[client] & HUD_KEYOVERLAY || gI_HUDSettings[client] & HUD_SPECTATORS) && (!gB_Zones || !Shavit_IsClientCreatingZone(client)) && (GetClientMenu(client, null) == MenuSource_None || GetClientMenu(client, null) == MenuSource_RawPanel)) { bool bShouldDraw = false; Panel pHUD = new Panel(); @@ -576,6 +577,33 @@ public void UpdateKeyOverlay(int client, Panel panel, bool &draw) draw = true; } +public void UpdateCenterKeys(int client) +{ + if(!(gI_HUDSettings[client] & HUD_KEYOVERLAY)) + { + return; + } + + int target = GetHUDTarget(client); + + if((!(gI_HUDSettings[client] & HUD_OBSERVE) && client != target) || !IsValidClient(target) || IsClientObserver(target)) + { + return; + } + + int buttons = GetClientButtons(target); + + if(gI_StyleProperties[Shavit_GetBhopStyle(target)] & STYLE_AUTOBHOP) // don't include [JUMP] for autobhop styles + { + PrintCenterText(client, "[%s]\n %s\n%s %s %s", buttons & IN_DUCK? "DUCK":"----", buttons & IN_FORWARD? "W":"-", buttons & IN_MOVELEFT? "A":"-", buttons & IN_BACK? "S":"-", buttons & IN_MOVERIGHT? "D":"-"); + } + + else + { + PrintCenterText(client, "[%s] [%s]\n %s\n%s %s %s", buttons & IN_JUMP? "JUMP":"----", buttons & IN_DUCK? "DUCK":"----", buttons & IN_FORWARD? "W":"-", buttons & IN_MOVELEFT? "A":"-", buttons & IN_BACK? "S":"-", buttons & IN_MOVERIGHT? "D":"-"); + } +} + public void UpdateSpectatorList(int client, Panel panel, bool &draw) { if(!(gI_HUDSettings[client] & HUD_SPECTATORS)) @@ -671,19 +699,62 @@ public void UpdateKeyHint(int client) { if(gI_Cycle % 10 == 0 && (gI_HUDSettings[client] & HUD_SYNC || gI_HUDSettings[client] & HUD_TIMELEFT)) { - char[] sMessage = new char[128]; + char[] sMessage = new char[256]; int iTimeLeft = -1; if(gI_HUDSettings[client] & HUD_TIMELEFT && GetMapTimeLeft(iTimeLeft) && iTimeLeft > 0) { - FormatEx(sMessage, 128, (iTimeLeft > 60)? "Time left: %d minutes":"Time left: <1 minute", (iTimeLeft / 60)); + FormatEx(sMessage, 256, (iTimeLeft > 60)? "Time left: %d minutes":"Time left: <1 minute", (iTimeLeft / 60)); } int target = GetHUDTarget(client); - if(gI_HUDSettings[client] & HUD_SYNC && Shavit_GetTimerStatus(target) == Timer_Running && gI_StyleProperties[Shavit_GetBhopStyle(target)] & STYLE_MEASURESYNC && !IsFakeClient(target) && (!gB_Zones || !Shavit_InsideZone(target, Zone_Start))) + if(IsValidClient(target) && (target == client || gI_HUDSettings[client] & HUD_OBSERVE)) { - Format(sMessage, 128, "%s%sSync: %.02f", sMessage, (strlen(sMessage) > 0)? "\n\n":"", Shavit_GetSync(target)); + if(gI_HUDSettings[client] & HUD_SYNC && Shavit_GetTimerStatus(target) == Timer_Running && gI_StyleProperties[Shavit_GetBhopStyle(target)] & STYLE_MEASURESYNC && !IsFakeClient(target) && (!gB_Zones || !Shavit_InsideZone(target, Zone_Start))) + { + Format(sMessage, 256, "%s%sSync: %.02f", sMessage, (strlen(sMessage) > 0)? "\n\n":"", Shavit_GetSync(target)); + } + + if(gI_HUDSettings[client] & HUD_SPECTATORS) + { + int[] iSpectatorClients = new int[MaxClients]; + int iSpectators = 0; + + for(int i = 1; i <= MaxClients; i++) + { + if(i == client || !IsValidClient(i) || IsFakeClient(i) || !IsClientObserver(i) || GetEntPropEnt(i, Prop_Send, "m_hObserverTarget") != target) + { + continue; + } + + int iObserverMode = GetEntProp(i, Prop_Send, "m_iObserverMode"); + + if(iObserverMode >= 3 && iObserverMode <= 5) + { + iSpectatorClients[iSpectators++] = i; + } + } + + if(iSpectators > 0) + { + Format(sMessage, 256, "%s%s%spectators (%d):", sMessage, (strlen(sMessage) > 0)? "\n\n":"", (client == target)? "S":"Other s", iSpectators); + + for(int i = 0; i < iSpectators; i++) + { + if(i == 7) + { + Format(sMessage, 256, "%s\n...", sMessage); + + break; + } + + char[] sName = new char[gI_NameLength]; + GetClientName(iSpectatorClients[i], sName, gI_NameLength); + Format(sMessage, 256, "%s\n%s", sMessage, sName); + } + } + } } if(strlen(sMessage) > 0) diff --git a/scripting/shavit-rankings.sp b/scripting/shavit-rankings.sp index e7c5367e..0f08a0a7 100644 --- a/scripting/shavit-rankings.sp +++ b/scripting/shavit-rankings.sp @@ -969,8 +969,6 @@ public void SQL_DBConnect() } } - OnMapStart(); - char[] sDriver = new char[8]; gH_SQL.Driver.GetIdentifier(sDriver, 8); gB_MySQL = StrEqual(sDriver, "mysql", false); diff --git a/scripting/shavit-replay.sp b/scripting/shavit-replay.sp index c55bedfc..5a09e767 100644 --- a/scripting/shavit-replay.sp +++ b/scripting/shavit-replay.sp @@ -433,6 +433,11 @@ public bool DeleteReplay(BhopStyle style) public void OnClientPutInServer(int client) { + if(IsClientSourceTV(client)) + { + return; + } + if(!IsFakeClient(client)) { gA_PlayerFrames[client] = new ArrayList(5); diff --git a/scripting/shavit-wr.sp b/scripting/shavit-wr.sp index fd24127d..34db7b45 100644 --- a/scripting/shavit-wr.sp +++ b/scripting/shavit-wr.sp @@ -391,38 +391,27 @@ public void SQL_UpdateWRCache_Callback(Database db, DBResultSet results, const c public int Native_GetWRTime(Handle handler, int numParams) { - BhopStyle style = GetNativeCell(1); - SetNativeCellRef(2, gF_WRTime[style]); + SetNativeCellRef(2, gF_WRTime[GetNativeCell(1)]); } public int Native_GetWRRecordID(Handle handler, int numParams) { - BhopStyle style = GetNativeCell(1); - SetNativeCellRef(2, gI_WRRecordID[style]); + SetNativeCellRef(2, gI_WRRecordID[GetNativeCell(1)]); } public int Native_GetWRName(Handle handler, int numParams) { - BhopStyle style = GetNativeCell(1); - int maxlength = GetNativeCell(3); - - SetNativeString(2, gS_WRName[style], maxlength); + SetNativeString(2, gS_WRName[GetNativeCell(1)], GetNativeCell(3)); } public int Native_GetPlayerPB(Handle handler, int numParams) { - int client = GetNativeCell(1); - BhopStyle style = GetNativeCell(2); - - SetNativeCellRef(3, gF_PlayerRecord[client][style]); + SetNativeCellRef(3, gF_PlayerRecord[GetNativeCell(1)][GetNativeCell(2)]); } public int Native_GetRankForTime(Handle handler, int numParams) { - BhopStyle style = GetNativeCell(1); - float time = GetNativeCell(2); - - return GetRankForTime(style, time); + return GetRankForTime(GetNativeCell(1), GetNativeCell(2)); } #if defined DEBUG diff --git a/scripting/shavit-zones.sp b/scripting/shavit-zones.sp index fcde88e8..4b64ac21 100644 --- a/scripting/shavit-zones.sp +++ b/scripting/shavit-zones.sp @@ -397,7 +397,7 @@ public void OnMapStart() } } - PrecacheModel("models/props/cs_office/vending_machine.mdl"); // placeholder model + // PrecacheModel("models/props/cs_office/vending_machine.mdl"); // placeholder model // draw // start drawing mapzones here