From d61cc39210f13ec332a766b172eb62311e80f1d3 Mon Sep 17 00:00:00 2001 From: Zipcore Date: Fri, 28 Aug 2015 16:40:42 +0200 Subject: [PATCH 1/5] Part I --- .../scripting/simple-chatprocessor.sp | 2 + .../addons/sourcemod/scripting/timer-core.sp | 24 +- .../addons/sourcemod/scripting/timer-cpmod.sp | 1 + .../scripting/timer-finish_msg_csgo.sp | 233 +-- .../sourcemod/scripting/timer-ljstats.sp | 6 +- .../sourcemod/scripting/timer-maptier.sp | 66 +- .../sourcemod/scripting/timer-mapzones.sp | 1830 +++++++++-------- .../timer-mapzones_startzone_nojump.sp | 23 +- .../addons/sourcemod/scripting/timer-menu.sp | 70 +- .../addons/sourcemod/scripting/timer-mysql.sp | 144 +- .../sourcemod/scripting/timer-online_db.sp | 36 +- .../sourcemod/scripting/timer-physics.sp | 728 +++---- .../sourcemod/scripting/timer-rankings.sp | 31 +- .../addons/sourcemod/scripting/timer-sound.sp | 151 +- .../addons/sourcemod/scripting/timer-spec.sp | 66 +- .../addons/sourcemod/scripting/timer-teams.sp | 365 ++-- .../sourcemod/scripting/timer-teleme.sp | 37 +- .../sourcemod/scripting/timer-worldrecord.sp | 1056 +++++----- .../scripting/timer-worldrecord_latest.sp | 96 +- .../scripting/timer-worldrecord_maptop.sp | 177 +- .../scripting/timer-worldrecord_playerinfo.sp | 243 +-- 21 files changed, 2689 insertions(+), 2696 deletions(-) diff --git a/gameserver/addons/sourcemod/scripting/simple-chatprocessor.sp b/gameserver/addons/sourcemod/scripting/simple-chatprocessor.sp index 4dc9e62..33a59bc 100644 --- a/gameserver/addons/sourcemod/scripting/simple-chatprocessor.sp +++ b/gameserver/addons/sourcemod/scripting/simple-chatprocessor.sp @@ -34,6 +34,8 @@ $Copyright: (c) Simple Plugins 2008-2009$ ************************************************************************* */ +#pragma dynamic 131072 + #include #define PLUGIN_VERSION "2.0.2 (modified by Zipcore)" diff --git a/gameserver/addons/sourcemod/scripting/timer-core.sp b/gameserver/addons/sourcemod/scripting/timer-core.sp index b341cb2..2b61206 100644 --- a/gameserver/addons/sourcemod/scripting/timer-core.sp +++ b/gameserver/addons/sourcemod/scripting/timer-core.sp @@ -47,7 +47,6 @@ enum Timer CurrentStyle, FpsMax, Track, - bool:ShortEndReached, String:ReplayFile[32] } @@ -289,6 +288,14 @@ public OnMapStart() LoadPhysics(); LoadTimerSettings(); + + for (new client = 1; client <= MaxClients; client++) + g_timers[client][Track] = TRACK_NORMAL; +} + +public OnClientPutInServer(client) +{ + g_timers[client][Track] = TRACK_NORMAL; } /** @@ -411,7 +418,6 @@ bool:ResetTimer(client) g_timers[client][IsPaused] = false; g_timers[client][PauseStartTime] = 0.0; g_timers[client][PauseTotalTime] = 0.0; - g_timers[client][ShortEndReached] = false; g_timers[client][ReplayFile][0] = '\0'; if(g_timerPhysics) Timer_ResetAccuracy(client); @@ -434,7 +440,6 @@ bool:StartTimer(client) return false; g_timers[client][Enabled] = true; - g_timers[client][ShortEndReached] = false; g_timers[client][StartTime] = GetGameTime(); g_timers[client][EndTime] = -1.0; g_timers[client][Jumps] = 0; @@ -470,7 +475,6 @@ bool:StopTimer(client, bool:stopPaused = true) //Get time g_timers[client][Enabled] = false; - g_timers[client][ShortEndReached] = true; g_timers[client][EndTime] = GetGameTime(); //Prevent Resume @@ -551,7 +555,7 @@ bool:PauseTimer(client) Array_Copy(angles, g_timers[client][PauseLastAngles], 3); new Float:velocity[3]; - GetClientAbsVelocity(client, velocity); + GetEntPropVector(client, Prop_Data, "m_vecVelocity", velocity); Array_Copy(velocity, g_timers[client][PauseLastVelocity], 3); Call_StartForward(g_timerPausedForward); @@ -695,11 +699,7 @@ FinishRound(client, const String:map[], Float:time, jumps, style, fpsmax, track) if(g_timerPhysics) if (g_Physics[style][StyleCategory] != MCategory_Ranked || !(bool:Timer_IsStyleRanked(style))) return; - - //short end already triggered - if (g_timers[client][ShortEndReached] && track == 2) - return; - + new flashbangcount; //TODO new stage; @@ -725,9 +725,7 @@ FinishRound(client, const String:map[], Float:time, jumps, style, fpsmax, track) return; } } - - if(track == TRACK_SHORT) g_timers[client][ShortEndReached] = true; - + //Record Info new RecordId; new Float:RecordTime; diff --git a/gameserver/addons/sourcemod/scripting/timer-cpmod.sp b/gameserver/addons/sourcemod/scripting/timer-cpmod.sp index cd932f6..bfab741 100644 --- a/gameserver/addons/sourcemod/scripting/timer-cpmod.sp +++ b/gameserver/addons/sourcemod/scripting/timer-cpmod.sp @@ -6,6 +6,7 @@ #undef REQUIRE_PLUGIN #include #include +#include #include #undef REQUIRE_EXTENSIONS diff --git a/gameserver/addons/sourcemod/scripting/timer-finish_msg_csgo.sp b/gameserver/addons/sourcemod/scripting/timer-finish_msg_csgo.sp index 950c049..7e8f4a0 100644 --- a/gameserver/addons/sourcemod/scripting/timer-finish_msg_csgo.sp +++ b/gameserver/addons/sourcemod/scripting/timer-finish_msg_csgo.sp @@ -84,112 +84,110 @@ public OnTimerRecord(client, track, style, Float:time, Float:lasttime, currentra { decl String:name[MAX_NAME_LENGTH]; GetClientName(client, name, sizeof(name)); - + + //General Info + new Float:fWrTime; + new iTotalRanks; + //Record Info - new RecordId; - new Float:RecordTime; - new RankTotal; - new Float:LastTime; - new Float:LastTimeStatic; - new LastJumps; - decl String:TimeDiff[32]; - decl String:buffer[32]; - - new bool:NewPersonalRecord = false; - new bool:NewWorldRecord = false; - new bool:FirstRecord = false; - - new bool:ranked, Float:jumpacc; - if(g_timerPhysics) + decl String:sTime[64]; + + new Float:fTimeDiff; + new iStrafeCount; + new Float:fJumpAcc; + new bool:bRankedStyle; + + new bool:bNewPersonalRecord; + new bool:bNewWorldRecord; + new bool:bFirstRecord; + new bool:bOnlyTimeImproved; + + // Core + new bool:enabled = false, jumps, fpsmax; + Timer_SecondsToTime(time, sTime, sizeof(sTime), 2); + new Float:fTimeOld; + Timer_GetClientTimer(client, enabled, fTimeOld, jumps, fpsmax); + + // Physics + if(g_timerPhysics) { - ranked = bool:Timer_IsStyleRanked(style); - Timer_GetJumpAccuracy(client, jumpacc); + bRankedStyle = bool:Timer_IsStyleRanked(style); + Timer_GetJumpAccuracy(client, fJumpAcc); } - - new strafes; - if(g_timerStrafes) strafes = Timer_GetStrafeCount(client); - - new bool:enabled = false; - new jumps = 0; - new fpsmax; + // Strafes + if(g_timerStrafes) + { + iStrafeCount = Timer_GetStrafeCount(client); + } - Timer_GetClientTimer(client, enabled, time, jumps, fpsmax); - - if(g_timerWorldRecord) + if(g_timerWorldRecord) { /* Get Personal Record */ - if(Timer_GetBestRound(client, style, track, LastTime, LastJumps)) + if(lasttime > 0.0) { - LastTimeStatic = LastTime; - LastTime -= time; - if(LastTime < 0.0) - { - LastTime *= -1.0; - Timer_SecondsToTime(LastTime, buffer, sizeof(buffer), 3); - FormatEx(TimeDiff, sizeof(TimeDiff), "+%s", buffer); - } - else if(LastTime > 0.0) - { - Timer_SecondsToTime(LastTime, buffer, sizeof(buffer), 3); - FormatEx(TimeDiff, sizeof(TimeDiff), "-%s", buffer); - } - else if(LastTime == 0.0) - { - Timer_SecondsToTime(LastTime, buffer, sizeof(buffer), 3); - FormatEx(TimeDiff, sizeof(TimeDiff), "%s", buffer); - } + fTimeDiff = lasttime-time; + + if(fTimeDiff < 0.0) + fTimeDiff *= -1.0; } else { //No personal record, this is his first record - FirstRecord = true; - LastTime = 0.0; - Timer_SecondsToTime(LastTime, buffer, sizeof(buffer), 3); - FormatEx(TimeDiff, sizeof(TimeDiff), "%s", buffer); - RankTotal++; + bFirstRecord = true; + fTimeDiff = 0.0; + iTotalRanks++; } } - - decl String:TimeString[32]; - Timer_SecondsToTime(time, TimeString, sizeof(TimeString), 2); - - new String:WrName[32], String:WrTime[32]; - new Float:wrtime; - - if(g_timerWorldRecord) + + new String:sBeatenName[32], String:sBeatenTime[32]; + new Float:fBeatenTime; + + if(g_timerWorldRecord) { - Timer_GetRecordTimeInfo(style, track, newrank, wrtime, WrTime, 32); - Timer_GetRecordHolderName(style, track, newrank, WrName, 32); - + Timer_GetRecordTimeInfo(style, track, newrank, fBeatenTime, sBeatenTime, 32); + Timer_GetRecordHolderName(style, track, newrank, sBeatenName, 32); + /* Get World Record */ - Timer_GetStyleRecordWRStats(style, track, RecordId, RecordTime, RankTotal); + new RecordId; + Timer_GetStyleRecordWRStats(style, track, RecordId, fWrTime, iTotalRanks); } + new Float:fWRDiffTime; + new String:sWrDiffTime[32]; + + fWRDiffTime = time-fWrTime; + Timer_SecondsToTime(fWRDiffTime, sWrDiffTime, sizeof(sWrDiffTime), 2); + + if(fWrTime <= 0.0) + Format(sWrDiffTime, sizeof(sWrDiffTime), "-%s", sWrDiffTime); + else if(fWrTime <= time) + Format(sWrDiffTime, sizeof(sWrDiffTime), "+%s", sWrDiffTime); + else Format(sWrDiffTime, sizeof(sWrDiffTime), "-%s", sWrDiffTime); + + //PrintToChat(client, "[DEBUG] %.2f - %.2f = %.2f", time, fWrTime, fWRDiffTime); + //PrintToChat(client, "[DEBUG] %s", sWrDiffTime); + /* Detect Record Type */ - if(RecordTime == 0.0 || time < RecordTime) + if(fWrTime == 0.0 || time < fWrTime) { - NewWorldRecord = true; + bNewWorldRecord = true; } - - if(LastTimeStatic == 0.0 || time < LastTimeStatic) + + if(lasttime == 0.0 || time < lasttime) { - NewPersonalRecord = true; + bNewPersonalRecord = true; } - - new bool:self = false; - + if(currentrank == newrank) - { - self = true; - } - - if(FirstRecord) RankTotal++; - - new Float:wrdiff = time-wrtime; - + bOnlyTimeImproved = true; + + if(bFirstRecord) iTotalRanks++; + + new Float:fBeatenTimeDiff = time-fBeatenTime; + new String:BonusString[32]; - + if(track == TRACK_BONUS) { FormatEx(BonusString, sizeof(BonusString), " {olive}bonus"); @@ -210,82 +208,79 @@ public OnTimerRecord(client, track, style, Float:time, Float:lasttime, currentra { FormatEx(BonusString, sizeof(BonusString), " {olive}bonus5"); } - + new String:RankString[128], String:RankPwndString[128]; - new String:JumpString[128]; + new String:sJumps[128]; new bool:bAll = false; - + new String:StyleString[128]; - if(g_Settings[MultimodeEnable]) + if(g_Settings[MultimodeEnable]) FormatEx(StyleString, sizeof(StyleString), " on {olive}%s", g_Physics[style][StyleName]); - - if(NewWorldRecord) + + if(bNewWorldRecord) { bAll = true; - FormatEx(RankString, sizeof(RankString), "{purple}NEW WORLD RECORD"); - - if(wrtime > 0.0) + FormatEx(RankString, sizeof(RankString), "{purple} NEW MAP RECORD"); + + if(fBeatenTime > 0.0) { - if(self) - FormatEx(RankPwndString, sizeof(RankPwndString), "{olive}Improved {lightred}%s{olive}! {lightred}[%.2fs]{olive} diff, old time was {lightred}[%s]", "himself", wrdiff, WrTime); + if(bOnlyTimeImproved) + FormatEx(RankPwndString, sizeof(RankPwndString), "{olive}Improved {lightred}%s{olive}! {lightred}[%.2fs]{olive} diff, old time was {lightred}[%s]", "himself", fBeatenTimeDiff, sBeatenTime); else - FormatEx(RankPwndString, sizeof(RankPwndString), "{olive}Beaten {lightred}%s{olive}! {lightred}[%.2fs]{olive} diff, old time was {lightred}[%s]", WrName, wrdiff, WrTime); + FormatEx(RankPwndString, sizeof(RankPwndString), "{olive}Beaten {lightred}%s{olive}! {lightred}[%.2fs]{olive} diff, old time was {lightred}[%s]", sBeatenName, fBeatenTimeDiff, sBeatenTime); } } - else if(newrank > 5000) - { - FormatEx(RankString, sizeof(RankString), "{lightred}#%d+ / %d", newrank, RankTotal); - } - else if(NewPersonalRecord || FirstRecord) + else if(bNewPersonalRecord || bFirstRecord) { bAll = true; - FormatEx(RankString, sizeof(RankString), "{lightred}#%d / %d", newrank, RankTotal); - - if(newrank < currentrank) FormatEx(RankPwndString, sizeof(RankPwndString), "{olive}Beaten {lightred}%s{olive}! {lightred}[%.2fs]{olive} diff, old time was {lightred}[%s]", WrName, wrdiff, WrTime); - } - else if(NewPersonalRecord) + FormatEx(RankString, sizeof(RankString), "{lightred}#%d / %d", newrank, iTotalRanks); + + if(newrank < currentrank) + FormatEx(RankPwndString, sizeof(RankPwndString), "{olive}Beaten {lightred}%s{olive}! {lightred}[%.2fs]{olive} diff, old time was {lightred}[%s]", sBeatenName, fBeatenTimeDiff, sBeatenTime); + } + else if(bNewPersonalRecord) { - FormatEx(RankString, sizeof(RankString), "{orange}#%d / %d", newrank, RankTotal); - - Format(RankPwndString, sizeof(RankPwndString), "You have improved {lightred}yourself! {lightred}[%.2fs]{olive} diff, old time was {lightred}[%s]", wrdiff, WrTime); + FormatEx(RankString, sizeof(RankString), "{orange}#%d / %d", newrank, iTotalRanks); + + Format(RankPwndString, sizeof(RankPwndString), "You have improved {lightred}yourself! {lightred}[%.2fs]{olive} diff, old time was {lightred}[%s]", fBeatenTimeDiff, sBeatenTime); } - + if(g_Settings[JumpsEnable]) { - FormatEx(JumpString, sizeof(JumpString), "{olive} and {lightred}%d jumps [%.2f ⁰⁄₀]", jumps, jumpacc); + FormatEx(sJumps, sizeof(sJumps), "{olive} and {lightred}%d jumps [%.2f ⁰⁄₀]", jumps, fJumpAcc); } - - if(g_Settings[StrafesEnable]) + + if(g_Settings[StrafesEnable] && g_timerStrafes) { - FormatEx(JumpString, sizeof(JumpString), "{olive} and {lightred}%d strafes", strafes); + FormatEx(sJumps, sizeof(sJumps), "{olive} and {lightred}%d strafes", iStrafeCount); } - - if(ranked) + + if(bRankedStyle) { - if(FirstRecord || NewPersonalRecord) + if(bFirstRecord || bNewPersonalRecord) { if(bAll) { - CPrintToChatAll("%s {olive}Player {lightred}%s{olive} has finished%s{olive}%s{olive}.", PLUGIN_PREFIX2, name, BonusString, StyleString); - CPrintToChatAll("{olive}Time: {lightred}[%ss] %s %s", TimeString, JumpString, RankString); + CPrintToChatAll("%s {lightred}%s{olive} has finished%s{olive}%s{olive}.", PLUGIN_PREFIX2, name, BonusString, StyleString); + CPrintToChatAll("{olive}Time: {lightred}%ss (WR %s) %s %s", sTime, sWrDiffTime, sJumps, RankString); CPrintToChatAll("%s", RankPwndString); } else { CPrintToChat(client, "%s {lightred}You{olive} have finished%s{olive}%s{olive}.", PLUGIN_PREFIX2, BonusString, StyleString); - CPrintToChat(client, "{olive}Time: {lightred}[%ss] %s %s", TimeString, JumpString, RankString); + CPrintToChat(client, "{olive}Time: {lightred}%ss (WR %s) %s %s", sTime, sWrDiffTime, sJumps, RankString); CPrintToChat(client, "%s", RankPwndString); } } else { - CPrintToChat(client, "%s {lightred}You{olive} have finished%s{olive}%s{olive}. Time: {lightred}[%ss] %s %s", PLUGIN_PREFIX2, BonusString, StyleString, TimeString, JumpString, RankString); + CPrintToChat(client, "%s {lightred}You{olive} have finished%s{olive}%s{olive}. Time: {lightred}%ss (WR %s) %s %s", PLUGIN_PREFIX2, BonusString, StyleString, sTime, sWrDiffTime, sJumps, RankString); } } else { CPrintToChat(client, "{lightred}You{olive} have finished%s{olive}%s{olive}.", PLUGIN_PREFIX2, BonusString, StyleString); - CPrintToChat(client, "{olive}Time: {lightred}[%ss] %s", TimeString, JumpString); + CPrintToChat(client, "{olive}Time: {lightred}[%ss] %s", sTime, sJumps); } } diff --git a/gameserver/addons/sourcemod/scripting/timer-ljstats.sp b/gameserver/addons/sourcemod/scripting/timer-ljstats.sp index a6161d8..4d06688 100644 --- a/gameserver/addons/sourcemod/scripting/timer-ljstats.sp +++ b/gameserver/addons/sourcemod/scripting/timer-ljstats.sp @@ -1827,7 +1827,11 @@ RecordQuery(client, JumpType:type, Float:distance, Float:pre, strafe) decl String:query[512], String:steamid[64], String:temp[64], String:name[64]; GetClientName(client, temp, sizeof(temp)); SQL_EscapeString(maindb, temp, name, sizeof(name)); - GetClientAuthString(client, steamid, sizeof(steamid)); + #if SOURCEMOD_V_MAJOR >= 1 && SOURCEMOD_V_MINOR >= 7 + GetClientAuthId(client, AuthId_Steam2, steamid, sizeof(steamid)); + #else + GetClientAuthString(client, steamid, sizeof(steamid)); + #endif Format(query, sizeof(query), "select distance from 'ljstats' where steamid = '%s' and type = %d", steamid, type); new Handle:datapack = CreateDataPack(); WritePackString(datapack, steamid); diff --git a/gameserver/addons/sourcemod/scripting/timer-maptier.sp b/gameserver/addons/sourcemod/scripting/timer-maptier.sp index 99109c0..ade0248 100644 --- a/gameserver/addons/sourcemod/scripting/timer-maptier.sp +++ b/gameserver/addons/sourcemod/scripting/timer-maptier.sp @@ -121,28 +121,23 @@ public LoadTierCallback(Handle:owner, Handle:hndl, const String:error[], any:dat Timer_LogError("SQL Error on LoadTier: %s", error); return; } - + while (SQL_FetchRow(hndl)) { new track = SQL_FetchInt(hndl, 0); g_maptier[track] = 0; g_maptier[track] = SQL_FetchInt(hndl, 1); g_stagecount[track] = SQL_FetchInt(hndl, 2); - + } + + for (new track = 0; track < MAX_TRACKS; track++) + { if (g_maptier[track] == 0) { - decl String:query[128]; - FormatEx(query, sizeof(query), "INSERT IGNORE INTO maptier (map, track, tier, stagecount) VALUES ('%s','%d','1', '1');", g_currentMap, track); - - if (g_hSQL == INVALID_HANDLE) - ConnectSQL(); - - if (g_hSQL != INVALID_HANDLE) - { - SQL_TQuery(g_hSQL, InsertTierCallback, query, track, DBPrio_Normal); - } - g_maptier[track] = 1; + decl String:query[128]; + FormatEx(query, sizeof(query), "INSERT IGNORE INTO maptier (map, track, tier, stagecount) VALUES ('%s','%d','%d', '%d');", g_currentMap, track, g_maptier[track], GetStageCount(track, false)); + SQL_TQuery(g_hSQL, InsertTierCallback, query, track, DBPrio_Normal); } } } @@ -315,29 +310,17 @@ public Native_GetMapTier(Handle:plugin, numParams) if(KvJumpToKey(hMaps, map, false)) { if(track == TRACK_NORMAL) - { tier = KvGetNum(hMaps, "tier"); - } else if(track == TRACK_BONUS) - { tier = KvGetNum(hMaps, "tier_bonus"); - } else if(track == TRACK_BONUS2) - { tier = KvGetNum(hMaps, "tier_bonus2"); - } else if(track == TRACK_BONUS3) - { tier = KvGetNum(hMaps, "tier_bonus3"); - } else if(track == TRACK_BONUS4) - { tier = KvGetNum(hMaps, "tier_bonus4"); - } else if(track == TRACK_BONUS5) - { tier = KvGetNum(hMaps, "tier_bonus5"); - } } CloseHandle(hMaps); @@ -363,38 +346,30 @@ public Native_GetMapStageCount(Handle:plugin, numParams) if(KvJumpToKey(hMaps, map, false)) { if(track == TRACK_NORMAL) - { stagecount = KvGetNum(hMaps, "stagecount"); - } else if(track == TRACK_BONUS) - { stagecount = KvGetNum(hMaps, "stagecount_bonus"); - } else if(track == TRACK_BONUS2) - { stagecount = KvGetNum(hMaps, "stagecount_bonus2"); - } else if(track == TRACK_BONUS3) - { stagecount = KvGetNum(hMaps, "stagecount_bonus3"); - } else if(track == TRACK_BONUS4) - { stagecount = KvGetNum(hMaps, "stagecount_bonus4"); - } else if(track == TRACK_BONUS5) - { stagecount = KvGetNum(hMaps, "stagecount_bonus5"); - } } CloseHandle(hMaps); - + return stagecount; } public Native_UpdateStageCount(Handle:plugin, numParams) { - new track = GetNativeCell(1); + return GetStageCount(GetNativeCell(1), true); +} + +GetStageCount(track, bool:update_sql = false) +{ if(track == TRACK_NORMAL) g_stagecount[track] = Timer_GetMapzoneCount(ZtLevel)+1; else if(track == TRACK_BONUS) @@ -407,10 +382,13 @@ public Native_UpdateStageCount(Handle:plugin, numParams) g_stagecount[track] = Timer_GetMapzoneCount(ZtBonus4Level)+1; else if(track == TRACK_BONUS5) g_stagecount[track] = Timer_GetMapzoneCount(ZtBonus5Level)+1; - - decl String:query[256]; - FormatEx(query, sizeof(query), "UPDATE maptier SET stagecount = '%d' WHERE map = '%s' AND track = '%d'", g_stagecount[track], g_currentMap, track); - SQL_TQuery(g_hSQL, UpdateStageCountCallback, query, track, DBPrio_Normal); - + + if(update_sql) + { + decl String:query[256]; + FormatEx(query, sizeof(query), "UPDATE maptier SET stagecount = '%d' WHERE map = '%s' AND track = '%d'", g_stagecount[track], g_currentMap, track); + SQL_TQuery(g_hSQL, UpdateStageCountCallback, query, track, DBPrio_Normal); + } + return g_stagecount[track]; } diff --git a/gameserver/addons/sourcemod/scripting/timer-mapzones.sp b/gameserver/addons/sourcemod/scripting/timer-mapzones.sp index 85b7336..55ca813 100644 --- a/gameserver/addons/sourcemod/scripting/timer-mapzones.sp +++ b/gameserver/addons/sourcemod/scripting/timer-mapzones.sp @@ -229,53 +229,53 @@ public OnPluginStart() HookConVarChange(g_glitch4ZoneColor, Action_OnSettingsChange); HookConVarChange(g_levelZoneColor, Action_OnSettingsChange); HookConVarChange(g_bonusLevelZoneColor, Action_OnSettingsChange); - + HookConVarChange(Sound_TeleLast, Action_OnSettingsChange); HookConVarChange(Sound_TeleNext, Action_OnSettingsChange); HookConVarChange(Sound_TimerStart, Action_OnSettingsChange); - - + + HookConVarChange(g_BeamBonusEndZonePath, Action_OnSettingsChange); HookConVarChange(g_BeamBonusStartZonePath, Action_OnSettingsChange); HookConVarChange(g_BeamDefaultPath, Action_OnSettingsChange); HookConVarChange(g_BeamEndZonePath, Action_OnSettingsChange); HookConVarChange(g_BeamStartZonePath, Action_OnSettingsChange); - + AutoExecConfig(true, "timer/timer-mapzones"); - + LoadTranslations("timer.phrases"); - + new Handle:topmenu; if (LibraryExists("adminmenu") && ((topmenu = GetAdminTopMenu()) != INVALID_HANDLE)) { OnAdminMenuReady(topmenu); } - - RegAdminCmd("sm_zoneadminmode", Command_LevelAdminMode, ADMFLAG_RCON); - RegAdminCmd("sm_zonename", Command_LevelName, ADMFLAG_RCON); - RegAdminCmd("sm_zoneid", Command_LevelID, ADMFLAG_RCON); - RegAdminCmd("sm_zonetype", Command_LevelType, ADMFLAG_RCON); - RegAdminCmd("sm_zoneadd", Command_AddZone, ADMFLAG_RCON); - RegAdminCmd("sm_zonereload", Command_ReloadZones, ADMFLAG_SLAY); - RegAdminCmd("sm_npc_next", Command_NPC_Next, ADMFLAG_RCON); - RegAdminCmd("sm_zone", Command_AdminZone, ADMFLAG_ROOT); - RegAdminCmd("sm_zonedel", Command_AdminZoneDel, ADMFLAG_ROOT); - RegAdminCmd("sm_toggle_tp", Command_ToggleTeleporters, ADMFLAG_RCON); - + + RegAdminCmd("sm_zoneadminmode", Command_LevelAdminMode, ADMFLAG_BAN); + RegAdminCmd("sm_zonename", Command_LevelName, ADMFLAG_BAN); + RegAdminCmd("sm_zoneid", Command_LevelID, ADMFLAG_BAN); + RegAdminCmd("sm_zonetype", Command_LevelType, ADMFLAG_BAN); + RegAdminCmd("sm_zoneadd", Command_AddZone, ADMFLAG_BAN); + RegAdminCmd("sm_zonereload", Command_ReloadZones, ADMFLAG_BAN); + RegAdminCmd("sm_npc_next", Command_NPC_Next, ADMFLAG_BAN); + RegAdminCmd("sm_zone", Command_AdminZone, ADMFLAG_BAN); + RegAdminCmd("sm_zonedel", Command_AdminZoneDel, ADMFLAG_BAN); + RegAdminCmd("sm_toggle_tp", Command_ToggleTeleporters, ADMFLAG_BAN); + RegConsoleCmd("sm_levels", Command_Levels); RegConsoleCmd("sm_stage", Command_Levels); - + if(g_Settings[RestartEnable]) { RegConsoleCmd("sm_restart", Command_Restart); RegConsoleCmd("sm_r", Command_Restart); } - + if(g_Settings[StartEnable]) { RegConsoleCmd("sm_start", Command_Start); RegConsoleCmd("sm_s", Command_Start); - + RegConsoleCmd("sm_bonusrestart", Command_BonusRestart); RegConsoleCmd("sm_bonusstart", Command_BonusRestart); RegConsoleCmd("sm_br", Command_BonusRestart); @@ -290,27 +290,34 @@ public OnPluginStart() RegConsoleCmd("sm_b5", Command_Bonus5Restart); RegConsoleCmd("sm_bonus5", Command_Bonus5Restart); } - - if(g_Settings[StuckEnable]) RegConsoleCmd("sm_stuck", Command_Stuck); - + + if(g_Settings[StuckEnable]) + { + RegConsoleCmd("sm_stuck", Command_Stuck); + RegConsoleCmd("sm_resetstage", Command_Stuck); + RegConsoleCmd("sm_rs", Command_Stuck); + RegConsoleCmd("sm_gb", Command_Stuck); + RegConsoleCmd("sm_goback", Command_Stuck); + } + HookEvent("round_start", Event_RoundStart, EventHookMode_Post); HookEvent("player_spawn", Event_PlayerSpawn); - + AddNormalSoundHook(Hook_NormalSound); - + g_ioffsCollisionGroup = FindSendPropOffs("CBaseEntity", "m_CollisionGroup"); - + g_OnMapZonesLoaded = CreateGlobalForward("OnMapZonesLoaded", ET_Event); - + g_OnClientStartTouchZoneType = CreateGlobalForward("OnClientStartTouchZoneType", ET_Event, Param_Cell,Param_Cell); g_OnClientEndTouchZoneType = CreateGlobalForward("OnClientEndTouchZoneType", ET_Event, Param_Cell,Param_Cell); - + g_OnClientStartTouchLevel = CreateGlobalForward("OnClientStartTouchLevel", ET_Event, Param_Cell, Param_Cell, Param_Cell); g_OnClientStartTouchBonusLevel = CreateGlobalForward("OnClientStartTouchBonusLevel", ET_Event, Param_Cell, Param_Cell, Param_Cell); - + //Check timeleft to enforce mapchange if(g_Settings[ForceMapEndEnable]) CreateTimer(1.0, CheckRemainingTime, INVALID_HANDLE, TIMER_REPEAT); - + //Fix rotation bugs CreateTimer(300.0, Timer_FixAngRotation, _, TIMER_REPEAT); } @@ -428,23 +435,17 @@ public OnTimerStarted(client) public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon) { if(buttons & IN_USE && IsPlayerTouchingZoneType(client, ZtBlockUse)) - { buttons &= ~IN_USE; - } - + if(buttons & IN_DUCK && IsPlayerTouchingZoneType(client, ZtBlockDuck)) - { buttons &= ~IN_DUCK; - } - + if(buttons & IN_ATTACK && IsPlayerTouchingZoneType(client, ZtBlockAttack)) - { buttons &= ~IN_ATTACK; - } - + if(g_mapZoneEditors[client][Step] == 0) return Plugin_Continue; - + if (!IsPlayerAlive(client) || IsClientSourceTV(client)) return Plugin_Continue; @@ -719,12 +720,14 @@ DisplaySelectZoneTypeMenu(client, category) } else if(category == 4) { + AddMenuItem(menu, "bhop", "Allow Bhop"); AddMenuItem(menu, "auto", "Enable Auto Bhop"); AddMenuItem(menu, "noauto", "Disable Auto Bhop"); AddMenuItem(menu, "nogravity", "No Gravity verwrite"); AddMenuItem(menu, "noboost", "Disable Style Boost"); AddMenuItem(menu, "block", "Toggle Noblock"); AddMenuItem(menu, "antinoclip", "Anti Noclip"); + AddMenuItem(menu, "anticp", "Anti cPmod"); AddMenuItem(menu, "back", "Back"); } else if(category == 5) @@ -1052,7 +1055,7 @@ public ZoneTypeSelect(Handle:menu, MenuAction:action, client, itemNum) } else if(StrEqual(info, "bonuslevel")) { - zonetype = ZtBonusCheckpoint; + zonetype = ZtBonusLevel; new String:lvlbuffer[32]; new hcount = LEVEL_BONUS_START; @@ -1083,18 +1086,18 @@ public ZoneTypeSelect(Handle:menu, MenuAction:action, client, itemNum) hcount = g_mapZones[zone][Level_Id]; } hcount++; - + FormatEx(lvlbuffer, sizeof(lvlbuffer), "Bonus2-Checkpoint %d", hcount); - + LvlID = hcount; ZoneName = lvlbuffer; valid = true; } else if(StrEqual(info, "bonus2level")) { - zonetype = ZtBonus2Checkpoint; + zonetype = ZtBonus2Level; new String:lvlbuffer[32]; - + new hcount = LEVEL_BONUS2_START; for (new zone = 0; zone < g_mapZonesCount; zone++) { @@ -1103,9 +1106,9 @@ public ZoneTypeSelect(Handle:menu, MenuAction:action, client, itemNum) hcount = g_mapZones[zone][Level_Id]; } hcount++; - + FormatEx(lvlbuffer, sizeof(lvlbuffer), "Bonus2-Stage %d", hcount); - + LvlID = hcount; ZoneName = lvlbuffer; valid = true; @@ -1114,7 +1117,7 @@ public ZoneTypeSelect(Handle:menu, MenuAction:action, client, itemNum) { zonetype = ZtBonus3Checkpoint; new String:lvlbuffer[32]; - + new hcount = LEVEL_BONUS3_START; for (new zone = 0; zone < g_mapZonesCount; zone++) { @@ -1123,18 +1126,18 @@ public ZoneTypeSelect(Handle:menu, MenuAction:action, client, itemNum) hcount = g_mapZones[zone][Level_Id]; } hcount++; - + FormatEx(lvlbuffer, sizeof(lvlbuffer), "Bonus3-Checkpoint %d", hcount); - + LvlID = hcount; ZoneName = lvlbuffer; valid = true; } else if(StrEqual(info, "bonus3level")) { - zonetype = ZtBonus3Checkpoint; + zonetype = ZtBonus3Level; new String:lvlbuffer[32]; - + new hcount = LEVEL_BONUS3_START; for (new zone = 0; zone < g_mapZonesCount; zone++) { @@ -1143,9 +1146,9 @@ public ZoneTypeSelect(Handle:menu, MenuAction:action, client, itemNum) hcount = g_mapZones[zone][Level_Id]; } hcount++; - + FormatEx(lvlbuffer, sizeof(lvlbuffer), "Bonus3-Stage %d", hcount); - + LvlID = hcount; ZoneName = lvlbuffer; valid = true; @@ -1154,7 +1157,7 @@ public ZoneTypeSelect(Handle:menu, MenuAction:action, client, itemNum) { zonetype = ZtBonus4Checkpoint; new String:lvlbuffer[32]; - + new hcount = LEVEL_BONUS4_START; for (new zone = 0; zone < g_mapZonesCount; zone++) { @@ -1163,18 +1166,18 @@ public ZoneTypeSelect(Handle:menu, MenuAction:action, client, itemNum) hcount = g_mapZones[zone][Level_Id]; } hcount++; - + FormatEx(lvlbuffer, sizeof(lvlbuffer), "Bonus4-Checkpoint %d", hcount); - + LvlID = hcount; ZoneName = lvlbuffer; valid = true; } else if(StrEqual(info, "bonus4level")) { - zonetype = ZtBonus4Checkpoint; + zonetype = ZtBonus4Level; new String:lvlbuffer[32]; - + new hcount = LEVEL_BONUS4_START; for (new zone = 0; zone < g_mapZonesCount; zone++) { @@ -1183,9 +1186,9 @@ public ZoneTypeSelect(Handle:menu, MenuAction:action, client, itemNum) hcount = g_mapZones[zone][Level_Id]; } hcount++; - + FormatEx(lvlbuffer, sizeof(lvlbuffer), "Bonus4-Stage %d", hcount); - + LvlID = hcount; ZoneName = lvlbuffer; valid = true; @@ -1194,7 +1197,7 @@ public ZoneTypeSelect(Handle:menu, MenuAction:action, client, itemNum) { zonetype = ZtBonus5Checkpoint; new String:lvlbuffer[32]; - + new hcount = LEVEL_BONUS5_START; for (new zone = 0; zone < g_mapZonesCount; zone++) { @@ -1203,18 +1206,18 @@ public ZoneTypeSelect(Handle:menu, MenuAction:action, client, itemNum) hcount = g_mapZones[zone][Level_Id]; } hcount++; - + FormatEx(lvlbuffer, sizeof(lvlbuffer), "Bonus5-Checkpoint %d", hcount); - + LvlID = hcount; ZoneName = lvlbuffer; valid = true; } else if(StrEqual(info, "bonus5level")) { - zonetype = ZtBonus5Checkpoint; + zonetype = ZtBonus5Level; new String:lvlbuffer[32]; - + new hcount = LEVEL_BONUS5_START; for (new zone = 0; zone < g_mapZonesCount; zone++) { @@ -1223,9 +1226,9 @@ public ZoneTypeSelect(Handle:menu, MenuAction:action, client, itemNum) hcount = g_mapZones[zone][Level_Id]; } hcount++; - + FormatEx(lvlbuffer, sizeof(lvlbuffer), "Bonus5-Stage %d", hcount); - + LvlID = hcount; ZoneName = lvlbuffer; valid = true; @@ -1412,7 +1415,19 @@ public ZoneTypeSelect(Handle:menu, MenuAction:action, client, itemNum) ZoneName = "Block Attack"; valid = true; } - + else if(StrEqual(info, "bhop")) + { + zonetype = ZtBhop; + ZoneName = "Allow Bhop"; + valid = true; + } + else if(StrEqual(info, "aticp")) + { + zonetype = ZtAntiCp; + ZoneName = "Anti cPmod"; + valid = true; + } + if(valid) { new Float:point1[3]; @@ -1427,14 +1442,14 @@ public ZoneTypeSelect(Handle:menu, MenuAction:action, client, itemNum) } } } - else if (action == MenuAction_End) + else if (action == MenuAction_End) { CloseHandle(menu); ResetMapZoneEditor(client); - } - else if (action == MenuAction_Cancel) + } + else if (action == MenuAction_Cancel) { - if (itemNum == MenuCancel_Exit && hTopMenu != INVALID_HANDLE) + if (itemNum == MenuCancel_Exit && hTopMenu != INVALID_HANDLE) { DisplayTopMenu(hTopMenu, client, TopMenuPosition_LastCategory); ResetMapZoneEditor(client); @@ -1446,29 +1461,29 @@ public Action:OnTouchTrigger(caller, activator) { if(!g_bZonesLoaded) return; - + if(g_mapZonesCount < 1) return; - + if (activator < 1 || activator > MaxClients) { return; } - + if (!IsClientInGame(activator)) { return; } - + if (!IsPlayerAlive(activator)) { return; } - + new client = activator; - + ChangePlayerVelocity(client); - + return; } @@ -1478,53 +1493,50 @@ public Action:StartTouchTrigger(caller, activator) return; if(g_mapZonesCount < 1) return; - + if (activator < 1 || activator > MaxClients) return; - + if (!IsClientInGame(activator)) return; - + new client = activator; - + new Float:vec[3]; GetClientAbsOrigin(client, vec); - - new mate; - if(g_timerTeams) mate = Timer_GetClientTeammate(client); - + new zone = g_MapZoneEntityZID[caller]; - + if(zone < 0) return; - - decl String:TriggerName[32]; + + decl String:TriggerName[32]; GetEntPropString(caller, Prop_Data, "m_iName", TriggerName, sizeof(TriggerName)); - + if(adminmode == 1 && Client_IsAdmin(client)) { if(GetGameMod() == MOD_CSGO) { PrintHintText(client, "ID: %d", zone); } - else + else { PrintCenterText(client, "ID: %d", zone); DrawZone(zone, false); } return; } - + Call_StartForward(g_OnClientStartTouchZoneType); Call_PushCell(client); Call_PushCell(g_mapZones[zone][Type]); Call_Finish(); - + g_bZone[zone][client] = true; - + if (!IsPlayerAlive(activator)) return; - + if (g_mapZones[zone][Type] == ZtReset) { Timer_Reset(client); @@ -1533,257 +1545,236 @@ public Action:StartTouchTrigger(caller, activator) { if(!g_Settings[NoblockEnable]) SetPush(client); - - if(mate == 0) - { - g_iIgnoreEndTouchStart[client] = false; - g_iClientLastTrackZone[client] = zone; - - Timer_Stop(client, false); - Timer_SetTrack(client, TRACK_NORMAL); - } + + g_iIgnoreEndTouchStart[client] = false; + g_iClientLastTrackZone[client] = zone; + + Timer_Stop(client, false); + Timer_SetTrack(client, TRACK_NORMAL); } else if (g_mapZones[zone][Type] == ZtBonusStart) { g_iIgnoreEndTouchStart[client] = false; g_iClientLastTrackZone[client] = zone; - + Timer_Stop(client, false); Timer_SetTrack(client, TRACK_BONUS); - + if(g_timerLjStats) SetLJMode(client, false); } else if (g_mapZones[zone][Type] == ZtBonus2Start) { g_iIgnoreEndTouchStart[client] = false; g_iClientLastTrackZone[client] = zone; - + Timer_Stop(client, false); Timer_SetTrack(client, TRACK_BONUS2); - + if(g_timerLjStats) SetLJMode(client, false); } else if (g_mapZones[zone][Type] == ZtBonus3Start) { g_iIgnoreEndTouchStart[client] = false; g_iClientLastTrackZone[client] = zone; - + Timer_Stop(client, false); Timer_SetTrack(client, TRACK_BONUS3); - + if(g_timerLjStats) SetLJMode(client, false); } else if (g_mapZones[zone][Type] == ZtBonus4Start) { g_iIgnoreEndTouchStart[client] = false; g_iClientLastTrackZone[client] = zone; - + Timer_Stop(client, false); Timer_SetTrack(client, TRACK_BONUS4); - + if(g_timerLjStats) SetLJMode(client, false); } else if (g_mapZones[zone][Type] == ZtBonus5Start) { g_iIgnoreEndTouchStart[client] = false; g_iClientLastTrackZone[client] = zone; - + Timer_Stop(client, false); Timer_SetTrack(client, TRACK_BONUS5); - + if(g_timerLjStats) SetLJMode(client, false); } else if (g_mapZones[zone][Type] == ZtEnd) { if(!g_Settings[NoblockEnable]) SetPush(client); - - if(mate == 0) + + //has player noclip? + if(GetEntProp(client, Prop_Send, "movetype", 1) == 8) { - //has player noclip? - if(GetEntProp(client, Prop_Send, "movetype", 1) == 8) - { - Timer_Stop(client, false); - } - else if(Timer_GetTrack(client) == TRACK_NORMAL) + Timer_Stop(client, false); + } + else if(Timer_GetTrack(client) == TRACK_NORMAL) + { + g_iClientLastTrackZone[client] = zone; + + if (Timer_Stop(client, false)) { - g_iClientLastTrackZone[client] = zone; - - if (Timer_Stop(client, false)) + new bool:enabled = false; + new jumps = 0; + new Float:time; + new fpsmax; + + if (Timer_GetClientTimer(client, enabled, time, jumps, fpsmax)) { - new bool:enabled = false; - new jumps = 0; - new Float:time; - new fpsmax; - - if (Timer_GetClientTimer(client, enabled, time, jumps, fpsmax)) - { - new difficulty = 0; - if (g_timerPhysics) - difficulty = Timer_GetStyle(client); - - Timer_FinishRound(client, g_currentMap, time, jumps, difficulty, fpsmax, TRACK_NORMAL); - } + new difficulty = 0; + if (g_timerPhysics) + difficulty = Timer_GetStyle(client); + + Timer_FinishRound(client, g_currentMap, time, jumps, difficulty, fpsmax, TRACK_NORMAL); } } } } else if (g_mapZones[zone][Type] == ZtBonusEnd) { - if(mate == 0) + //has player noclip? + if(GetEntProp(client, Prop_Send, "movetype", 1) == 8) { - //has player noclip? - if(GetEntProp(client, Prop_Send, "movetype", 1) == 8) - { - Timer_Stop(client, false); - } - else if(Timer_GetTrack(client) == TRACK_BONUS) + Timer_Stop(client, false); + } + else if(Timer_GetTrack(client) == TRACK_BONUS) + { + g_iClientLastTrackZone[client] = zone; + + if (Timer_Stop(client, false)) { - g_iClientLastTrackZone[client] = zone; - - if (Timer_Stop(client, false)) + new bool:enabled = false; + new jumps = 0; + new Float:time; + new fpsmax; + + if (Timer_GetClientTimer(client, enabled, time, jumps, fpsmax)) { - new bool:enabled = false; - new jumps = 0; - new Float:time; - new fpsmax; - - if (Timer_GetClientTimer(client, enabled, time, jumps, fpsmax)) - { - new difficulty = 0; - if (g_timerPhysics) - difficulty = Timer_GetStyle(client); - - Timer_FinishRound(client, g_currentMap, time, jumps, difficulty, fpsmax, TRACK_BONUS); - } + new difficulty = 0; + if (g_timerPhysics) + difficulty = Timer_GetStyle(client); + + Timer_FinishRound(client, g_currentMap, time, jumps, difficulty, fpsmax, TRACK_BONUS); } } } } else if (g_mapZones[zone][Type] == ZtBonus2End) { - if(mate == 0) + //has player noclip? + if(GetEntProp(client, Prop_Send, "movetype", 1) == 8) { - //has player noclip? - if(GetEntProp(client, Prop_Send, "movetype", 1) == 8) - { - Timer_Stop(client, false); - } - else if(Timer_GetTrack(client) == TRACK_BONUS2) + Timer_Stop(client, false); + } + else if(Timer_GetTrack(client) == TRACK_BONUS2) + { + g_iClientLastTrackZone[client] = zone; + + if (Timer_Stop(client, false)) { - g_iClientLastTrackZone[client] = zone; - - if (Timer_Stop(client, false)) + new bool:enabled = false; + new jumps = 0; + new Float:time; + new fpsmax; + + if (Timer_GetClientTimer(client, enabled, time, jumps, fpsmax)) { - new bool:enabled = false; - new jumps = 0; - new Float:time; - new fpsmax; - - if (Timer_GetClientTimer(client, enabled, time, jumps, fpsmax)) - { - new difficulty = 0; - if (g_timerPhysics) - difficulty = Timer_GetStyle(client); - - Timer_FinishRound(client, g_currentMap, time, jumps, difficulty, fpsmax, TRACK_BONUS2); - } + new difficulty = 0; + if (g_timerPhysics) + difficulty = Timer_GetStyle(client); + + Timer_FinishRound(client, g_currentMap, time, jumps, difficulty, fpsmax, TRACK_BONUS2); } } } } else if (g_mapZones[zone][Type] == ZtBonus3End) { - if(mate == 0) + //has player noclip? + if(GetEntProp(client, Prop_Send, "movetype", 1) == 8) { - //has player noclip? - if(GetEntProp(client, Prop_Send, "movetype", 1) == 8) - { - Timer_Stop(client, false); - } - else if(Timer_GetTrack(client) == TRACK_BONUS3) + Timer_Stop(client, false); + } + else if(Timer_GetTrack(client) == TRACK_BONUS3) + { + g_iClientLastTrackZone[client] = zone; + + if (Timer_Stop(client, false)) { - g_iClientLastTrackZone[client] = zone; - - if (Timer_Stop(client, false)) + new bool:enabled = false; + new jumps = 0; + new Float:time; + new fpsmax; + + if (Timer_GetClientTimer(client, enabled, time, jumps, fpsmax)) { - new bool:enabled = false; - new jumps = 0; - new Float:time; - new fpsmax; - - if (Timer_GetClientTimer(client, enabled, time, jumps, fpsmax)) - { - new difficulty = 0; - if (g_timerPhysics) - difficulty = Timer_GetStyle(client); - - Timer_FinishRound(client, g_currentMap, time, jumps, difficulty, fpsmax, TRACK_BONUS3); - } + new difficulty = 0; + if (g_timerPhysics) + difficulty = Timer_GetStyle(client); + + Timer_FinishRound(client, g_currentMap, time, jumps, difficulty, fpsmax, TRACK_BONUS3); } } } } else if (g_mapZones[zone][Type] == ZtBonus4End) { - if(mate == 0) + //has player noclip? + if(GetEntProp(client, Prop_Send, "movetype", 1) == 8) { - //has player noclip? - if(GetEntProp(client, Prop_Send, "movetype", 1) == 8) - { - Timer_Stop(client, false); - } - else if(Timer_GetTrack(client) == TRACK_BONUS4) - { - g_iClientLastTrackZone[client] = zone; - - if (Timer_Stop(client, false)) + Timer_Stop(client, false); + } + else if(Timer_GetTrack(client) == TRACK_BONUS4) + { + g_iClientLastTrackZone[client] = zone; + + if (Timer_Stop(client, false)) + { + new bool:enabled = false; + new jumps = 0; + new Float:time; + new fpsmax; + + if (Timer_GetClientTimer(client, enabled, time, jumps, fpsmax)) { - new bool:enabled = false; - new jumps = 0; - new Float:time; - new fpsmax; - - if (Timer_GetClientTimer(client, enabled, time, jumps, fpsmax)) - { - new difficulty = 0; - if (g_timerPhysics) - difficulty = Timer_GetStyle(client); - - Timer_FinishRound(client, g_currentMap, time, jumps, difficulty, fpsmax, TRACK_BONUS4); - } + new difficulty = 0; + if (g_timerPhysics) + difficulty = Timer_GetStyle(client); + + Timer_FinishRound(client, g_currentMap, time, jumps, difficulty, fpsmax, TRACK_BONUS4); } } } } else if (g_mapZones[zone][Type] == ZtBonus5End) { - if(mate == 0) + //has player noclip? + if(GetEntProp(client, Prop_Send, "movetype", 1) == 8) { - //has player noclip? - if(GetEntProp(client, Prop_Send, "movetype", 1) == 8) - { - Timer_Stop(client, false); - } - else if(Timer_GetTrack(client) == TRACK_BONUS5) + Timer_Stop(client, false); + } + else if(Timer_GetTrack(client) == TRACK_BONUS5) + { + g_iClientLastTrackZone[client] = zone; + + if (Timer_Stop(client, false)) { - g_iClientLastTrackZone[client] = zone; - - if (Timer_Stop(client, false)) + new bool:enabled = false; + new jumps = 0; + new Float:time; + new fpsmax; + + if (Timer_GetClientTimer(client, enabled, time, jumps, fpsmax)) { - new bool:enabled = false; - new jumps = 0; - new Float:time; - new fpsmax; - - if (Timer_GetClientTimer(client, enabled, time, jumps, fpsmax)) - { - new difficulty = 0; - if (g_timerPhysics) - difficulty = Timer_GetStyle(client); - - Timer_FinishRound(client, g_currentMap, time, jumps, difficulty, fpsmax, TRACK_BONUS5); - } + new difficulty = 0; + if (g_timerPhysics) + difficulty = Timer_GetStyle(client); + + Timer_FinishRound(client, g_currentMap, time, jumps, difficulty, fpsmax, TRACK_BONUS5); } } } @@ -1794,23 +1785,23 @@ public Action:StartTouchTrigger(caller, activator) } else if (g_mapZones[zone][Type] == ZtRestart) { - if(Timer_GetTrack(client) == TRACK_BONUS) + if(Timer_GetTrack(client) == TRACK_BONUS) { Tele_Level(client, LEVEL_BONUS_START); } - else if(Timer_GetTrack(client) == TRACK_BONUS2) + else if(Timer_GetTrack(client) == TRACK_BONUS2) { Tele_Level(client, LEVEL_BONUS2_START); } - else if(Timer_GetTrack(client) == TRACK_BONUS3) + else if(Timer_GetTrack(client) == TRACK_BONUS3) { Tele_Level(client, LEVEL_BONUS3_START); } - else if(Timer_GetTrack(client) == TRACK_BONUS4) + else if(Timer_GetTrack(client) == TRACK_BONUS4) { Tele_Level(client, LEVEL_BONUS4_START); } - else if(Timer_GetTrack(client) == TRACK_BONUS5) + else if(Timer_GetTrack(client) == TRACK_BONUS5) { Tele_Level(client, LEVEL_BONUS5_START); } @@ -1821,30 +1812,30 @@ public Action:StartTouchTrigger(caller, activator) } else if (g_mapZones[zone][Type] == ZtRestartNormalTimer) { - if(Timer_GetTrack(client) == TRACK_NORMAL) + if(Timer_GetTrack(client) == TRACK_NORMAL) { Tele_Level(client, LEVEL_START); } } else if (g_mapZones[zone][Type] == ZtRestartBonusTimer) { - if(Timer_GetTrack(client) == TRACK_BONUS) + if(Timer_GetTrack(client) == TRACK_BONUS) { Tele_Level(client, LEVEL_BONUS_START); } - else if(Timer_GetTrack(client) == TRACK_BONUS2) + else if(Timer_GetTrack(client) == TRACK_BONUS2) { Tele_Level(client, LEVEL_BONUS2_START); } - else if(Timer_GetTrack(client) == TRACK_BONUS3) + else if(Timer_GetTrack(client) == TRACK_BONUS3) { Tele_Level(client, LEVEL_BONUS3_START); } - else if(Timer_GetTrack(client) == TRACK_BONUS4) + else if(Timer_GetTrack(client) == TRACK_BONUS4) { Tele_Level(client, LEVEL_BONUS4_START); } - else if(Timer_GetTrack(client) == TRACK_BONUS5) + else if(Timer_GetTrack(client) == TRACK_BONUS5) { Tele_Level(client, LEVEL_BONUS5_START); } @@ -1852,38 +1843,18 @@ public Action:StartTouchTrigger(caller, activator) else if (g_mapZones[zone][Type] == ZtLast) { new lowestcheckpoint = g_mapZones[g_iClientLastTrackZone[client]][Level_Id]; - - if(0 < mate && IsClientInGame(mate) && IsPlayerAlive(mate)) - { - if(g_iClientLastTrackZone[client] > g_iClientLastTrackZone[mate]) lowestcheckpoint = g_mapZones[g_iClientLastTrackZone[mate]][Level_Id]; - - Tele_Level(client, lowestcheckpoint); - Tele_Level(mate, lowestcheckpoint); - - if(Client_IsValid(client, true)) EmitSoundToClient(client, SND_TELE_LAST); - if(Client_IsValid(mate, true)) EmitSoundToClient(mate, SND_TELE_LAST); - } - else - { - if(Client_IsValid(client, true)) EmitSoundToClient(client, SND_TELE_LAST); - Tele_Level(client, lowestcheckpoint); - } + Tele_Level(client, lowestcheckpoint); + + if(Client_IsValid(client, true)) + EmitSoundToClient(client, SND_TELE_LAST); } else if (g_mapZones[zone][Type] == ZtNext) { - if(0 < mate && IsClientInGame(mate) && IsPlayerAlive(mate) && g_mapZones[g_iClientLastTrackZone[client]][Level_Id] == g_mapZones[g_iClientLastTrackZone[mate]][Level_Id]) - { - Tele_Level(client, g_mapZones[g_iClientLastTrackZone[client]][Level_Id]+1); - Tele_Level(mate, g_mapZones[g_iClientLastTrackZone[client]][Level_Id]+1); - if(Client_IsValid(client, true)) EmitSoundToClient(client, SND_TELE_NEXT); - if(Client_IsValid(mate, true)) EmitSoundToClient(mate, SND_TELE_NEXT); - } - else - { - Tele_Level(client, g_mapZones[g_iClientLastTrackZone[client]][Level_Id]+1); - if(Client_IsValid(client, true)) EmitSoundToClient(client, SND_TELE_NEXT); - } - + Tele_Level(client, g_mapZones[g_iClientLastTrackZone[client]][Level_Id]+1); + + if(Client_IsValid(client, true)) + EmitSoundToClient(client, SND_TELE_NEXT); + } else if (g_mapZones[zone][Type] == ZtLevel) { @@ -1891,7 +1862,7 @@ public Action:StartTouchTrigger(caller, activator) { new lastlevel = g_mapZones[g_iClientLastTrackZone[client]][Level_Id]; g_iClientLastTrackZone[client] = zone; - + Call_StartForward(g_OnClientStartTouchLevel); Call_PushCell(client); Call_PushCell(g_mapZones[g_iClientLastTrackZone[client]][Level_Id]); @@ -1905,7 +1876,7 @@ public Action:StartTouchTrigger(caller, activator) { new lastlevel = g_mapZones[g_iClientLastTrackZone[client]][Level_Id]; g_iClientLastTrackZone[client] = zone; - + Call_StartForward(g_OnClientStartTouchLevel); Call_PushCell(client); Call_PushCell(g_mapZones[g_iClientLastTrackZone[client]][Level_Id]); @@ -1919,7 +1890,7 @@ public Action:StartTouchTrigger(caller, activator) { new lastlevel = g_mapZones[g_iClientLastTrackZone[client]][Level_Id]; g_iClientLastTrackZone[client] = zone; - + Call_StartForward(g_OnClientStartTouchBonusLevel); Call_PushCell(client); Call_PushCell(g_mapZones[g_iClientLastTrackZone[client]][Level_Id]); @@ -1933,7 +1904,7 @@ public Action:StartTouchTrigger(caller, activator) { new lastlevel = g_mapZones[g_iClientLastTrackZone[client]][Level_Id]; g_iClientLastTrackZone[client] = zone; - + Call_StartForward(g_OnClientStartTouchBonusLevel); Call_PushCell(client); Call_PushCell(g_mapZones[g_iClientLastTrackZone[client]][Level_Id]); @@ -1947,7 +1918,7 @@ public Action:StartTouchTrigger(caller, activator) { new lastlevel = g_mapZones[g_iClientLastTrackZone[client]][Level_Id]; g_iClientLastTrackZone[client] = zone; - + Call_StartForward(g_OnClientStartTouchBonusLevel); Call_PushCell(client); Call_PushCell(g_mapZones[g_iClientLastTrackZone[client]][Level_Id]); @@ -1961,7 +1932,7 @@ public Action:StartTouchTrigger(caller, activator) { new lastlevel = g_mapZones[g_iClientLastTrackZone[client]][Level_Id]; g_iClientLastTrackZone[client] = zone; - + Call_StartForward(g_OnClientStartTouchBonusLevel); Call_PushCell(client); Call_PushCell(g_mapZones[g_iClientLastTrackZone[client]][Level_Id]); @@ -1975,7 +1946,7 @@ public Action:StartTouchTrigger(caller, activator) { new lastlevel = g_mapZones[g_iClientLastTrackZone[client]][Level_Id]; g_iClientLastTrackZone[client] = zone; - + Call_StartForward(g_OnClientStartTouchBonusLevel); Call_PushCell(client); Call_PushCell(g_mapZones[g_iClientLastTrackZone[client]][Level_Id]); @@ -1989,7 +1960,7 @@ public Action:StartTouchTrigger(caller, activator) { new lastlevel = g_mapZones[g_iClientLastTrackZone[client]][Level_Id]; g_iClientLastTrackZone[client] = zone; - + Call_StartForward(g_OnClientStartTouchBonusLevel); Call_PushCell(client); Call_PushCell(g_mapZones[g_iClientLastTrackZone[client]][Level_Id]); @@ -2003,7 +1974,7 @@ public Action:StartTouchTrigger(caller, activator) { new lastlevel = g_mapZones[g_iClientLastTrackZone[client]][Level_Id]; g_iClientLastTrackZone[client] = zone; - + Call_StartForward(g_OnClientStartTouchBonusLevel); Call_PushCell(client); Call_PushCell(g_mapZones[g_iClientLastTrackZone[client]][Level_Id]); @@ -2017,7 +1988,7 @@ public Action:StartTouchTrigger(caller, activator) { new lastlevel = g_mapZones[g_iClientLastTrackZone[client]][Level_Id]; g_iClientLastTrackZone[client] = zone; - + Call_StartForward(g_OnClientStartTouchBonusLevel); Call_PushCell(client); Call_PushCell(g_mapZones[g_iClientLastTrackZone[client]][Level_Id]); @@ -2031,7 +2002,7 @@ public Action:StartTouchTrigger(caller, activator) { new lastlevel = g_mapZones[g_iClientLastTrackZone[client]][Level_Id]; g_iClientLastTrackZone[client] = zone; - + Call_StartForward(g_OnClientStartTouchBonusLevel); Call_PushCell(client); Call_PushCell(g_mapZones[g_iClientLastTrackZone[client]][Level_Id]); @@ -2045,7 +2016,7 @@ public Action:StartTouchTrigger(caller, activator) { new lastlevel = g_mapZones[g_iClientLastTrackZone[client]][Level_Id]; g_iClientLastTrackZone[client] = zone; - + Call_StartForward(g_OnClientStartTouchBonusLevel); Call_PushCell(client); Call_PushCell(g_mapZones[g_iClientLastTrackZone[client]][Level_Id]); @@ -2075,7 +2046,7 @@ public Action:StartTouchTrigger(caller, activator) { SetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue", 0.7); } - + return; } @@ -2083,32 +2054,29 @@ public Action:EndTouchTrigger(caller, activator) { if(!g_bZonesLoaded) return; - + if(g_mapZonesCount < 1) return; - + if (activator < 1 || activator > MaxClients) return; - + if (!IsClientInGame(activator)) return; - + new client = activator; - + new Float:vec[3]; GetClientAbsOrigin(client, vec); - - new mate; - if(g_timerTeams) mate = Timer_GetClientTeammate(client); - + new zone = g_MapZoneEntityZID[caller]; - + if(zone < 0) return; - - decl String:TriggerName[32]; + + decl String:TriggerName[32]; GetEntPropString(caller, Prop_Data, "m_iName", TriggerName, sizeof(TriggerName)); - + if(adminmode == 1 && Client_IsAdmin(client)) { if(GetGameMod() == MOD_CSGO) @@ -2118,26 +2086,26 @@ public Action:EndTouchTrigger(caller, activator) else PrintCenterText(client, "ID: %d", zone); return; } - + Call_StartForward(g_OnClientEndTouchZoneType); Call_PushCell(client); Call_PushCell(g_mapZones[zone][Type]); Call_Finish(); - + g_bZone[zone][client] = false; - + if (!IsPlayerAlive(activator)) return; - + if(Timer_GetForceStyle() && !Timer_GetPickedStyle(client)) { if(GetGameTime()-g_fSpawnTime[client] > 0.5) Tele_Level(client, LEVEL_START); - + FakeClientCommand(client, "sm_style"); CPrintToChat(client, PLUGIN_PREFIX, "Force Mode"); } - + if(g_mapZones[zone][Type] == ZtEnd) { if(!g_Settings[NoblockEnable]) @@ -2147,24 +2115,24 @@ public Action:EndTouchTrigger(caller, activator) { if(!g_Settings[NoblockEnable]) SetBlock(client); - - if(mate == 0 && CheckIllegalTeleport(client)) + + if(CheckIllegalTeleport(client)) { if(Timer_IsPlayerTouchingZoneType(client, ZtStop)) return; - + if(GetEntProp(client, Prop_Send, "movetype", 1) == 8) return; - + if(g_iIgnoreEndTouchStart[client]) { g_iIgnoreEndTouchStart[client] = false; return; } - + if(IsClientConnected(client)) EmitSoundToClient(client, SND_TIMER_START); - + Timer_Restart(client); Timer_SetTrack(client, TRACK_NORMAL); } @@ -2173,16 +2141,19 @@ public Action:EndTouchTrigger(caller, activator) { if(Timer_IsPlayerTouchingZoneType(client, ZtStop) || !CheckIllegalTeleport(client)) return; - + if(GetEntProp(client, Prop_Send, "movetype", 1) == 8) return; - + if(g_iIgnoreEndTouchStart[client]) { g_iIgnoreEndTouchStart[client] = false; return; } - if(IsClientConnected(client)) EmitSoundToClient(client, SND_TIMER_START); + + if(IsClientConnected(client)) + EmitSoundToClient(client, SND_TIMER_START); + Timer_Restart(client); Timer_SetTrack(client, TRACK_BONUS); } @@ -2190,16 +2161,19 @@ public Action:EndTouchTrigger(caller, activator) { if(Timer_IsPlayerTouchingZoneType(client, ZtStop) || !CheckIllegalTeleport(client)) return; - + if(GetEntProp(client, Prop_Send, "movetype", 1) == 8) return; - + if(g_iIgnoreEndTouchStart[client]) { g_iIgnoreEndTouchStart[client] = false; return; } - if(IsClientConnected(client)) EmitSoundToClient(client, SND_TIMER_START); + + if(IsClientConnected(client)) + EmitSoundToClient(client, SND_TIMER_START); + Timer_Restart(client); Timer_SetTrack(client, TRACK_BONUS2); } @@ -2207,16 +2181,19 @@ public Action:EndTouchTrigger(caller, activator) { if(Timer_IsPlayerTouchingZoneType(client, ZtStop) || !CheckIllegalTeleport(client)) return; - + if(GetEntProp(client, Prop_Send, "movetype", 1) == 8) return; - + if(g_iIgnoreEndTouchStart[client]) { g_iIgnoreEndTouchStart[client] = false; return; } - if(IsClientConnected(client)) EmitSoundToClient(client, SND_TIMER_START); + + if(IsClientConnected(client)) + EmitSoundToClient(client, SND_TIMER_START); + Timer_Restart(client); Timer_SetTrack(client, TRACK_BONUS3); } @@ -2224,16 +2201,19 @@ public Action:EndTouchTrigger(caller, activator) { if(Timer_IsPlayerTouchingZoneType(client, ZtStop) || !CheckIllegalTeleport(client)) return; - + if(GetEntProp(client, Prop_Send, "movetype", 1) == 8) return; - + if(g_iIgnoreEndTouchStart[client]) { g_iIgnoreEndTouchStart[client] = false; return; } - if(IsClientConnected(client)) EmitSoundToClient(client, SND_TIMER_START); + + if(IsClientConnected(client)) + EmitSoundToClient(client, SND_TIMER_START); + Timer_Restart(client); Timer_SetTrack(client, TRACK_BONUS4); } @@ -2241,16 +2221,19 @@ public Action:EndTouchTrigger(caller, activator) { if(Timer_IsPlayerTouchingZoneType(client, ZtStop) || !CheckIllegalTeleport(client)) return; - + if(GetEntProp(client, Prop_Send, "movetype", 1) == 8) return; - + if(g_iIgnoreEndTouchStart[client]) { g_iIgnoreEndTouchStart[client] = false; return; } - if(IsClientConnected(client)) EmitSoundToClient(client, SND_TIMER_START); + + if(IsClientConnected(client)) + EmitSoundToClient(client, SND_TIMER_START); + Timer_Restart(client); Timer_SetTrack(client, TRACK_BONUS5); } @@ -2272,40 +2255,40 @@ public Action:EndTouchTrigger(caller, activator) { SetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue", 1.0); } - + return; -} +} public Action:NPC_Use(caller, activator) { decl Float:camangle[3], Float:vecClient[3], Float:vecCaller[3]; - + decl Float:vec[3]; Entity_GetAbsOrigin(caller, vecCaller); - GetClientAbsOrigin(activator, vecClient); - + GetClientAbsOrigin(activator, vecClient); + MakeVectorFromPoints(vecCaller, vecClient, vec); GetVectorAngles(vec, camangle); camangle[0] = 0.0; camangle[2] = 0.0; - + TeleportEntity(caller, NULL_VECTOR, camangle, NULL_VECTOR); - + for (new i = 0; i < g_mapZonesCount; i++) { if(g_mapZones[i][NPC] == caller) { g_iClientLastTrackZone[activator] = i; - + Menu_NPC_Next(activator, i); - + break; } } - + SetEntData(caller, g_ioffsCollisionGroup, 17, 4, true); CreateTimer(0.5, SetBlockable, caller, TIMER_FLAG_NO_MAPCHANGE); - + return Plugin_Continue; } @@ -2313,16 +2296,16 @@ public OnConfigsExecuted() { //Sounds CacheSounds(); - + //Sprites GetConVarString(g_BeamDefaultPath, g_sBeamDefaultPath, sizeof(g_sBeamDefaultPath)); GetConVarString(g_BeamStartZonePath, g_sBeamStartZonePath, sizeof(g_sBeamStartZonePath)); GetConVarString(g_BeamEndZonePath, g_sBeamEndZonePath, sizeof(g_sBeamEndZonePath)); GetConVarString(g_BeamBonusStartZonePath, g_sBeamBonusStartZonePath, sizeof(g_sBeamBonusStartZonePath)); GetConVarString(g_BeamBonusEndZonePath, g_sBeamBonusEndZonePath, sizeof(g_sBeamBonusEndZonePath)); - + InitZoneSprites(); - + //Colors new String:buffer[128]; GetConVarString(g_startMapZoneColor, buffer, sizeof(buffer)); @@ -2353,10 +2336,10 @@ CacheSounds() { GetConVarString(Sound_TeleLast, SND_TELE_LAST, sizeof(SND_TELE_LAST)); PrepareSound(SND_TELE_LAST); - + GetConVarString(Sound_TeleNext, SND_TELE_NEXT, sizeof(SND_TELE_NEXT)); PrepareSound(SND_TELE_NEXT); - + GetConVarString(Sound_TimerStart, SND_TIMER_START, sizeof(SND_TIMER_START)); PrepareSound(SND_TIMER_START); } @@ -2364,9 +2347,9 @@ CacheSounds() public PrepareSound(String: sound[MAX_FILE_LEN]) { decl String:fileSound[MAX_FILE_LEN]; - + FormatEx(fileSound, MAX_FILE_LEN, "sound/%s", sound); - + if (FileExists(fileSound)) { PrecacheSound(sound, true); @@ -2381,7 +2364,7 @@ public PrepareSound(String: sound[MAX_FILE_LEN]) InitZoneSprites() { new String:spritebuffer[256]; - + //default sprite GetConVarString(g_BeamDefaultPath, g_sBeamDefaultPath, sizeof(g_sBeamDefaultPath)); Format(spritebuffer, sizeof(spritebuffer), "%s.vmt", g_sBeamDefaultPath); @@ -2392,7 +2375,7 @@ InitZoneSprites() Format(spritebuffer, sizeof(spritebuffer), "%s.vtf", g_sBeamDefaultPath); AddFileToDownloadsTable(spritebuffer); } - + //start sprite GetConVarString(g_BeamStartZonePath, g_sBeamStartZonePath, sizeof(g_sBeamStartZonePath)); Format(spritebuffer, sizeof(spritebuffer), "%s.vmt", g_sBeamStartZonePath); @@ -2403,7 +2386,7 @@ InitZoneSprites() Format(spritebuffer, sizeof(spritebuffer), "%s.vtf", g_sBeamStartZonePath); AddFileToDownloadsTable(spritebuffer); } - + //end sprite GetConVarString(g_BeamEndZonePath, g_sBeamEndZonePath, sizeof(g_sBeamEndZonePath)); Format(spritebuffer, sizeof(spritebuffer), "%s.vmt", g_sBeamEndZonePath); @@ -2414,7 +2397,7 @@ InitZoneSprites() Format(spritebuffer, sizeof(spritebuffer), "%s.vtf", g_sBeamEndZonePath); AddFileToDownloadsTable(spritebuffer); } - + //bonus start sprite GetConVarString(g_BeamBonusStartZonePath, g_sBeamBonusStartZonePath, sizeof(g_sBeamBonusStartZonePath)); Format(spritebuffer, sizeof(spritebuffer), "%s.vmt", g_sBeamBonusStartZonePath); @@ -2425,7 +2408,7 @@ InitZoneSprites() Format(spritebuffer, sizeof(spritebuffer), "%s.vtf", g_sBeamBonusStartZonePath); AddFileToDownloadsTable(spritebuffer); } - + //bonus end sprite GetConVarString(g_BeamBonusEndZonePath, g_sBeamBonusEndZonePath, sizeof(g_sBeamBonusEndZonePath)); Format(spritebuffer, sizeof(spritebuffer), "%s.vmt", g_sBeamBonusEndZonePath); @@ -2444,16 +2427,16 @@ public Action:CheckEntitysLoaded(Handle:timer) { if (g_hSQL == INVALID_HANDLE) ConnectSQL(); - + if (g_hSQL != INVALID_HANDLE) { Timer_LogInfo("No mapzone entitys spawned, reloading..."); LoadMapZones(); } - + CreateTimer(4.0, CheckEntitysLoaded, _, TIMER_FLAG_NO_MAPCHANGE); } - + return Plugin_Stop; } @@ -2468,65 +2451,40 @@ public OnClientDisconnect_Post(client) //Credits to 1NutWunDeR public Action:CheckRemainingTime(Handle:timer) { - new Handle:hTmp; + new Handle:hTmp; hTmp = FindConVar("mp_timelimit"); - new iTimeLimit = GetConVarInt(hTmp); + new iTimeLimit = GetConVarInt(hTmp); if (hTmp != INVALID_HANDLE) - CloseHandle(hTmp); + CloseHandle(hTmp); if (iTimeLimit > 0) { new timeleft; GetMapTimeLeft(timeleft); - + new tier; if(g_timerMapTier) tier = Timer_GetTier(TRACK_NORMAL); - + decl String:sTier[32]; - Format(sTier, sizeof(sTier), " Map Tier: %d", tier); - - if(GetEngineVersion() == Engine_CSGO) - { - switch(timeleft) - { - case 1800: CPrintToChatAll("Current Map: %s%s Time Remaining: 30 minutes", g_currentMap, sTier); - case 1200: CPrintToChatAll("Current Map: %s%s Time Remaining: 20 minutes", g_currentMap, sTier); - case 600: CPrintToChatAll("Current Map: %s%s Time Remaining: 10 minutes", g_currentMap, sTier); - case 300: CPrintToChatAll("Current Map: %s%s Time Remaining: 5 minutes", g_currentMap, sTier); - case 120: CPrintToChatAll("Current Map: %s%s Time Remaining: 2 minutes", g_currentMap, sTier); - case 60: CPrintToChatAll("Current Map: %s%s Time Remaining: 60 seconds", g_currentMap, sTier); - case 30: CPrintToChatAll("Current Map: %s%s Time Remaining: 30 seconds", g_currentMap, sTier); - case 15: CPrintToChatAll("Current Map: %s%s Time Remaining: 15 seconds", g_currentMap, sTier); - case -1: CPrintToChatAll("3.."); - case -2: CPrintToChatAll("2.."); - case -3: - { - CPrintToChatAll("1.."); - CreateTimer(1.0, TerminateRoundTimer, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE); - } - } - } - else + Format(sTier, sizeof(sTier), " Tier: %d", tier); + + switch(timeleft) { - switch(timeleft) - { - case 1800: CPrintToChatAll("Current Map: %s%s Time Remaining: 30 minutes", g_currentMap, sTier); - case 1200: CPrintToChatAll("Current Map: %s%s Time Remaining: 20 minutes", g_currentMap, sTier); - case 600: CPrintToChatAll("Current Map: %s%s Time Remaining: 10 minutes", g_currentMap, sTier); - case 300: CPrintToChatAll("Current Map: %s%s Time Remaining: 5 minutes", g_currentMap, sTier); - case 120: CPrintToChatAll("Current Map: %s%s Time Remaining: 2 minutes", g_currentMap, sTier); - case 60: CPrintToChatAll("Current Map: %s%s Time Remaining: 60 seconds", g_currentMap, sTier); - case 30: CPrintToChatAll("Current Map: %s%s Time Remaining: 30 seconds", g_currentMap, sTier); - case 15: CPrintToChatAll("Current Map: %s%s Time Remaining: 15 seconds", g_currentMap, sTier); - case -1: CPrintToChatAll("3.."); - case -2: CPrintToChatAll("2.."); - case -3: - { - CPrintToChatAll("1.."); - CreateTimer(1.0, TerminateRoundTimer, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE); - } - } + case 1800: CPrintToChatAll("Current Map: %s%s Time Remaining: 30 minutes", g_currentMap, sTier); + case 1200: CPrintToChatAll("Current Map: %s%s Time Remaining: 20 minutes", g_currentMap, sTier); + case 600: CPrintToChatAll("Current Map: %s%s Time Remaining: 10 minutes", g_currentMap, sTier); + case 300: CPrintToChatAll("Current Map: %s%s Time Remaining: 5 minutes", g_currentMap, sTier); + case 120: CPrintToChatAll("Current Map: %s%s Time Remaining: 2 minutes", g_currentMap, sTier); + case 60: CPrintToChatAll("Current Map: %s%s Time Remaining: 60 seconds", g_currentMap, sTier); + case 30: CPrintToChatAll("Current Map: %s%s Time Remaining: 30 seconds", g_currentMap, sTier); + case 15: CPrintToChatAll("Current Map: %s%s Time Remaining: 15 seconds", g_currentMap, sTier); + case -1: CPrintToChatAll("3.."); + case -2: CPrintToChatAll("2.."); + case -3: CPrintToChatAll("1.."); } + + if(timeleft < -3 && !g_bAllowRoundEnd) + CreateTimer(0.0, TerminateRoundTimer, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE); } } @@ -2550,11 +2508,11 @@ public Action:CS_OnTerminateRound(&Float:delay, &CSRoundEndReason:reason) g_bAllowRoundEnd = false; return Plugin_Continue; } - + // Block round end if(g_Settings[TerminateRoundEnd]) return Plugin_Handled; - + // Let the round end return Plugin_Continue; } @@ -2563,10 +2521,10 @@ public Action:Event_RoundStart(Handle:event,const String:name[],bool:dontBroadca { if (g_hSQL == INVALID_HANDLE) ConnectSQL(); - + if (g_hSQL != INVALID_HANDLE) LoadMapZones(); - + else CreateTimer(3.0, Timer_LoadMapzones, _ , TIMER_FLAG_NO_MAPCHANGE); } @@ -2574,44 +2532,44 @@ public Action:Timer_LoadMapzones(Handle:timer, any:data) { if (g_hSQL == INVALID_HANDLE) ConnectSQL(); - + if (g_hSQL != INVALID_HANDLE) LoadMapZones(); - + else CreateTimer(3.0, Timer_LoadMapzones, _ , TIMER_FLAG_NO_MAPCHANGE); - + return Plugin_Stop; } public Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) { new client = GetClientOfUserId(GetEventInt(event, "userid")); - + g_iClientLastTrackZone[client] = 0; g_iIgnoreEndTouchStart[client] = 0; g_iTargetNPC[client] = 0; Timer_Resume(client); Timer_Stop(client, false); - + for (new i = 0; i <= 127; i++) { g_bZone[i][client] = false; } - + if(g_Settings[TeleportOnSpawn]) { // Prevent infinite loop if(GetGameTime()-g_fSpawnTime[client] > 0.5) Tele_Level(client, LEVEL_START); } - + if(IsClientInGame(client) && IsPlayerAlive(client)) { if(g_Settings[NoblockEnable]) SetNoBlock(client); else SetBlock(client); } - + g_fSpawnTime[client] = GetGameTime(); } @@ -2690,11 +2648,11 @@ bool:AddMapZone(String:map[], MapZoneType:type, String:name[], level_id, Float:p { if (g_hSQL == INVALID_HANDLE) ConnectSQL(); - + if (g_hSQL != INVALID_HANDLE) { decl String:query[512]; - + if ((type == ZtStart && !g_Settings[AllowMultipleStart]) || (type == ZtEnd && !g_Settings[AllowMultipleEnd]) || (type == ZtBonusStart && !g_Settings[AllowMultipleBonusStart]) @@ -2702,18 +2660,18 @@ bool:AddMapZone(String:map[], MapZoneType:type, String:name[], level_id, Float:p { decl String:deleteQuery[256]; FormatEx(deleteQuery, sizeof(deleteQuery), "DELETE FROM mapzone WHERE map = '%s' AND type = %d;", map, type); - - SQL_TQuery(g_hSQL, MapZoneChangedCallback, deleteQuery, _, DBPrio_High); + + SQL_TQuery(g_hSQL, MapZoneChangedCallback, deleteQuery, _, DBPrio_High); } - + //add new zone FormatEx(query, sizeof(query), "INSERT INTO mapzone (map, type, name, level_id, point1_x, point1_y, point1_z, point2_x, point2_y, point2_z) VALUES ('%s','%d','%s','%d', %f, %f, %f, %f, %f, %f);", map, type, name, level_id, point1[0], point1[1], point1[2], point2[0], point2[1], point2[2]); - + SQL_TQuery(g_hSQL, MapZoneChangedCallback, query, StrEqual(map, g_currentMap), DBPrio_Normal); - + return true; } - + return false; } @@ -2724,7 +2682,7 @@ public MapZoneChangedCallback(Handle:owner, Handle:hndl, const String:error[], a Timer_LogError("SQL Error on AddMapZone: %s", error); return; } - + if(data) { if(g_timerMapTier) @@ -2747,10 +2705,10 @@ bool:LoadMapZones() decl String:query[512]; FormatEx(query, sizeof(query), "SELECT * FROM mapzone WHERE map = '%s' ORDER BY level_id ASC;", g_currentMap); SQL_TQuery(g_hSQL, LoadMapZonesCallback, query, _, DBPrio_High); - + return true; } - + return false; } @@ -2758,44 +2716,51 @@ bool:LoadMapZones() public LoadMapZonesCallback(Handle:owner, Handle:hndl, const String:error[], any:data) { g_bZonesLoaded = false; - + if (hndl == INVALID_HANDLE) { Timer_LogError("SQL Error on LoadMapZones: %s", error); return; } - + g_mapZonesCount = 0; DeleteAllZoneEntitys(); - + while (SQL_FetchRow(hndl)) { strcopy(g_mapZones[g_mapZonesCount][Map], 64, g_currentMap); - + g_mapZones[g_mapZonesCount][Id] = SQL_FetchInt(hndl, 0); g_mapZones[g_mapZonesCount][Type] = MapZoneType:SQL_FetchInt(hndl, 1); g_mapZones[g_mapZonesCount][Level_Id] = SQL_FetchInt(hndl, 2); - + g_mapZones[g_mapZonesCount][Point1][0] = SQL_FetchFloat(hndl, 3); g_mapZones[g_mapZonesCount][Point1][1] = SQL_FetchFloat(hndl, 4); g_mapZones[g_mapZonesCount][Point1][2] = SQL_FetchFloat(hndl, 5); - + g_mapZones[g_mapZonesCount][Point2][0] = SQL_FetchFloat(hndl, 6); g_mapZones[g_mapZonesCount][Point2][1] = SQL_FetchFloat(hndl, 7); g_mapZones[g_mapZonesCount][Point2][2] = SQL_FetchFloat(hndl, 8); - + + if(g_mapZones[g_mapZonesCount][Point2][2] < g_mapZones[g_mapZonesCount][Point1][2]) + { + new Float:buffer = g_mapZones[g_mapZonesCount][Point2][2]; + g_mapZones[g_mapZonesCount][Point2][2] = g_mapZones[g_mapZonesCount][Point1][2]; + g_mapZones[g_mapZonesCount][Point1][2] = buffer; + } + decl String:ZoneName[32]; SQL_FetchString(hndl, 10, ZoneName, sizeof(ZoneName)); FormatEx(g_mapZones[g_mapZonesCount][zName], 32, "%s", ZoneName); - + SpawnZoneEntitys(g_mapZonesCount); - + g_mapZonesCount++; } - + g_bZonesLoaded = true; g_bSpawnSpotlights = false; - + /* Forwards */ Call_StartForward(g_OnMapZonesLoaded); Call_Finish(); @@ -2817,7 +2782,7 @@ public OnTimerSqlStop() ConnectSQL() { g_hSQL = Handle:Timer_SqlGetConnection(); - + if (g_hSQL == INVALID_HANDLE) CreateTimer(0.1, Timer_SQLReconnect, _ , TIMER_FLAG_NO_MAPCHANGE); else @@ -2836,38 +2801,38 @@ public OnAdminMenuReady(Handle:topmenu) if (topmenu == hTopMenu) { return; } - + // Save the Handle hTopMenu = topmenu; - + if ((oMapZoneMenu = FindTopMenuCategory(topmenu, "Timer Zones")) == INVALID_TOPMENUOBJECT) { oMapZoneMenu = AddToTopMenu(hTopMenu,"Timer Zones",TopMenuObject_Category,AdminMenu_CategoryHandler,INVALID_TOPMENUOBJECT); } - + AddToTopMenu(hTopMenu, "timer_mapzones_add",TopMenuObject_Item,AdminMenu_AddMapZone, - oMapZoneMenu,"timer_mapzones_add",ADMFLAG_RCON); - + oMapZoneMenu,"timer_mapzones_add",ADMFLAG_BAN); + AddToTopMenu(hTopMenu, "timer_mapzones_remove",TopMenuObject_Item,AdminMenu_RemoveMapZone, - oMapZoneMenu,"timer_mapzones_remove",ADMFLAG_RCON); - + oMapZoneMenu,"timer_mapzones_remove",ADMFLAG_BAN); + AddToTopMenu(hTopMenu, "timer_mapzones_remove_all",TopMenuObject_Item,AdminMenu_RemoveAllMapZones, - oMapZoneMenu,"timer_mapzones_remove_all",ADMFLAG_RCON); - + oMapZoneMenu,"timer_mapzones_remove_all",ADMFLAG_BAN); + AddToTopMenu(hTopMenu, "sm_npc_next",TopMenuObject_Item,AdminMenu_NPC, - oMapZoneMenu,"sm_npc_next",ADMFLAG_RCON); - + oMapZoneMenu,"sm_npc_next",ADMFLAG_BAN); + AddToTopMenu(hTopMenu, "sm_zoneadminmode",TopMenuObject_Item,AdminMenu_AdminMode, - oMapZoneMenu,"sm_zoneadminmode",ADMFLAG_CHANGEMAP); - + oMapZoneMenu,"sm_zoneadminmode",ADMFLAG_BAN); + AddToTopMenu(hTopMenu, "sm_zonereload",TopMenuObject_Item,AdminMenu_Reload, - oMapZoneMenu,"sm_zonereload",ADMFLAG_CHANGEMAP); - + oMapZoneMenu,"sm_zonereload",ADMFLAG_BAN); + AddToTopMenu(hTopMenu, "sm_zone",TopMenuObject_Item,AdminMenu_Teleport, - oMapZoneMenu,"sm_zone",ADMFLAG_CHANGEMAP); + oMapZoneMenu,"sm_zone",ADMFLAG_BAN); } -public AdminMenu_CategoryHandler(Handle:topmenu, +public AdminMenu_CategoryHandler(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, @@ -2881,7 +2846,7 @@ public AdminMenu_CategoryHandler(Handle:topmenu, } } -public AdminMenu_AddMapZone(Handle:topmenu, +public AdminMenu_AddMapZone(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, @@ -2901,7 +2866,7 @@ StartAddingZone(client) DisplaySelectPointMenu(client, 1); } -public AdminMenu_RemoveMapZone(Handle:topmenu, +public AdminMenu_RemoveMapZone(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, @@ -2915,7 +2880,7 @@ public AdminMenu_RemoveMapZone(Handle:topmenu, } } -public AdminMenu_RemoveAllMapZones(Handle:topmenu, +public AdminMenu_RemoveAllMapZones(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, @@ -2924,7 +2889,7 @@ public AdminMenu_RemoveAllMapZones(Handle:topmenu, { if (action == TopMenuAction_DisplayOption) { FormatEx(buffer, maxlength, "Delete All Zones"); - } else if (action == TopMenuAction_SelectOption) + } else if (action == TopMenuAction_SelectOption) { if(param == 0) DeleteAllMapZones(param); @@ -2932,7 +2897,7 @@ public AdminMenu_RemoveAllMapZones(Handle:topmenu, } } -public AdminMenu_NPC(Handle:topmenu, +public AdminMenu_NPC(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, @@ -2941,13 +2906,13 @@ public AdminMenu_NPC(Handle:topmenu, { if (action == TopMenuAction_DisplayOption) { FormatEx(buffer, maxlength, "Create NPC Teleporter"); - } else if (action == TopMenuAction_SelectOption) + } else if (action == TopMenuAction_SelectOption) { CreateNPC(param, 0); } } -public AdminMenu_AdminMode(Handle:topmenu, +public AdminMenu_AdminMode(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, @@ -2956,14 +2921,14 @@ public AdminMenu_AdminMode(Handle:topmenu, { if (action == TopMenuAction_DisplayOption) { FormatEx(buffer, maxlength, "Toggle Admin Mode"); - } else if (action == TopMenuAction_SelectOption) + } else if (action == TopMenuAction_SelectOption) { if(adminmode == 0) { CPrintToChatAll("%s Adminmode enabled!", PLUGIN_PREFIX2); adminmode = 1; } - else + else { CPrintToChatAll("%s Adminmode disabled!", PLUGIN_PREFIX2); adminmode = 0; @@ -2971,7 +2936,7 @@ public AdminMenu_AdminMode(Handle:topmenu, } } -public AdminMenu_Reload(Handle:topmenu, +public AdminMenu_Reload(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, @@ -2980,14 +2945,14 @@ public AdminMenu_Reload(Handle:topmenu, { if (action == TopMenuAction_DisplayOption) { FormatEx(buffer, maxlength, "Zone Reload"); - } else if (action == TopMenuAction_SelectOption) + } else if (action == TopMenuAction_SelectOption) { CPrintToChatAll("%s Zones Reloaded!", PLUGIN_PREFIX2); LoadMapZones(); } } -public AdminMenu_Teleport(Handle:topmenu, +public AdminMenu_Teleport(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, @@ -2996,7 +2961,7 @@ public AdminMenu_Teleport(Handle:topmenu, { if (action == TopMenuAction_DisplayOption) { FormatEx(buffer, maxlength, "Zone Teleport"); - } else if (action == TopMenuAction_SelectOption) + } else if (action == TopMenuAction_SelectOption) { AdminZoneTeleport(param); } @@ -3007,17 +2972,17 @@ DeleteMapZonesMenu(client) if (0 < client < MaxClients) { new Handle:menu = CreateMenu(Handle_DeleteMapZonesMenu); - + SetMenuTitle(menu, "Are you sure!"); - - AddMenuItem(menu, "no", "Oh no"); + AddMenuItem(menu, "no", "Oh no"); AddMenuItem(menu, "no", "Oh no"); - AddMenuItem(menu, "yes", "!!! YES DELETE ALL ZONES !!!"); AddMenuItem(menu, "no", "Oh no"); + AddMenuItem(menu, "yes", "!!! YES DELETE ALL ZONES !!!"); AddMenuItem(menu, "no", "Oh no"); AddMenuItem(menu, "no", "Oh no"); - + AddMenuItem(menu, "no", "Oh no"); + DisplayMenu(menu, client, MENU_TIME_FOREVER); } } @@ -3045,10 +3010,10 @@ ResetMapZoneEditor(client) if(client) { g_mapZoneEditors[client][Step] = 0; - + for (new i = 0; i < 3; i++) g_mapZoneEditors[client][Point1][i] = 0.0; - + for (new i = 0; i < 3; i++) g_mapZoneEditors[client][Point1][i] = 0.0; } @@ -3058,15 +3023,15 @@ DeleteMapZone(client) { new Float:vec[3]; GetClientAbsOrigin(client, vec); - + for (new zone = 0; zone < g_mapZonesCount; zone++) { if (IsInsideBox(vec, g_mapZones[zone][Point1][0], g_mapZones[zone][Point1][1], g_mapZones[zone][Point1][2], g_mapZones[zone][Point2][0], g_mapZones[zone][Point2][1], g_mapZones[zone][Point2][2])) { decl String:query[64]; FormatEx(query, sizeof(query), "DELETE FROM mapzone WHERE id = %d", g_mapZones[zone][Id]); - - SQL_TQuery(g_hSQL, DeleteMapZoneCallback, query, client, DBPrio_Normal); + + SQL_TQuery(g_hSQL, DeleteMapZoneCallback, query, client, DBPrio_Normal); break; } } @@ -3076,7 +3041,7 @@ DeleteAllMapZones(client) { decl String:query[256]; FormatEx(query, sizeof(query), "DELETE FROM mapzone WHERE map = '%s'", g_currentMap); - + SQL_TQuery(g_hSQL, DeleteMapZoneCallback, query, client, DBPrio_Normal); } @@ -3087,9 +3052,9 @@ public DeleteMapZoneCallback(Handle:owner, Handle:hndl, const String:error[], an Timer_LogError("SQL Error on DeleteMapZone: %s", error); return; } - + LoadMapZones(); - + if (IsClientInGame(data)) CPrintToChat(data, PLUGIN_PREFIX, "Map Zone Delete"); } @@ -3097,19 +3062,19 @@ public DeleteMapZoneCallback(Handle:owner, Handle:hndl, const String:error[], an DisplaySelectPointMenu(client, n) { new Handle:panel = CreatePanel(); - + decl String:message[255]; decl String:first[32], String:second[32]; FormatEx(first, sizeof(first), "%t", "FIRST"); FormatEx(second, sizeof(second), "%t", "SECOND"); - + FormatEx(message, sizeof(message), "%t", "Point Select Panel", (n == 1) ? first : second); - + DrawPanelItem(panel, message, ITEMDRAW_RAWLINE); - + FormatEx(message, sizeof(message), "%t", "Cancel"); DrawPanelItem(panel, message); - + SendPanelToClient(panel, client, PointSelect, 540); CloseHandle(panel); } @@ -3117,28 +3082,28 @@ DisplaySelectPointMenu(client, n) DisplayPleaseWaitMenu(client) { new Handle:panel = CreatePanel(); - + decl String:wait[64]; FormatEx(wait, sizeof(wait), "%t", "Please wait"); DrawPanelItem(panel, wait, ITEMDRAW_RAWLINE); - + SendPanelToClient(panel, client, PointSelect, 540); CloseHandle(panel); } public PointSelect(Handle:menu, MenuAction:action, param1, param2) { - if (action == MenuAction_End) + if (action == MenuAction_End) { CloseHandle(menu); - } - else if (action == MenuAction_Select) + } + else if (action == MenuAction_Select) { - if (param2 == MenuCancel_Exit && hTopMenu != INVALID_HANDLE) + if (param2 == MenuCancel_Exit && hTopMenu != INVALID_HANDLE) { DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory); } - + ResetMapZoneEditor(param1); } } @@ -3146,10 +3111,10 @@ public PointSelect(Handle:menu, MenuAction:action, param1, param2) public Action:ChangeStep(Handle:timer, any:serial) { new client = GetClientFromSerial(serial); - + g_mapZoneEditors[client][Step] = 2; CreateTimer(0.1, DrawAdminBox, GetClientSerial(client), TIMER_REPEAT); - + DisplaySelectPointMenu(client, 2); } @@ -3164,7 +3129,7 @@ stock CheckIllegalTeleport(client) { return true; } - + return false; } @@ -3174,26 +3139,26 @@ stock CreateNPC(client, step, bool:double = false) { if(!IsClientInGame(client)) return; - + if(step == 0) { new Float:vec[3]; GetClientAbsOrigin(client, vec); g_mapZoneEditors[client][Point1] = vec; new Handle:menu = CreateMenu(Handle_Menu_NPC); - + SetMenuTitle(menu, "Timer Menu"); - + AddMenuItem(menu, "npc_reset", "Reset NPC Point"); AddMenuItem(menu, "dest", "Set Destination (Teammate)"); AddMenuItem(menu, "dest_double", "Set Destination (Both Players)"); - + DisplayMenu(menu, client, MENU_TIME_FOREVER); } else { new String:lvlbuffer[32]; - + new hcount = LEVEL_START; for (new zone = 0; zone < g_mapZonesCount; zone++) { @@ -3201,21 +3166,21 @@ stock CreateNPC(client, step, bool:double = false) if(g_mapZones[zone][Level_Id] <= hcount) continue; hcount = g_mapZones[zone][Level_Id]; } - + hcount++; - + FormatEx(lvlbuffer, sizeof(lvlbuffer), "Level %d", hcount); - + new Float:vec[3]; GetClientAbsOrigin(client, vec); g_mapZoneEditors[client][Point2] = vec; - + new Float:point1[3]; Array_Copy(g_mapZoneEditors[client][Point1], point1, 3); - + new Float:point2[3]; Array_Copy(g_mapZoneEditors[client][Point2], point2, 3); - + if(!double) { if(!AddMapZone(g_currentMap, MapZoneType:ZtNPC_Next, lvlbuffer, hcount, point1, point2)) @@ -3257,23 +3222,23 @@ public Handle_Menu_NPC(Handle:menu, MenuAction:action, client, itemNum) public Action:DrawAdminBox(Handle:timer, any:serial) { new client = GetClientFromSerial(serial); - + if (g_mapZoneEditors[client][Step] == 0) { return Plugin_Stop; } - + new Float:a[3], Float:b[3]; - + Array_Copy(g_mapZoneEditors[client][Point1], b, 3); - + if (g_mapZoneEditors[client][Step] == 3) Array_Copy(g_mapZoneEditors[client][Point2], a, 3); else GetClientAbsOrigin(client, a); - + new color[4] = {255, 255, 255, 255}; - + DrawBox(a, b, 0.1, color, false); return Plugin_Continue; } @@ -3284,15 +3249,15 @@ public Action:DrawZones(Handle:timer) { new Float:point1[3]; Array_Copy(g_mapZones[zone][Point1], point1, 3); - + new Float:point2[3]; Array_Copy(g_mapZones[zone][Point2], point2, 3); - + if (point1[2] < point2[2]) point2[2] = point1[2]; else point1[2] = point2[2]; - + if (g_mapZones[zone][Type] == ZtStart) DrawBox(point1, point2, 1.0, g_startColor, true, precache_laser_start); else if (g_mapZones[zone][Type] == ZtEnd) @@ -3302,7 +3267,7 @@ public Action:DrawZones(Handle:timer) else if (g_mapZones[zone][Type] == ZtBonusEnd || g_mapZones[zone][Type] == ZtBonus2End || g_mapZones[zone][Type] == ZtBonus3End || g_mapZones[zone][Type] == ZtBonus4End || g_mapZones[zone][Type] == ZtBonus5End) DrawBox(point1, point2, 1.0, g_bonusendColor, true, precache_laser_bonus_end); } - + return Plugin_Continue; } @@ -3312,10 +3277,10 @@ DrawZone(zone, bool:flat) { new Float:point1[3]; Array_Copy(g_mapZones[zone][Point1], point1, 3); - + new Float:point2[3]; Array_Copy(g_mapZones[zone][Point2], point2, 3); - + if(flat) { if (point1[2] < point2[2]) @@ -3323,7 +3288,7 @@ DrawZone(zone, bool:flat) else point1[2] = point2[2]; } - + if(flat) { if (g_mapZones[zone][Type] == ZtStop) @@ -3347,7 +3312,7 @@ DrawZone(zone, bool:flat) { DrawBox(point1, point2, 1.0, g_startColor, flat); } - + g_MapZoneDrawDelayTimer[zone] = CreateTimer(2.0, Timer_DelayDraw, zone, TIMER_FLAG_NO_MAPCHANGE); } } @@ -3355,7 +3320,7 @@ DrawZone(zone, bool:flat) public Action:Timer_DelayDraw(Handle:timer, any:zone) { g_MapZoneDrawDelayTimer[zone] = INVALID_HANDLE; - + return Plugin_Stop; } @@ -3363,13 +3328,13 @@ public TraceToEntity(client) { new Float:vecClientEyePos[3], Float:vecClientEyeAng[3]; GetClientEyePosition(client, vecClientEyePos); - GetClientEyeAngles(client, vecClientEyeAng); - + GetClientEyeAngles(client, vecClientEyeAng); + TR_TraceRayFilter(vecClientEyePos, vecClientEyeAng, MASK_PLAYERSOLID, RayType_Infinite, TraceASDF, client); - + if (TR_DidHit(INVALID_HANDLE)) return (TR_GetEntityIndex(INVALID_HANDLE)); - + return (-1); } @@ -3384,6 +3349,14 @@ bool:IsPlayerTouchingSpeedZone(client) return true; if(g_bPreSpeedBonusStart && Timer_IsPlayerTouchingZoneType(client, ZtBonusStart)) return true; + if(g_bPreSpeedBonusStart && Timer_IsPlayerTouchingZoneType(client, ZtBonus2Start)) + return true; + if(g_bPreSpeedBonusStart && Timer_IsPlayerTouchingZoneType(client, ZtBonus3Start)) + return true; + if(g_bPreSpeedBonusStart && Timer_IsPlayerTouchingZoneType(client, ZtBonus4Start)) + return true; + if(g_bPreSpeedBonusStart && Timer_IsPlayerTouchingZoneType(client, ZtBonus5Start)) + return true; if(Timer_IsPlayerTouchingZoneType(client, ZtLimitSpeed)) return true; if(Timer_IsPlayerTouchingZoneType(client, ZtFullBooster)) @@ -3404,7 +3377,7 @@ bool:IsPlayerTouchingSpeedZone(client) return true; if(Timer_IsPlayerTouchingZoneType(client, ZtHover)) return true; - + return false; } @@ -3422,18 +3395,18 @@ ChangePlayerVelocity(client) return; if(g_mapZonesCount < 1) return; - + new Float:vec[3]; GetClientAbsOrigin(client, vec); - + new style = Timer_GetStyle(client); new Float:maxspeed = g_Physics[style][StyleBlockPreSpeeding]; - + if(!IsPlayerTouchingSpeedZone(client)) return; - + new Float:push_maxspeed = GetEntPropFloat(client, Prop_Send, "m_flMaxspeed"); - + if (Timer_IsPlayerTouchingZoneType(client, ZtFullBooster)) { CheckVelocity(client, 4, maxspeed); @@ -3500,29 +3473,29 @@ IsInsideBox(Float:fPCords[3], Float:fbsx, Float:fbsy, Float:fbsz, Float:fbex, Fl new Float:fpx = fPCords[0]; new Float:fpy = fPCords[1]; new Float:fpz = fPCords[2]+30; - + new bool:bX = false; new bool:bY = false; new bool:bZ = false; - + if (fbsx > fbex && fpx <= fbsx && fpx >= fbex) bX = true; else if (fbsx < fbex && fpx >= fbsx && fpx <= fbex) bX = true; - + if (fbsy > fbey && fpy <= fbsy && fpy >= fbey) bY = true; else if (fbsy < fbey && fpy >= fbsy && fpy <= fbey) bY = true; - + if (fbsz > fbez && fpz <= fbsz && fpz >= fbez) bZ = true; else if (fbsz < fbez && fpz >= fbsz && fpz <= fbez) bZ = true; - + if (bX && bY && bZ) return true; - + return false; } @@ -3530,7 +3503,7 @@ DrawBox(Float:fFrom[3], Float:fTo[3], Float:fLife, color[4], bool:flat, iSpriteI { if(iSpriteIndex == 0) iSpriteIndex = precache_laser_default; - + if(g_Settings[ZoneSprites] || !flat) { //initialize tempoary variables bottom front @@ -3541,7 +3514,7 @@ DrawBox(Float:fFrom[3], Float:fTo[3], Float:fLife, color[4], bool:flat, iSpriteI fLeftBottomFront[2] = fTo[2]-g_Settings[ZoneBeamHeight]; else fLeftBottomFront[2] = fTo[2]; - + decl Float:fRightBottomFront[3]; fRightBottomFront[0] = fTo[0]; fRightBottomFront[1] = fFrom[1]; @@ -3549,7 +3522,7 @@ DrawBox(Float:fFrom[3], Float:fTo[3], Float:fLife, color[4], bool:flat, iSpriteI fRightBottomFront[2] = fTo[2]-g_Settings[ZoneBeamHeight]; else fRightBottomFront[2] = fTo[2]; - + //initialize tempoary variables bottom back decl Float:fLeftBottomBack[3]; fLeftBottomBack[0] = fFrom[0]; @@ -3558,7 +3531,7 @@ DrawBox(Float:fFrom[3], Float:fTo[3], Float:fLife, color[4], bool:flat, iSpriteI fLeftBottomBack[2] = fTo[2]-g_Settings[ZoneBeamHeight]; else fLeftBottomBack[2] = fTo[2]; - + decl Float:fRightBottomBack[3]; fRightBottomBack[0] = fTo[0]; fRightBottomBack[1] = fTo[1]; @@ -3566,7 +3539,7 @@ DrawBox(Float:fFrom[3], Float:fTo[3], Float:fLife, color[4], bool:flat, iSpriteI fRightBottomBack[2] = fTo[2]-g_Settings[ZoneBeamHeight]; else fRightBottomBack[2] = fTo[2]; - + //initialize tempoary variables top front decl Float:fLeftTopFront[3]; fLeftTopFront[0] = fFrom[0]; @@ -3582,7 +3555,7 @@ DrawBox(Float:fFrom[3], Float:fTo[3], Float:fLife, color[4], bool:flat, iSpriteI fRightTopFront[2] = fFrom[2]+g_Settings[ZoneBeamHeight]; else fRightTopFront[2] = fFrom[2]; - + //initialize tempoary variables top back decl Float:fLeftTopBack[3]; fLeftTopBack[0] = fFrom[0]; @@ -3598,29 +3571,29 @@ DrawBox(Float:fFrom[3], Float:fTo[3], Float:fLife, color[4], bool:flat, iSpriteI fRightTopBack[2] = fFrom[2]+g_Settings[ZoneBeamHeight]; else fRightTopBack[2] = fFrom[2]; - + new Float:width = g_Settings[ZoneBeamThickness]; - + if(flat == false) width = 0.5; - + //create the box TE_SetupBeamPoints(fLeftTopFront,fRightTopFront,iSpriteIndex,0,0,0,0.99,width,width,10,0.0,color,10);TE_SendToAll(0.0); TE_SetupBeamPoints(fLeftTopBack,fLeftTopFront,iSpriteIndex,0,0,0,0.99,width,width,10,0.0,color,10);TE_SendToAll(0.0); TE_SetupBeamPoints(fRightTopBack,fLeftTopBack,iSpriteIndex,0,0,0,0.99,width,width,10,0.0,color,10);TE_SendToAll(0.0); TE_SetupBeamPoints(fRightTopFront,fRightTopBack,iSpriteIndex,0,0,0,0.99,width,width,10,0.0,color,10);TE_SendToAll(0.0); - + if(!flat) { TE_SetupBeamPoints(fRightBottomFront,fLeftBottomFront,iSpriteIndex,0,0,0,fLife,width,width,0,0.0,color,0);TE_SendToAll(0.0); TE_SetupBeamPoints(fLeftBottomBack,fLeftBottomFront,iSpriteIndex,0,0,0,fLife,width,width,0,0.0,color,0);TE_SendToAll(0.0); TE_SetupBeamPoints(fLeftTopFront,fLeftBottomFront,iSpriteIndex,0,0,0,fLife,width,width,0,0.0,color,0);TE_SendToAll(0.0); - - + + TE_SetupBeamPoints(fLeftBottomBack,fRightBottomBack,iSpriteIndex,0,0,0,fLife,width,width,0,0.0,color,0);TE_SendToAll(0.0); TE_SetupBeamPoints(fRightBottomFront,fRightBottomBack,iSpriteIndex,0,0,0,fLife,width,width,0,0.0,color,0);TE_SendToAll(0.0); TE_SetupBeamPoints(fRightTopBack,fRightBottomBack,iSpriteIndex,0,0,0,fLife,width,width,0,0.0,color,0);TE_SendToAll(0.0); - + TE_SetupBeamPoints(fRightTopFront,fRightBottomFront,iSpriteIndex,0,0,0,fLife,width,width,0,0.0,color,0);TE_SendToAll(0.0); TE_SetupBeamPoints(fLeftTopBack,fLeftBottomBack,iSpriteIndex,0,0,0,fLife,width,width,0,0.0,color,0);TE_SendToAll(0.0); } @@ -3851,28 +3824,28 @@ stock ZoneEffectTesla(targetzone) TeleportEntity(laserent, center, zero, zero); - AcceptEntityInput(laserent, "TurnOn"); + AcceptEntityInput(laserent, "TurnOn"); AcceptEntityInput(laserent, "DoSpark"); } GetZoneEntityCount() { new count; - + for (new i = MaxClients; i <= 2047; i++) { if(!IsValidEntity(i)) continue; - + new String:EntName[256]; Entity_GetName(i, EntName, sizeof(EntName)); - + new valid = StrContains(EntName, "#TIMER_"); if(valid > -1) { count++; } } - + return count; } @@ -3882,25 +3855,25 @@ DeleteAllZoneEntitys() { g_MapZoneDrawDelayTimer[i] = INVALID_HANDLE; g_MapZoneEntityZID[i] = -1; - + if(!IsValidEntity(i)) continue; - + new String:EntName[256]; Entity_GetName(i, EntName, sizeof(EntName)); - + if(StrContains(EntName, "#TIMER_NPC") != -1) SDKUnhook(i, SDKHook_StartTouch, NPC_Use); - + if(StrContains(EntName, "#TIMER_TRIGGER") != -1) { SDKUnhook(i, SDKHook_StartTouch, StartTouchTrigger); SDKUnhook(i, SDKHook_EndTouch, EndTouchTrigger); SDKUnhook(i, SDKHook_Touch, OnTouchTrigger); } - + if(StrContains(EntName, "#TIMER_") != -1) DeleteEntity(i); - + for (new client = 1; client <= MaxClients; client++) g_bZone[i][client] = false; } @@ -3918,13 +3891,13 @@ SpawnZoneEntitys(zone) // No valid zone return; } - + //Spawn debug entitys ine each corner if(adminmode == 1) { SpawnZoneDebugEntitys(zone); } - + //Spawn NPCs if(g_mapZones[zone][Type] == ZtNPC_Next || g_mapZones[zone][Type] == ZtNPC_Next_Double) { @@ -3940,27 +3913,27 @@ SpawnZoneEntitys(zone) { SpawnZoneTrigger(zone); } - + //Spawn spot lights if(g_bSpawnSpotlights && g_Settings[ZoneSpotlights]) { - if(g_mapZones[zone][Type] == ZtStart || - g_mapZones[zone][Type] == ZtEnd || - g_mapZones[zone][Type] == ZtLevel || - g_mapZones[zone][Type] == ZtBonusStart || - g_mapZones[zone][Type] == ZtBonus2Start || - g_mapZones[zone][Type] == ZtBonus3Start || - g_mapZones[zone][Type] == ZtBonus4Start || - g_mapZones[zone][Type] == ZtBonus5Start || - g_mapZones[zone][Type] == ZtBonusEnd || - g_mapZones[zone][Type] == ZtBonus2End || - g_mapZones[zone][Type] == ZtBonus3End || - g_mapZones[zone][Type] == ZtBonus4End || - g_mapZones[zone][Type] == ZtBonus5End || - g_mapZones[zone][Type] == ZtBonusLevel || - g_mapZones[zone][Type] == ZtBonus2Level || - g_mapZones[zone][Type] == ZtBonus3Level || - g_mapZones[zone][Type] == ZtBonus4Level || + if(g_mapZones[zone][Type] == ZtStart || + g_mapZones[zone][Type] == ZtEnd || + g_mapZones[zone][Type] == ZtLevel || + g_mapZones[zone][Type] == ZtBonusStart || + g_mapZones[zone][Type] == ZtBonus2Start || + g_mapZones[zone][Type] == ZtBonus3Start || + g_mapZones[zone][Type] == ZtBonus4Start || + g_mapZones[zone][Type] == ZtBonus5Start || + g_mapZones[zone][Type] == ZtBonusEnd || + g_mapZones[zone][Type] == ZtBonus2End || + g_mapZones[zone][Type] == ZtBonus3End || + g_mapZones[zone][Type] == ZtBonus4End || + g_mapZones[zone][Type] == ZtBonus5End || + g_mapZones[zone][Type] == ZtBonusLevel || + g_mapZones[zone][Type] == ZtBonus2Level || + g_mapZones[zone][Type] == ZtBonus3Level || + g_mapZones[zone][Type] == ZtBonus4Level || g_mapZones[zone][Type] == ZtBonus5Level) { SpawnZoneSpotLights(zone); @@ -3975,19 +3948,19 @@ SpawnZoneTrigger(zone) center[0] = (g_mapZones[zone][Point1][0] + g_mapZones[zone][Point2][0]) / 2.0; center[1] = (g_mapZones[zone][Point1][1] + g_mapZones[zone][Point2][1]) / 2.0; center[2] = g_mapZones[zone][Point1][2]; - + // Min & max bounds - new Float:minbounds[3]; - new Float:maxbounds[3]; - + new Float:minbounds[3]; + new Float:maxbounds[3]; + minbounds[0] = FloatAbs(g_mapZones[zone][Point1][0]-g_mapZones[zone][Point2][0]) / -2.0; minbounds[1] = FloatAbs(g_mapZones[zone][Point1][1]-g_mapZones[zone][Point2][1]) / -2.0; minbounds[2] = -1.0; // Just to be save it's not buggy like a defective contact - + maxbounds[0] = FloatAbs(g_mapZones[zone][Point1][0]-g_mapZones[zone][Point2][0]) / 2.0; maxbounds[1] = FloatAbs(g_mapZones[zone][Point1][1]-g_mapZones[zone][Point2][1]) / 2.0; maxbounds[2] = FloatAbs(g_mapZones[zone][Point1][2]-g_mapZones[zone][Point2][2]); - + // Resize trigger (by default it's set to 16.0). A player is 32.0 unity wide, so we need to resize the trigger to have a touching border between the legs minbounds[0] += g_Settings[ZoneResize]; minbounds[1] += g_Settings[ZoneResize]; @@ -3995,17 +3968,17 @@ SpawnZoneTrigger(zone) maxbounds[0] -= g_Settings[ZoneResize]; maxbounds[1] -= g_Settings[ZoneResize]; maxbounds[2] -= g_Settings[ZoneResize]; - + // Spawn trigger new entity = CreateEntityByName("trigger_multiple"); if (entity > 0) { // Attach zoneID to the entity g_MapZoneEntityZID[entity] = zone; - + // Give our trigger_multiple a model (It's totally unimportant which one you are using) - SetEntityModel(entity, "models/props_junk/wood_crate001a.mdl"); - + SetEntityModel(entity, "models/props_junk/wood_crate001a.mdl"); + if(IsValidEntity(entity)) { // Spawnflags for "trigger_multiple" @@ -4016,29 +3989,29 @@ SpawnZoneTrigger(zone) // 16 - only non-player NPCs can trigger this by touch // 128 - Start off, has to be activated by a target_activate to be touchable/usable // 256 - multiple players can trigger the entity at the same time - - DispatchKeyValue(entity, "spawnflags", "257"); - + + DispatchKeyValue(entity, "spawnflags", "257"); + DispatchKeyValue(entity, "StartDisabled", "0"); - + // Give our entity a unique name tag, so we can delete it also if the plugins was reloaded without deleting them new String:EntName[256]; FormatEx(EntName, sizeof(EntName), "#TIMER_Trigger_%d", g_mapZones[zone][Id]); DispatchKeyValue(entity, "targetname", EntName); - + if(DispatchSpawn(entity)) { ActivateEntity(entity); - + // Set the size of our trigger_multiple box SetEntPropVector(entity, Prop_Send, "m_vecMins", minbounds); SetEntPropVector(entity, Prop_Send, "m_vecMaxs", maxbounds); - + SetEntProp(entity, Prop_Send, "m_nSolidType", 2); SetEntProp(entity, Prop_Send, "m_fEffects", GetEntProp(entity, Prop_Send, "m_fEffects") | 32); - + TeleportEntity(entity, center, NULL_VECTOR, NULL_VECTOR); - + SDKHook(entity, SDKHook_StartTouch, StartTouchTrigger); SDKHook(entity, SDKHook_EndTouch, EndTouchTrigger); SDKHook(entity, SDKHook_Touch, OnTouchTrigger); @@ -4053,36 +4026,36 @@ SpawnZoneSpotLights(zone) fFrom[0] = g_mapZones[zone][Point2][0]; fFrom[1] = g_mapZones[zone][Point2][1]; fFrom[2] = g_mapZones[zone][Point2][2]; - + new Float:fTo[3]; fTo[0] = g_mapZones[zone][Point1][0]; fTo[1] = g_mapZones[zone][Point1][1]; fTo[2] = g_mapZones[zone][Point1][2]; - + //initialize tempoary variables bottom front decl Float:fLeftBottomFront[3]; fLeftBottomFront[0] = fFrom[0]; fLeftBottomFront[1] = fFrom[1]; fLeftBottomFront[2] = fTo[2]+20; - + decl Float:fRightBottomFront[3]; fRightBottomFront[0] = fTo[0]; fRightBottomFront[1] = fFrom[1]; fRightBottomFront[2] = fTo[2]+20; - + //initialize tempoary variables bottom back decl Float:fLeftBottomBack[3]; fLeftBottomBack[0] = fFrom[0]; fLeftBottomBack[1] = fTo[1]; fLeftBottomBack[2] = fTo[2]+20; - + decl Float:fRightBottomBack[3]; fRightBottomBack[0] = fTo[0]; fRightBottomBack[1] = fTo[1]; fRightBottomBack[2] = fTo[2]+20; - + new Float:ang[3], Float:color[3]; - + if(g_mapZones[zone][Type] == ZtStart) { color[0] = float(g_startColor[0]); @@ -4119,9 +4092,9 @@ SpawnZoneSpotLights(zone) color[1] = float(g_bonusendColor[1]); color[2] = float(g_bonusendColor[2]); } - + ang[0] = -90.0; - + SpawnSpotLight(fLeftBottomFront, color, ang); SpawnSpotLight(fRightBottomFront, color, ang); SpawnSpotLight(fLeftBottomBack, color, ang); @@ -4131,47 +4104,47 @@ SpawnZoneSpotLights(zone) stock SpawnSpotLight(Float:pos[3], Float:color[3], Float:ang[3]) { pos[2] -= 16.0; - + new entity = CreateEntityByName("point_spotlight"); - + decl String:sAng[32]; Format(sAng, sizeof(sAng), "%d %d %d", RoundToFloor(ang[0]), RoundToFloor(ang[1]), RoundToFloor(ang[2])); - - + + decl String:EntName[256]; FormatEx(EntName, sizeof(EntName), "#TIMER_SPOTLIGHT_%d_%d_%d", RoundToFloor(pos[0]), RoundToFloor(pos[1]), RoundToFloor(pos[2])); DispatchKeyValue(entity, "targetname", EntName); - + DispatchKeyValue(entity, "SpotlightLength", "350"); DispatchKeyValue(entity, "SpotlightWidth", "25"); DispatchKeyValue(entity, "rendermode", "0"); DispatchKeyValue(entity, "scale", "1"); DispatchKeyValue(entity, "renderamt", "64"); DispatchKeyValueVector(entity, "rendercolor", color); - + DispatchKeyValue(entity, "HDRColorScale", "0.1"); DispatchKeyValue(entity, "HaloScale", "1"); DispatchKeyValue(entity, "fadescale", "1"); - + DispatchKeyValue(entity, "brightness", "1"); - + DispatchKeyValue(entity, "_light", "255 255 255 255"); DispatchKeyValue(entity, "style", "0"); - + DispatchKeyValue(entity, "pitch", "0 0 0"); DispatchKeyValue(entity, "renderamt", "255"); - + DispatchKeyValue(entity, "disablereceiveshadows", "1"); - + //-75 x 0 DispatchKeyValue(entity, "angles", sAng); - + DispatchKeyValue(entity, "spawnflags", "3"); - + DispatchSpawn(entity); - + TeleportEntity(entity, pos, NULL_VECTOR, NULL_VECTOR); - + AcceptEntityInput(entity, "LightOn"); } @@ -4181,12 +4154,12 @@ SpawnNPC(zone) vecNPC[0] = g_mapZones[zone][Point1][0]; vecNPC[1] = g_mapZones[zone][Point1][1]; vecNPC[2] = g_mapZones[zone][Point1][2]; - + new Float:vecDestination[3]; vecDestination[0] = g_mapZones[zone][Point2][0]; vecDestination[1] = g_mapZones[zone][Point2][1]; vecDestination[2] = g_mapZones[zone][Point2][2]; - + new String:ModePath[256]; if(g_mapZones[zone][Type] == ZtNPC_Next) { @@ -4198,24 +4171,24 @@ SpawnNPC(zone) PrecacheModel(g_Settings[NPC_Double_Path], true); FormatEx(ModePath, sizeof(ModePath), "%s", g_Settings[NPC_Double_Path]); } - + decl String:EntName[256]; FormatEx(EntName, sizeof(EntName), "#TIMER_NPC_%d", g_mapZones[zone][Id]); - + new String:Classname[] = "prop_physics_override"; - + new entity1 = CreateEntityByName(Classname); SetEntityModel(entity1, ModePath); - + DispatchKeyValue(entity1, "targetname", EntName); - + DispatchSpawn(entity1); AcceptEntityInput(entity1, "DisableMotion"); AcceptEntityInput(entity1, "DisableShadow"); TeleportEntity(entity1, vecNPC, NULL_VECTOR, NULL_VECTOR); - + g_mapZones[zone][NPC] = entity1; - + SDKHook(entity1, SDKHook_StartTouch, NPC_Use); } @@ -4225,59 +4198,59 @@ SpawnZoneDebugEntitys(zone) { if(g_mapZones[zone][Type] == ZtNPC_Next || g_mapZones[zone][Type] == ZtNPC_Next_Double) return; - + new Float:fFrom[3]; fFrom[0] = g_mapZones[zone][Point2][0]; fFrom[1] = g_mapZones[zone][Point2][1]; fFrom[2] = g_mapZones[zone][Point2][2]; - + new Float:fTo[3]; fTo[0] = g_mapZones[zone][Point1][0]; fTo[1] = g_mapZones[zone][Point1][1]; fTo[2] = g_mapZones[zone][Point1][2]; - + //initialize tempoary variables bottom front decl Float:fLeftBottomFront[3]; fLeftBottomFront[0] = fFrom[0]; fLeftBottomFront[1] = fFrom[1]; fLeftBottomFront[2] = fTo[2]+20; - + decl Float:fRightBottomFront[3]; fRightBottomFront[0] = fTo[0]; fRightBottomFront[1] = fFrom[1]; fRightBottomFront[2] = fTo[2]+20; - + //initialize tempoary variables bottom back decl Float:fLeftBottomBack[3]; fLeftBottomBack[0] = fFrom[0]; fLeftBottomBack[1] = fTo[1]; fLeftBottomBack[2] = fTo[2]+20; - + decl Float:fRightBottomBack[3]; fRightBottomBack[0] = fTo[0]; fRightBottomBack[1] = fTo[1]; fRightBottomBack[2] = fTo[2]+20; - + PrecacheModel("models/props_junk/trafficcone001a.mdl", true); - + decl String:EntName[256]; FormatEx(EntName, sizeof(EntName), "#TIMER_Zone_%d", g_mapZones[zone][Id]); - + new String:ModePath[] = "models/props_junk/trafficcone001a.mdl"; new String:Classname[] = "prop_physics_override"; - + new entity1 = CreateEntityByName(Classname); SetEntityModel(entity1, ModePath); SetEntProp(entity1, Prop_Data, "m_CollisionGroup", 1); SetEntProp(entity1, Prop_Send, "m_usSolidFlags", 12); SetEntProp(entity1, Prop_Send, "m_nSolidType", 6); - SetEntityMoveType(entity1, MOVETYPE_NONE); + SetEntityMoveType(entity1, MOVETYPE_NONE); DispatchKeyValue(entity1, "targetname", EntName); DispatchSpawn(entity1); AcceptEntityInput(entity1, "DisableMotion"); AcceptEntityInput(entity1, "DisableShadow"); TeleportEntity(entity1, fRightBottomBack, NULL_VECTOR, NULL_VECTOR); - + new entity2 = CreateEntityByName(Classname); SetEntityModel(entity2, ModePath); SetEntProp(entity2, Prop_Data, "m_CollisionGroup", 1); @@ -4289,7 +4262,7 @@ SpawnZoneDebugEntitys(zone) AcceptEntityInput(entity2, "DisableMotion"); AcceptEntityInput(entity2, "DisableShadow"); TeleportEntity(entity2, fRightBottomFront, NULL_VECTOR, NULL_VECTOR); - + new entity3 = CreateEntityByName(Classname); SetEntityModel(entity3, ModePath); SetEntProp(entity3, Prop_Data, "m_CollisionGroup", 1); @@ -4301,7 +4274,7 @@ SpawnZoneDebugEntitys(zone) AcceptEntityInput(entity3, "DisableMotion"); AcceptEntityInput(entity3, "DisableShadow"); TeleportEntity(entity3, fLeftBottomFront, NULL_VECTOR, NULL_VECTOR); - + new entity4 = CreateEntityByName(Classname); SetEntityModel(entity4, ModePath); SetEntProp(entity4, Prop_Data, "m_CollisionGroup", 1); @@ -4314,7 +4287,7 @@ SpawnZoneDebugEntitys(zone) AcceptEntityInput(entity4, "DisableMotion"); AcceptEntityInput(entity4, "DisableShadow"); TeleportEntity(entity4, fLeftBottomBack, NULL_VECTOR, NULL_VECTOR); - + if(g_mapZones[zone][Type] == ZtLevel || g_mapZones[zone][Type] == ZtStart || g_mapZones[zone][Type] == ZtEnd) { SetEntityRenderColor(entity1, 0, 255, 0, 200); @@ -4369,29 +4342,29 @@ Menu_NPC_Next(client, zone) { if (0 < client < MaxClients) { - + if(adminmode == 1 && Client_IsAdmin(client)) { new Handle:menu = CreateMenu(Handle_Menu_NPC_Delete); - + SetMenuTitle(menu, "Delete this NPC?"); - + AddMenuItem(menu, "yes", "Yes"); AddMenuItem(menu, "no", "No!"); - + DisplayMenu(menu, client, MENU_TIME_FOREVER); - + g_iTargetNPC[client] = zone; } else if(g_Settings[NPCConfirm]) { new Handle:menu = CreateMenu(Handle_Menu_NPC_Next); - + SetMenuTitle(menu, "Do you like to teleport?"); - + AddMenuItem(menu, "yes", "Yes Please"); AddMenuItem(menu, "no", "Not now!"); - + DisplayMenu(menu, client, MENU_TIME_FOREVER); } else @@ -4403,12 +4376,12 @@ Menu_NPC_Next(client, zone) vecDestination[0] = g_mapZones[g_iClientLastTrackZone[client]][Point2][0]; vecDestination[1] = g_mapZones[g_iClientLastTrackZone[client]][Point2][1]; vecDestination[2] = g_mapZones[g_iClientLastTrackZone[client]][Point2][2]; - - if(Timer_IsPlayerTouchingZoneType(client, ZtStart)) Timer_SetIgnoreEndTouchStart(client, 1); - + + if(Timer_IsPlayerTouchingStartZone(client)) Timer_SetIgnoreEndTouchStart(client, 1); + new mate; if(g_timerTeams) mate = Timer_GetClientTeammate(client); - + if(mate > 0) { if(g_mapZones[zone][Type] == ZtNPC_Next_Double) @@ -4416,7 +4389,7 @@ Menu_NPC_Next(client, zone) TeleportEntity(client, vecDestination, NULL_VECTOR, velStop); CreateTimer(1.5, SetBlockable, client, TIMER_FLAG_NO_MAPCHANGE); SetPush(client); - + TeleportEntity(mate, vecDestination, NULL_VECTOR, velStop); CreateTimer(1.5, SetBlockable, mate, TIMER_FLAG_NO_MAPCHANGE); SetPush(mate); @@ -4450,12 +4423,12 @@ public Handle_Menu_NPC_Next(Handle:menu, MenuAction:action, client, itemNum) vecDestination[0] = g_mapZones[g_iClientLastTrackZone[client]][Point2][0]; vecDestination[1] = g_mapZones[g_iClientLastTrackZone[client]][Point2][1]; vecDestination[2] = g_mapZones[g_iClientLastTrackZone[client]][Point2][2]; - - if(Timer_IsPlayerTouchingZoneType(client, ZtStart)) Timer_SetIgnoreEndTouchStart(client, 1); - + + if(Timer_IsPlayerTouchingStartZone(client)) Timer_SetIgnoreEndTouchStart(client, 1); + new mate; if(g_timerTeams) mate= Timer_GetClientTeammate(client); - + if(mate > 0) { if(Timer_GetCoopStatus(client)) @@ -4469,7 +4442,7 @@ public Handle_Menu_NPC_Next(Handle:menu, MenuAction:action, client, itemNum) } else if(StrEqual(info, "no")) { - + } } } @@ -4486,15 +4459,15 @@ public Handle_Menu_NPC_Delete(Handle:menu, MenuAction:action, client, itemNum) if(StrEqual(info, "yes")) { new zone = g_iTargetNPC[client]; - + decl String:query[64]; FormatEx(query, sizeof(query), "DELETE FROM mapzone WHERE id = %d", g_mapZones[zone][Id]); - + SQL_TQuery(g_hSQL, DeleteMapZoneCallback, query, client, DBPrio_Normal); } else if(StrEqual(info, "no")) { - + } } } @@ -4504,7 +4477,7 @@ ParseColor(const String:color[], result[]) { decl String:buffers[4][4]; ExplodeString(color, " ", buffers, sizeof(buffers), sizeof(buffers[])); - + for (new i = 0; i < sizeof(buffers); i++) result[i] = StringToInt(buffers[i]); } @@ -4517,14 +4490,14 @@ stock bool:Tele_Level(client, level) { if(g_mapZones[mapZone][Level_Id] < LEVEL_START) continue; - + if (g_mapZones[mapZone][Level_Id] == level) { return Tele_Zone(client, mapZone); } } } - + return false; } @@ -4532,60 +4505,42 @@ stock bool:Tele_Zone(client, zone, bool:stopspeed = true, bool:overwrite_physics { if(!IsClientInGame(client)) return false; - + // Don't teleport from inside a startzone to the same zone if(g_bZone[zone][client]) { if(g_mapZones[zone][Type] == ZtStart) - { - CPrintToChat(client, PLUGIN_PREFIX, "Already inside start zone"); return false; - } else if(g_mapZones[zone][Type] == ZtBonusStart) - { - CPrintToChat(client, PLUGIN_PREFIX, "Already inside bonus start zone"); return false; - } else if(g_mapZones[zone][Type] == ZtBonus2Start) - { - CPrintToChat(client, PLUGIN_PREFIX, "Already inside bonus2 start zone"); return false; - } else if(g_mapZones[zone][Type] == ZtBonus3Start) - { - CPrintToChat(client, PLUGIN_PREFIX, "Already inside bonus3 start zone"); return false; - } else if(g_mapZones[zone][Type] == ZtBonus4Start) - { - CPrintToChat(client, PLUGIN_PREFIX, "Already inside bonus4 start zone"); return false; - } else if(g_mapZones[zone][Type] == ZtBonus5Start) - { - CPrintToChat(client, PLUGIN_PREFIX, "Already inside bonus5 start zone"); return false; - } } - + // Get zone center cords new Float:center[3]; center[0] = (g_mapZones[zone][Point1][0] + g_mapZones[zone][Point2][0]) / 2.0; center[1] = (g_mapZones[zone][Point1][1] + g_mapZones[zone][Point2][1]) / 2.0; - + // Use static height if(g_Settings[UseZoneTeleportZ]) center[2] = g_mapZones[zone][Point1][2] + g_Settings[ZoneTeleportZ]; // Use center height else center[2] = (g_mapZones[zone][Point1][2] + g_mapZones[zone][Point2][2]) / 2.0; - + //If teleporting outside a startzone skip the next end touch output - new bool:touchstart = (Timer_IsPlayerTouchingZoneType(client, ZtStart) || Timer_IsPlayerTouchingZoneType(client, ZtBonusStart) || Timer_IsPlayerTouchingZoneType(client, ZtBonus2Start) || Timer_IsPlayerTouchingZoneType(client, ZtBonus3Start) || Timer_IsPlayerTouchingZoneType(client, ZtBonus4Start) || Timer_IsPlayerTouchingZoneType(client, ZtBonus5Start)); + new bool:touchstart = Timer_IsPlayerTouchingStartZone(client); new bool:targetstart = (g_mapZones[zone][Type] != ZtStart && g_mapZones[zone][Type] != ZtBonusStart && g_mapZones[zone][Type] != ZtBonus2Start && g_mapZones[zone][Type] != ZtBonus3Start && g_mapZones[zone][Type] != ZtBonus4Start && g_mapZones[zone][Type] != ZtBonus5Start); - + if(touchstart && targetstart) Timer_SetIgnoreEndTouchStart(client, 1); - + // Stop speed before and after teleporting if(stopspeed) { @@ -4595,7 +4550,7 @@ stock bool:Tele_Zone(client, zone, bool:stopspeed = true, bool:overwrite_physics CreateTimer(0.0, Timer_StopSpeed, client, TIMER_FLAG_NO_MAPCHANGE); } else TeleportEntity(client, center, NULL_VECTOR, NULL_VECTOR); - + // Anti cheat if(overwrite_physics) { @@ -4603,7 +4558,7 @@ stock bool:Tele_Zone(client, zone, bool:stopspeed = true, bool:overwrite_physics SetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue", g_Physics[style][StyleTimeScale]); SetEntityGravity(client, g_Physics[style][StyleGravity]); } - + return true; } @@ -4611,12 +4566,12 @@ public Action:Timer_StopSpeed(Handle:timer, any:client) { if(!IsClientInGame(client)) return Plugin_Stop; - + if(!IsPlayerAlive(client)) return Plugin_Stop; - + TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, Float:{0.0,0.0,-100.0}); - + return Plugin_Stop; } @@ -4625,24 +4580,24 @@ public Action:Command_LevelAdminMode(client, args) if (args != 1) { ReplyToCommand(client, "[SM] Usage: sm_zoneadminmode [0/1]"); - return Plugin_Handled; + return Plugin_Handled; } if (args == 1) { decl String:name2[64]; GetCmdArg(1,name2,sizeof(name2)); adminmode = StringToInt(name2); - - if(adminmode == 1) + + if(adminmode == 1) { CPrintToChat(client, PLUGIN_PREFIX, "Adminmode Enabled"); } - else + else { CPrintToChat(client, PLUGIN_PREFIX, "Adminmode Disabled"); } } - return Plugin_Handled; + return Plugin_Handled; } public Action:Command_AddZone(client, args) @@ -4669,7 +4624,7 @@ public Action:Command_LevelName(client, args) if (args != 1) { ReplyToCommand(client, "[SM] Usage: sm_zonename [name]"); - return Plugin_Handled; + return Plugin_Handled; } if (args == 1) { @@ -4677,10 +4632,10 @@ public Action:Command_LevelName(client, args) GetCmdArg(1,name2,sizeof(name2)); decl String:query[256]; FormatEx(query, sizeof(query), "UPDATE mapzone SET name = '%s' WHERE id = %d", name2, g_mapZones[g_iClientLastTrackZone[client]][Id]); - SQL_TQuery(g_hSQL, UpdateLevelCallback, query, client, DBPrio_Normal); + SQL_TQuery(g_hSQL, UpdateLevelCallback, query, client, DBPrio_Normal); PrintToChat(client, "Set LevelName: %s for ZoneID: %d", name2, g_mapZones[g_iClientLastTrackZone[client]][Id]); } - return Plugin_Handled; + return Plugin_Handled; } public Action:Command_LevelID(client, args) @@ -4688,19 +4643,19 @@ public Action:Command_LevelID(client, args) if (args != 1) { ReplyToCommand(client, "[SM] Usage: sm_zoneid [id]"); - return Plugin_Handled; + return Plugin_Handled; } if (args == 1) { decl String:name2[64]; GetCmdArg(1, name2, sizeof(name2)); - + decl String:query2[512]; FormatEx(query2, sizeof(query2), "UPDATE mapzone SET level_id = '%s' WHERE id = %d", name2, g_mapZones[g_iClientLastTrackZone[client]][Id]); - SQL_TQuery(g_hSQL, UpdateLevelCallback, query2, client, DBPrio_Normal); + SQL_TQuery(g_hSQL, UpdateLevelCallback, query2, client, DBPrio_Normal); PrintToChat(client, "Set LevelID: %s for ZoneID: %d", name2, g_mapZones[g_iClientLastTrackZone[client]][Id]); } - return Plugin_Handled; + return Plugin_Handled; } public Action:Command_LevelType(client, args) @@ -4708,19 +4663,19 @@ public Action:Command_LevelType(client, args) if (args != 1) { ReplyToCommand(client, "[SM] Usage: sm_zonetype"); - return Plugin_Handled; + return Plugin_Handled; } if (args == 1) { decl String:name2[64]; GetCmdArg(1, name2, sizeof(name2)); - + decl String:query2[512]; FormatEx(query2, sizeof(query2), "UPDATE mapzone SET type = '%s' WHERE id = %d", name2, g_mapZones[g_iClientLastTrackZone[client]][Id]); - SQL_TQuery(g_hSQL, UpdateLevelCallback, query2, client, DBPrio_Normal); + SQL_TQuery(g_hSQL, UpdateLevelCallback, query2, client, DBPrio_Normal); PrintToChat(client, "Set Type: %s for ZoneID: %d", name2, g_mapZones[g_iClientLastTrackZone[client]][Id]); } - return Plugin_Handled; + return Plugin_Handled; } public UpdateLevelCallback(Handle:owner, Handle:hndl, const String:error[], any:data) @@ -4730,7 +4685,7 @@ public UpdateLevelCallback(Handle:owner, Handle:hndl, const String:error[], any: Timer_LogError("SQL Error on UpdateZone: %s", error); return; } - + LoadMapZones(); } @@ -4738,21 +4693,44 @@ public Action:Command_Stuck(client, args) { if(!g_Settings[StuckEnable]) return Plugin_Handled; - - if(!IsClientInGame(client)) + + if(!IsClientInGame(client)) return Plugin_Handled; - - if(!IsPlayerAlive(client)) + + if(!IsPlayerAlive(client)) return Plugin_Handled; - + + if(Timer_IsPlayerTouchingZoneType(client, ZtStart) || + Timer_IsPlayerTouchingZoneType(client, ZtBonusStart) || + Timer_IsPlayerTouchingZoneType(client, ZtBonus2Start) || + Timer_IsPlayerTouchingZoneType(client, ZtBonus3Start) || + Timer_IsPlayerTouchingZoneType(client, ZtBonus4Start) || + Timer_IsPlayerTouchingZoneType(client, ZtBonus5Start) || + Timer_IsPlayerTouchingZoneType(client, ZtCheckpoint) || + Timer_IsPlayerTouchingZoneType(client, ZtBonusCheckpoint) || + Timer_IsPlayerTouchingZoneType(client, ZtBonus2Checkpoint) || + Timer_IsPlayerTouchingZoneType(client, ZtBonus3Checkpoint) || + Timer_IsPlayerTouchingZoneType(client, ZtBonus4Checkpoint) || + Timer_IsPlayerTouchingZoneType(client, ZtBonus5Checkpoint) || + Timer_IsPlayerTouchingZoneType(client, ZtLevel) || + Timer_IsPlayerTouchingZoneType(client, ZtBonusLevel) || + Timer_IsPlayerTouchingZoneType(client, ZtBonus2Level) || + Timer_IsPlayerTouchingZoneType(client, ZtBonus3Level) || + Timer_IsPlayerTouchingZoneType(client, ZtBonus4Level) || + Timer_IsPlayerTouchingZoneType(client, ZtBonus5Level)) + { + CPrintToChat(client, "%s You can't use this command inside this zone type.", PLUGIN_PREFIX2); + return Plugin_Handled; + } + if(Timer_GetStatus(client) && g_Settings[StuckPenaltyTime] > 0) { Timer_AddPenaltyTime(client, g_Settings[StuckPenaltyTime]); CPrintToChat(client, "%s You have used !stuck and got an %ds penalty time.", PLUGIN_PREFIX2, RoundToFloor(g_Settings[StuckPenaltyTime])); } - + TeleLastCheckpoint(client); - + return Plugin_Handled; } @@ -4760,19 +4738,56 @@ public Action:Command_Restart(client, args) { if(!g_Settings[RestartEnable]) return Plugin_Handled; - - if(!IsClientInGame(client)) + + if(!IsClientInGame(client)) return Plugin_Handled; - + if(Timer_GetMapzoneCount(ZtStart) < 1) return Plugin_Handled; - - if(Timer_IsPlayerTouchingZoneType(client, ZtStart)) + + new track = Timer_GetTrack(client); + + if(track == TRACK_NORMAL && Timer_IsPlayerTouchingZoneType(client, ZtStart)) { - CPrintToChat(client, PLUGIN_PREFIX, "Already inside start zone"); + //CPrintToChat(client, PLUGIN_PREFIX, "Already inside start zone"); return Plugin_Handled; } - + + if(track == TRACK_BONUS && Timer_IsPlayerTouchingZoneType(client, ZtBonusStart)) + { + Timer_SetTrack(client, TRACK_NORMAL); + Client_Start(client); + return Plugin_Handled; + } + + if(track == TRACK_BONUS2 && Timer_IsPlayerTouchingZoneType(client, ZtBonus2Start)) + { + Timer_SetTrack(client, TRACK_NORMAL); + Client_Start(client); + return Plugin_Handled; + } + + if(track == TRACK_BONUS3 && Timer_IsPlayerTouchingZoneType(client, ZtBonus3Start)) + { + Timer_SetTrack(client, TRACK_NORMAL); + Client_Start(client); + return Plugin_Handled; + } + + if(track == TRACK_BONUS4 && Timer_IsPlayerTouchingZoneType(client, ZtBonus4Start)) + { + Timer_SetTrack(client, TRACK_NORMAL); + Client_Start(client); + return Plugin_Handled; + } + + if(track == TRACK_BONUS5 && Timer_IsPlayerTouchingZoneType(client, ZtBonus5Start)) + { + Timer_SetTrack(client, TRACK_NORMAL); + Client_Start(client); + return Plugin_Handled; + } + if(g_timerTeams) { if(Timer_GetChallengeStatus(client) == 1 || Timer_GetCoopStatus(client) == 1) @@ -4781,9 +4796,12 @@ public Action:Command_Restart(client, args) return Plugin_Handled; } } - - Client_Restart(client); - + + if(track == TRACK_NORMAL) + Client_Start(client); + else + Client_BonusRestart(client, track); + return Plugin_Handled; } @@ -4791,11 +4809,11 @@ public Action:Command_Start(client, args) { if(!g_Settings[StartEnable]) return Plugin_Handled; - + decl String:slevel[64]; GetCmdArg(1, slevel, sizeof(slevel)); new level = StringToInt(slevel); - + if(level > 0) { if(g_timerTeams) @@ -4806,18 +4824,18 @@ public Action:Command_Start(client, args) return Plugin_Handled; } } - + Timer_Reset(client); Tele_Level(client, level); return Plugin_Handled; } - - if(!IsClientInGame(client)) + + if(!IsClientInGame(client)) return Plugin_Handled; - + if(Timer_GetMapzoneCount(ZtStart) < 1) return Plugin_Handled; - + if(g_timerTeams) { if(Timer_GetChallengeStatus(client) == 1 || Timer_GetCoopStatus(client) == 1) @@ -4826,9 +4844,9 @@ public Action:Command_Start(client, args) return Plugin_Handled; } } - + Client_Start(client); - + return Plugin_Handled; } @@ -4836,22 +4854,22 @@ public Action:Command_BonusRestart(client, args) { if(!g_Settings[StartEnable]) return Plugin_Handled; - - if(!IsClientInGame(client)) + + if(!IsClientInGame(client)) return Plugin_Handled; - + if(Timer_IsPlayerTouchingZoneType(client, ZtBonusStart)) { - CPrintToChat(client, PLUGIN_PREFIX, "Already inside bonus start zone"); + //CPrintToChat(client, PLUGIN_PREFIX, "Already inside bonus start zone"); return Plugin_Handled; } - + if(Timer_GetMapzoneCount(ZtBonusStart) < 1) { CPrintToChat(client, PLUGIN_PREFIX, "There is no bonus in this map"); return Plugin_Handled; } - + if(g_timerTeams) { if(Timer_GetChallengeStatus(client) == 1 || Timer_GetCoopStatus(client) == 1) @@ -4860,9 +4878,9 @@ public Action:Command_BonusRestart(client, args) return Plugin_Handled; } } - + Client_BonusRestart(client, TRACK_BONUS); - + return Plugin_Handled; } @@ -4870,22 +4888,22 @@ public Action:Command_Bonus2Restart(client, args) { if(!g_Settings[StartEnable]) return Plugin_Handled; - - if(!IsClientInGame(client)) + + if(!IsClientInGame(client)) return Plugin_Handled; - + if(Timer_IsPlayerTouchingZoneType(client, ZtBonus2Start)) { - CPrintToChat(client, PLUGIN_PREFIX, "Already inside bonus2 start zone"); + //CPrintToChat(client, PLUGIN_PREFIX, "Already inside bonus2 start zone"); return Plugin_Handled; } - + if(Timer_GetMapzoneCount(ZtBonus2Start) < 1) { CPrintToChat(client, PLUGIN_PREFIX, "There is no bonus2 in this map"); return Plugin_Handled; } - + if(g_timerTeams) { if(Timer_GetChallengeStatus(client) == 1 || Timer_GetCoopStatus(client) == 1) @@ -4894,9 +4912,9 @@ public Action:Command_Bonus2Restart(client, args) return Plugin_Handled; } } - + Client_BonusRestart(client, TRACK_BONUS2); - + return Plugin_Handled; } @@ -4904,22 +4922,22 @@ public Action:Command_Bonus3Restart(client, args) { if(!g_Settings[StartEnable]) return Plugin_Handled; - - if(!IsClientInGame(client)) + + if(!IsClientInGame(client)) return Plugin_Handled; - + if(Timer_IsPlayerTouchingZoneType(client, ZtBonus3Start)) { - CPrintToChat(client, PLUGIN_PREFIX, "Already inside bonus3 start zone"); + //CPrintToChat(client, PLUGIN_PREFIX, "Already inside bonus3 start zone"); return Plugin_Handled; } - + if(Timer_GetMapzoneCount(ZtBonus3Start) < 1) { CPrintToChat(client, PLUGIN_PREFIX, "There is no bonus3 in this map"); return Plugin_Handled; } - + if(g_timerTeams) { if(Timer_GetChallengeStatus(client) == 1 || Timer_GetCoopStatus(client) == 1) @@ -4928,9 +4946,9 @@ public Action:Command_Bonus3Restart(client, args) return Plugin_Handled; } } - + Client_BonusRestart(client, TRACK_BONUS3); - + return Plugin_Handled; } @@ -4938,22 +4956,22 @@ public Action:Command_Bonus4Restart(client, args) { if(!g_Settings[StartEnable]) return Plugin_Handled; - - if(!IsClientInGame(client)) + + if(!IsClientInGame(client)) return Plugin_Handled; - + if(Timer_IsPlayerTouchingZoneType(client, ZtBonus4Start)) { - CPrintToChat(client, PLUGIN_PREFIX, "Already inside bonus4 start zone"); + //CPrintToChat(client, PLUGIN_PREFIX, "Already inside bonus4 start zone"); return Plugin_Handled; } - + if(Timer_GetMapzoneCount(ZtBonus4Start) < 1) { CPrintToChat(client, PLUGIN_PREFIX, "There is no bonus4 in this map"); return Plugin_Handled; } - + if(g_timerTeams) { if(Timer_GetChallengeStatus(client) == 1 || Timer_GetCoopStatus(client) == 1) @@ -4962,9 +4980,9 @@ public Action:Command_Bonus4Restart(client, args) return Plugin_Handled; } } - + Client_BonusRestart(client, TRACK_BONUS4); - + return Plugin_Handled; } @@ -4972,22 +4990,22 @@ public Action:Command_Bonus5Restart(client, args) { if(!g_Settings[StartEnable]) return Plugin_Handled; - - if(!IsClientInGame(client)) + + if(!IsClientInGame(client)) return Plugin_Handled; - + if(Timer_IsPlayerTouchingZoneType(client, ZtBonus5Start)) { - CPrintToChat(client, PLUGIN_PREFIX, "Already inside bonus5 start zone"); + //CPrintToChat(client, PLUGIN_PREFIX, "Already inside bonus5 start zone"); return Plugin_Handled; } - + if(Timer_GetMapzoneCount(ZtBonus5Start) < 1) { CPrintToChat(client, PLUGIN_PREFIX, "There is no bonus5 in this map"); return Plugin_Handled; } - + if(g_timerTeams) { if(Timer_GetChallengeStatus(client) == 1 || Timer_GetCoopStatus(client) == 1) @@ -4996,36 +5014,47 @@ public Action:Command_Bonus5Restart(client, args) return Plugin_Handled; } } - + Client_BonusRestart(client, TRACK_BONUS5); - + return Plugin_Handled; } +new g_iConfirmTrack[MAXPLAYERS+1]; + ConfirmAbortMenu(client, track) { if (0 < client < MaxClients) { new Handle:menu = CreateMenu(Handle_ConfirmAbortMenu); - + new mate; if(g_timerTeams) mate = Timer_GetClientTeammate(client); - + + SetMenuTitle(menu, "Please confirm your action."); + if(mate > 0) { if(Timer_GetChallengeStatus(client) == 1) - SetMenuTitle(menu, "Are you sure to quit the Challenge?"); + { + AddMenuItem(menu, "no", "Do nothing"); + AddMenuItem(menu, "tele", "Teleport me back"); + AddMenuItem(menu, "unmate", "Cancel challenge"); + } else if(Timer_GetCoopStatus(client) == 1) - SetMenuTitle(menu, "Are you sure to quit the Coop?"); - }else SetMenuTitle(menu, "Are you sure to quit?"); - - decl String:info[8]; - IntToString(track, info, sizeof(info)); - - AddMenuItem(menu, info, "Yes"); - - AddMenuItem(menu, "no", "No"); - + { + AddMenuItem(menu, "no", "Do nothing"); + AddMenuItem(menu, "tele", "Teleport me back"); + AddMenuItem(menu, "unmate", "Cancel partner"); + } + } + else + { + AddMenuItem(menu, "yes", "Yes, Teleport me back"); + AddMenuItem(menu, "no", "No"); + } + + g_iConfirmTrack[client] = track; DisplayMenu(menu, client, 5); } } @@ -5039,11 +5068,16 @@ public Handle_ConfirmAbortMenu(Handle:menu, MenuAction:action, client, itemNum) if(found) { new track = StringToInt(info); - + + if(!StrEqual(info, "no")) + { + + } + if(track == -1) { Client_Restart(client); - + } else if(track == TRACK_NORMAL) { @@ -5059,28 +5093,28 @@ public Handle_ConfirmAbortMenu(Handle:menu, MenuAction:action, client, itemNum) bool:Client_Start(client) { - if(!IsClientInGame(client)) + if(!IsClientInGame(client)) return false; - + //Has player a valid team if(GetClientTeam(client) != CS_TEAM_CT && GetClientTeam(client) != CS_TEAM_T) { new validteam = CS_GetValidSpawnTeam(); - + if(validteam != CS_TEAM_NONE) { CS_SwitchTeam(client, validteam); } - else Timer_LogError("No spawn points for %s", g_currentMap); + else CS_SwitchTeam(client, CS_TEAM_CT); } - + new style = Timer_GetStyle(client); - + //Stop timer Timer_Reset(client); - + //Is player alive - if(!IsPlayerAlive(client)) + if(!IsPlayerAlive(client)) { CS_RespawnPlayer(client); } @@ -5090,39 +5124,39 @@ bool:Client_Start(client) SetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue", g_Physics[style][StyleTimeScale]); SetEntityGravity(client, g_Physics[style][StyleGravity]); } - + //Teleport player to starzone Tele_Level(client, LEVEL_START); - + return true; } bool:Client_Restart(client, bool:teleport = true) { - if(!IsClientInGame(client)) + if(!IsClientInGame(client)) return false; - + //Has player a valid team if(GetClientTeam(client) != CS_TEAM_CT && GetClientTeam(client) != CS_TEAM_T) { new validteam = CS_GetValidSpawnTeam(); - + if(validteam != CS_TEAM_NONE) { CS_SwitchTeam(client, validteam); } - else Timer_LogError("No spawn points for %s", g_currentMap); + else CS_SwitchTeam(client, CS_TEAM_CT); } - + new style = Timer_GetStyle(client); - + //Stop timer Timer_Reset(client); - + new bool:respawn = true; - + //Is player alive - if(!IsPlayerAlive(client)) + if(!IsPlayerAlive(client)) { CS_RespawnPlayer(client); respawn = false; @@ -5133,45 +5167,45 @@ bool:Client_Restart(client, bool:teleport = true) SetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue", g_Physics[style][StyleTimeScale]); SetEntityGravity(client, g_Physics[style][StyleGravity]); } - + //Teleport player to starzone if(g_Settings[TeleportOnRestart] && teleport) { Tele_Level(client, LEVEL_START); - } + } //Or just respawn him else if(respawn) { CS_RespawnPlayer(client); } - + return true; } bool:Client_BonusRestart(client, track) { - if(!IsClientInGame(client)) + if(!IsClientInGame(client)) return false; - + //Has player a valid team if(GetClientTeam(client) != CS_TEAM_CT && GetClientTeam(client) != CS_TEAM_T) { new validteam = CS_GetValidSpawnTeam(); - + if(validteam != CS_TEAM_NONE) { CS_SwitchTeam(client, validteam); } else Timer_LogError("No spawn points for %s", g_currentMap); } - + new style = Timer_GetStyle(client); - + //Stop timer Timer_Reset(client); - + //Is player alive - if(!IsPlayerAlive(client)) + if(!IsPlayerAlive(client)) { CS_RespawnPlayer(client); } @@ -5181,7 +5215,7 @@ bool:Client_BonusRestart(client, track) SetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue", g_Physics[style][StyleTimeScale]); SetEntityGravity(client, g_Physics[style][StyleGravity]); } - + //Teleport player to bonus-starzone if(track == TRACK_BONUS) return Tele_Level(client, LEVEL_BONUS_START); @@ -5193,7 +5227,7 @@ bool:Client_BonusRestart(client, track) return Tele_Level(client, LEVEL_BONUS4_START); else if(track == TRACK_BONUS5) return Tele_Level(client, LEVEL_BONUS5_START); - + return true; } @@ -5207,17 +5241,17 @@ AdminZoneTeleport(client) { new Handle:menu = CreateMenu(MenuHandlerAdminZone); SetMenuTitle(menu, "Zone Selection"); - + for (new zone = 0; zone < g_mapZonesCount; zone++) { decl String:zone_name[32]; FormatEx(zone_name, sizeof(zone_name), "%s", g_mapZones[zone][zName]); - + decl String:zone_id[32]; FormatEx(zone_id,sizeof(zone_id), "%d", zone); AddMenuItem(menu, zone_id, zone_name); } - + SetMenuExitButton(menu, true); DisplayMenu(menu, client, MENU_TIME_FOREVER); } @@ -5247,17 +5281,17 @@ AdminZoneDelete(client) { new Handle:menu = CreateMenu(MenuHandlerAdminZoneDelete); SetMenuTitle(menu, "Zone Selection"); - + for (new zone = 0; zone < g_mapZonesCount; zone++) { decl String:zone_name[32]; FormatEx(zone_name, sizeof(zone_name), "%s", g_mapZones[zone][zName]); - + decl String:zone_id[32]; FormatEx(zone_id,sizeof(zone_id), "%d", zone); AddMenuItem(menu, zone_id, zone_name); } - + SetMenuExitButton(menu, true); DisplayMenu(menu, client, MENU_TIME_FOREVER); } @@ -5273,7 +5307,7 @@ public MenuHandlerAdminZoneDelete(Handle:menu, MenuAction:action, client, param2 { decl String:query[64]; FormatEx(query, sizeof(query), "DELETE FROM mapzone WHERE id = %d", g_mapZones[zone][Id]); - + SQL_TQuery(g_hSQL, DeleteMapZoneCallback, query, client, DBPrio_Normal); } } @@ -5287,7 +5321,7 @@ public Action:Command_Levels(client, args) decl String:slevel[64]; GetCmdArg(1, slevel, sizeof(slevel)); new level = StringToInt(slevel); - + if(level > 0) { if(g_timerTeams) @@ -5298,33 +5332,33 @@ public Action:Command_Levels(client, args) return Plugin_Handled; } } - + Timer_Reset(client); Tele_Level(client, level); return Plugin_Handled; } - + new Handle:menu = CreateMenu(MenuHandlerLevels); SetMenuTitle(menu, "Stage Teleport Selection"); - + for (new zone = 0; zone < g_mapZonesCount; zone++) { if(g_mapZones[zone][Level_Id] < 1) { continue; } - + decl String:zone_name[32]; FormatEx(zone_name, sizeof(zone_name), "%s", g_mapZones[zone][zName]); - + decl String:zone_id[32]; FormatEx(zone_id,sizeof(zone_id), "%d", zone); AddMenuItem(menu, zone_id, zone_name); } - + SetMenuExitButton(menu, true); DisplayMenu(menu, client, 20); - + return Plugin_Handled; } @@ -5347,20 +5381,20 @@ public Native_AddMapZone(Handle:plugin, numParams) { decl String:map[32]; GetNativeString(1, map, sizeof(map)); - - new MapZoneType:type = GetNativeCell(2); - + + new MapZoneType:type = GetNativeCell(2); + decl String:name[32]; GetNativeString(1, name, sizeof(name)); - + new level_id = GetNativeCell(2); - + new Float:point1[3]; GetNativeArray(3, point1, sizeof(point1)); - + new Float:point2[3]; GetNativeArray(3, point2, sizeof(point2)); - + AddMapZone(map, type, name, level_id, point1, point2); } @@ -5392,10 +5426,10 @@ public Native_GetClientLevelID(Handle:plugin, numParams) public Native_GetLevelName(Handle:plugin, numParams) { new id = GetNativeCell(1); - new nlen = GetNativeCell(3); + new nlen = GetNativeCell(3); if (nlen <= 0) return false; - + for (new i = 0; i < g_mapZonesCount; i++) { if(g_mapZones[i][Level_Id] == id) @@ -5406,7 +5440,7 @@ public Native_GetLevelName(Handle:plugin, numParams) return true; } } - + return false; } @@ -5436,7 +5470,7 @@ public Native_IsPlayerTouchingZoneType(Handle:plugin, numParams) { new client = GetNativeCell(1); new MapZoneType:type = GetNativeCell(2); - + return IsPlayerTouchingZoneType(client, type); } @@ -5446,18 +5480,18 @@ IsPlayerTouchingZoneType(client, MapZoneType:type) { if(g_mapZones[i][Type] != type) continue; - + if(g_bZone[i][client]) return 1; } - + return 0; } public Native_GetMapzoneCount(Handle:plugin, numParams) { new MapZoneType:type = GetNativeCell(1); - + new count = 0; if(type == ZtLevel || type == ZtBonusLevel) @@ -5470,11 +5504,11 @@ public Native_GetMapzoneCount(Handle:plugin, numParams) LevelID[mapZone] = g_mapZones[mapZone][Level_Id]; } } - + SortIntegers(LevelID, g_mapZonesCount, Sort_Ascending); - + new lastlevel; - + for (new mapZone = 0; mapZone < g_mapZonesCount; mapZone++) { if (LevelID[mapZone] > lastlevel) @@ -5494,13 +5528,13 @@ public Native_GetMapzoneCount(Handle:plugin, numParams) } } } - + return count; } public bool:FilterOnlyPlayers(entity, contentsMask, any:data) { - if(entity != data && entity > 0 && entity <= MaxClients) + if(entity != data && entity > 0 && entity <= MaxClients) return true; return false; } @@ -5533,19 +5567,19 @@ public Action:Hook_NormalSound(clients[64], &numClients, String:sample[PLATFORM_ if (g_Settings[DisableDoorSounds]) if (StrContains(sample, "door") != -1) return Plugin_Stop; - + if (g_Settings[DisableButtonSounds]) if (StrContains(sample, "button") != -1) return Plugin_Stop; - + return Plugin_Continue; } public Action:Command_ToggleTeleporters(client, args) { ToggleTeleporters(client); - - return Plugin_Handled; + + return Plugin_Handled; } stock ToggleTeleporters(client) @@ -5553,12 +5587,12 @@ stock ToggleTeleporters(client) if(g_bTeleportersDisabled) { g_bTeleportersDisabled = false; - + ReplyToCommand(client, "(Re-)Enabled all trigger_teleport entitys"); - + new entity; decl String:targetname[256]; - + while ((entity = FindEntityByClassname(entity, "info_teleport_destination")) != -1) { GetEntPropString(entity, Prop_Data, "m_iName", targetname, sizeof(targetname)); @@ -5569,12 +5603,12 @@ stock ToggleTeleporters(client) else { g_bTeleportersDisabled = true; - + ReplyToCommand(client, "Disabled all trigger_teleport entitys"); - + new entity; decl String:targetname[256]; - + while ((entity = FindEntityByClassname(entity, "info_teleport_destination")) != -1) { GetEntPropString(entity, Prop_Data, "m_iName", targetname, sizeof(targetname)); @@ -5597,13 +5631,13 @@ stock FixAngRotation() { new Float:ang[3]; GetEntPropVector(entity, Prop_Send, "m_angRotation", ang); - + if(ang[0] > 360.0 || ang[1] > 360.0 || ang[2] > 360.0 || ang[0] < -360.0 || ang[1] < -360.0 || ang[2] < -360.0) { ang[0] = float(RoundToFloor(ang[0]) % 60); ang[1] = float(RoundToFloor(ang[1]) % 60); ang[2] = float(RoundToFloor(ang[2]) % 60); - + SetEntPropVector(entity, Prop_Send, "m_angRotation", ang); } } diff --git a/gameserver/addons/sourcemod/scripting/timer-mapzones_startzone_nojump.sp b/gameserver/addons/sourcemod/scripting/timer-mapzones_startzone_nojump.sp index 7a4dc56..6e61faf 100644 --- a/gameserver/addons/sourcemod/scripting/timer-mapzones_startzone_nojump.sp +++ b/gameserver/addons/sourcemod/scripting/timer-mapzones_startzone_nojump.sp @@ -1,11 +1,13 @@ #pragma semicolon 1 - + #include #include #include #include #include - +#include +#include + public Plugin:myinfo = { name = "[Timer] Start zone no jump", @@ -17,14 +19,25 @@ public Plugin:myinfo = public OnPluginStart() { + LoadPhysics(); + LoadTimerSettings(); HookEvent("player_jump", Event_PlayerJump); } +public OnMapStart() +{ + LoadPhysics(); + LoadTimerSettings(); +} + public Action:Event_PlayerJump(Handle:event, const String:name[], bool:dontBroadcast) { new client = GetClientOfUserId(GetEventInt(event, "userid")); - if(Timer_IsPlayerTouchingZoneType(client, ZtStart) || Timer_IsPlayerTouchingZoneType(client, ZtBonusStart)) + if(!g_Physics[Timer_GetStyle(client)][StyleStartZoneAntiBhop]) + return Plugin_Continue; + + if(Timer_IsPlayerTouchingZoneType(client, ZtStart) || Timer_IsPlayerTouchingZoneType(client, ZtBonusStart) || Timer_IsPlayerTouchingZoneType(client, ZtBonus2Start) || Timer_IsPlayerTouchingZoneType(client, ZtBonus3Start) || Timer_IsPlayerTouchingZoneType(client, ZtBonus4Start) || Timer_IsPlayerTouchingZoneType(client, ZtBonus5Start)) { CreateTimer(0.05, DelayedSlowDown, client); } @@ -45,8 +58,8 @@ public OnClientEndTouchZoneType(client, MapZoneType:type) if(type == ZtStart || type == ZtBonusStart) { new bool:onground = bool:(GetEntityFlags(client) & FL_ONGROUND); - - if(!onground) + + if(!onground && g_Physics[Timer_GetStyle(client)][StyleStartZoneAntiBhop]) { CheckVelocity(client, 1, 120.0); } diff --git a/gameserver/addons/sourcemod/scripting/timer-menu.sp b/gameserver/addons/sourcemod/scripting/timer-menu.sp index bcd420a..fd366f1 100644 --- a/gameserver/addons/sourcemod/scripting/timer-menu.sp +++ b/gameserver/addons/sourcemod/scripting/timer-menu.sp @@ -20,12 +20,12 @@ public OnPluginStart() { LoadPhysics(); LoadTimerSettings(); - - RegConsoleCmd("sm_menu", Command_Menu); + + RegConsoleCmd("sm_menu", Command_Menu); RegConsoleCmd("sm_timer", Command_HelpMenu); RegConsoleCmd("sm_help", Command_HelpMenu); RegConsoleCmd("sm_commands", Command_HelpMenu); - + mod = GetGameMod(); } @@ -33,14 +33,14 @@ public OnMapStart() { LoadPhysics(); LoadTimerSettings(); - + GetCurrentMap(g_sCurrentMap, sizeof(g_sCurrentMap)); } public Action:Command_Menu(client, args) { Menu(client); - + return Plugin_Handled; } @@ -62,14 +62,14 @@ public Action:Command_HelpMenu(client, args) Init_Commands(); g_iCurrentPage[client] = 1; CommandPanel(client); - + return Plugin_Handled; } public Init_Commands() { g_iCmdCount = 0; - + Add_Command("!timer - Displays this menu", "timer-core.smx"); Add_Command("!menu - Displays a main menu", "timer-menu.smx"); Add_Command("!style - Displays style selection menu", "timer-physics.smx"); @@ -115,7 +115,7 @@ public Init_Commands() Add_Command("!ljpopup - Toogle Long Jump Stats Popup", "timer-ljstats.smx"); Add_Command("!ljblock - Register Long Jump Destination", "timer-ljstats.smx"); Add_Command("!gap - Measure units between 2 point", "timer-ljstats.smx"); - + Add_Command("!credits - Displays Credits", "timer-core.smx"); } @@ -133,16 +133,16 @@ Add_Command(String:info[], String:plugin[], bool:enable = true) public CommandPanel(client) { new firstcomand = g_iCurrentPage[client]*commandsperpage-commandsperpage; - + new Handle:panel = CreatePanel(); SetPanelTitle(panel, ">>> Timer Help Menu <<<\nby Zipcore"); - + new String:sPage[512]; Format(sPage, sizeof(sPage), " -- Page %d/%d --", g_iCurrentPage[client], maxpage); - + DrawPanelText(panel, sPage); DrawPanelText(panel, " "); - + new String:buffer[512]; new iCmdCount; for(new i=firstcomand; i < (g_iCurrentPage[client]*commandsperpage); i++) @@ -151,24 +151,26 @@ public CommandPanel(client) DrawPanelText(panel, buffer); iCmdCount++; } - + DrawPanelText(panel, " "); - - + + new startkey = 8; if(g_iCurrentPage[client] > 1) startkey = 7; - + //Fix CS:GO menu buttons if(mod == MOD_CSGO) SetPanelCurrentKey(panel, startkey); else SetPanelCurrentKey(panel, startkey+1); - + if(g_iCurrentPage[client] > 1) DrawPanelItem(panel, "- Back -"); else DrawPanelText(panel, " "); if(g_iCurrentPage[client] < maxpage) DrawPanelItem(panel, "- Next -"); else DrawPanelText(panel, " "); + + SetPanelCurrentKey(panel, 9); DrawPanelItem(panel, "- Exit -"); - + SendPanelToClient(panel, client, CommandPanelHandler, MENU_TIME_FOREVER); CloseHandle(panel); @@ -178,7 +180,7 @@ public CommandPanelHandler (Handle:menu, MenuAction:action,client, param2) { if ( action == MenuAction_Select ) { - if(mod == MOD_CSGO) + if(mod == MOD_CSGO) { switch (param2) { @@ -222,9 +224,9 @@ Menu(client) if (0 < client < MaxClients) { new Handle:menu = CreateMenu(Handle_Menu); - SetMenuTitle(menu, "Timer - Main Menu \nby Zipcore"); - - AddMenuItem(menu, "mode", "Change Style"); + SetMenuTitle(menu, "Timer - Main Menu \nby Zipcore"); + + AddMenuItem(menu, "mode", "Change Style"); if(PluginEnabled("timer-physicsinfo.smx")) { AddMenuItem(menu, "info", "Mode Settings Info"); @@ -243,11 +245,11 @@ Menu(client) AddMenuItem(menu, "hud", "Custom HUD Settings"); } AddMenuItem(menu, "credits", "Credits"); - + DisplayMenu(menu, client, MENU_TIME_FOREVER); } } - + public Handle_Menu(Handle:menu, MenuAction:action, client, itemNum) { if ( action == MenuAction_Select ) @@ -274,11 +276,11 @@ public Handle_Menu(Handle:menu, MenuAction:action, client, itemNum) } else if(StrEqual(info, "challenge")) { - if(IsClientInGame(client)) FakeClientCommand(client, "sm_challenge"); + if(IsClientInGame(client)) FakeClientCommand(client, "sm_challenge"); } else if(StrEqual(info, "hud")) { - if(IsClientInGame(client)) FakeClientCommand(client, "sm_hud"); + if(IsClientInGame(client)) FakeClientCommand(client, "sm_hud"); } else if(StrEqual(info, "credits")) { @@ -293,18 +295,18 @@ WorldRecordMenu(client) if (0 < client < MaxClients) { new Handle:menu = CreateMenu(Handle_WorldRecordMenu); - + SetMenuTitle(menu, "World Record Menu"); - + AddMenuItem(menu, "wr", "World Record"); AddMenuItem(menu, "bwr", "Bonus World Record"); AddMenuItem(menu, "swr", "Short World Record"); AddMenuItem(menu, "main", "Back"); - + DisplayMenu(menu, client, MENU_TIME_FOREVER); } } - + public Handle_WorldRecordMenu(Handle:menu, MenuAction:action, client, itemNum) { if ( action == MenuAction_Select ) @@ -338,9 +340,9 @@ TeleportMenu(client) if (0 < client < MaxClients) { new Handle:menu = CreateMenu(Handle_TeleportMenu); - + SetMenuTitle(menu, "Teleport Menu"); - + if(g_Settings[PlayerTeleportEnable]) { AddMenuItem(menu, "teleme", "Teleport to Player"); @@ -354,11 +356,11 @@ TeleportMenu(client) AddMenuItem(menu, "checkpoint", "Teleport to Checkpoint"); } AddMenuItem(menu, "main", "Back"); - + DisplayMenu(menu, client, MENU_TIME_FOREVER); } } - + public Handle_TeleportMenu(Handle:menu, MenuAction:action, client, itemNum) { if ( action == MenuAction_Select ) diff --git a/gameserver/addons/sourcemod/scripting/timer-mysql.sp b/gameserver/addons/sourcemod/scripting/timer-mysql.sp index 21df738..c3ec251 100644 --- a/gameserver/addons/sourcemod/scripting/timer-mysql.sp +++ b/gameserver/addons/sourcemod/scripting/timer-mysql.sp @@ -32,7 +32,7 @@ public Plugin:myinfo = public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max) { RegPluginLibrary("timer-mysql"); - + CreateNative("Timer_SqlGetConnection", Native_SqlGetConnection); return APLRes_Success; @@ -42,9 +42,9 @@ public OnPluginStart() { g_timerOnTimerSqlConnected = CreateGlobalForward("OnTimerSqlConnected", ET_Event, Param_Cell); g_timerOnTimerSqlStop = CreateGlobalForward("OnTimerSqlStop", ET_Event); - + RegAdminCmd("timer_sql_force_update", Command_ForceUpdate, ADMFLAG_RCON, "timer_sql_force_update "); - + ConnectSQL(); } @@ -58,8 +58,8 @@ public Action:Command_ForceUpdate(client, args) InstallUpdates(); } else strcopy(g_DB_Version, sizeof(g_DB_Version), "2.1.3"); - - return Plugin_Handled; + + return Plugin_Handled; } public OnPluginEnd() @@ -72,17 +72,17 @@ public OnPluginEnd() ConnectSQL() { g_DatabaseReady = false; - + if(g_hSQL != INVALID_HANDLE) { Call_StartForward(g_timerOnTimerSqlStop); Call_Finish(); - + CloseHandle(g_hSQL); } - + g_hSQL = INVALID_HANDLE; - + if (SQL_CheckConfig("timer")) { SQL_TConnect(ConnectSQLCallback, "timer"); @@ -104,21 +104,21 @@ public ConnectSQLCallback(Handle:owner, Handle:hndl, const String:error[], any:d if (hndl == INVALID_HANDLE) { g_reconnectCounter++; - + Timer_LogError("[timer-mysql.smx] Connection to SQL database has failed, Try %d, Reason: %s", g_reconnectCounter, error); - - if(g_reconnectCounter >= 100) + + if(g_reconnectCounter >= 100) { Call_StartForward(g_timerOnTimerSqlStop); Call_Finish(); Timer_LogError("[timer-mysql.smx] +++ To much errors. Restart your server for a new try. +++"); } - else if(g_reconnectCounter > 5) + else if(g_reconnectCounter > 5) CreateTimer(5.0, Timer_ReConnect); else if(g_reconnectCounter > 3) CreateTimer(3.0, Timer_ReConnect); else CreateTimer(1.0, Timer_ReConnect); - + return; } @@ -126,7 +126,7 @@ public ConnectSQLCallback(Handle:owner, Handle:hndl, const String:error[], any:d SQL_GetDriverIdent(owner, driver, sizeof(driver)); g_hSQL = CloneHandle(hndl); - + if (StrEqual(driver, "mysql", false)) { SQL_SetCharset(g_hSQL, "utf8"); @@ -138,7 +138,7 @@ public ConnectSQLCallback(Handle:owner, Handle:hndl, const String:error[], any:d Call_Finish(); Timer_LogError("##### Timer ERROR: SqLite is not supported, please check you databases.cfg and use MySQL driver #####"); } - + g_reconnectCounter = 1; } @@ -152,14 +152,14 @@ public CreateSQLTableCallback(Handle:owner, Handle:hndl, const String:error[], a return; } - + if (hndl == INVALID_HANDLE) { Timer_LogError("[timer-mysql.smx] SQL Error on CreateSQLTableCallback: %s", error); ConnectSQL(); return; } - + SQL_TQuery(g_hSQL, GetDBVersionCallback, "SELECT `setting` FROM `settings` WHERE `key` = \"db_version\";"); } @@ -171,42 +171,42 @@ public GetDBVersionCallback(Handle:owner, Handle:hndl, const String:error[], any ConnectSQL(); return; } - + if (hndl == INVALID_HANDLE) { Timer_LogError("[timer-mysql.smx] SQL Error on GetDBVersionCallback: %s", error); ConnectSQL(); return; } - + // Existing database if(SQL_FetchRow(hndl)) { SQL_FetchString(hndl, 0, g_DB_Version, sizeof(g_DB_Version)); - + // Database up to date if(StrEqual(g_DB_Version, g_Version, true)) { g_DatabaseReady = true; } - + /// Database outdated else if(CheckVersionOutdated(g_DB_Version, g_Version)) InstallUpdates(); - + // Plugin outdated else Timer_LogError("[timer-mysql.smx] Database v%s is newer then Plugin v%s", g_DB_Version, g_Version); } // Install new database else InstallNew(); - + if(g_DatabaseReady) { Timer_LogInfo("[timer-mysql.smx] MySQL v%s connection established and ready.", g_DB_Version); Call_StartForward(g_timerOnTimerSqlConnected); Call_PushCell(_:g_hSQL); Call_Finish(); - + CreateTimer(1.0, Timer_HeartBeat, _, TIMER_REPEAT); } } @@ -215,10 +215,10 @@ stock CheckVersionOutdated(String:version_old[], String:version_new[]) { decl String:versions_old[4][32]; ExplodeString(version_old, ".", versions_old, 4, 32); - + decl String:versions_new[4][32]; ExplodeString(version_new, ".", versions_new, 4, 32); - + for (new i = 0; i < 4; i++) { if(StringToInt(versions_old[i]) < StringToInt(versions_new[i])) @@ -226,7 +226,7 @@ stock CheckVersionOutdated(String:version_old[], String:version_new[]) else if(StringToInt(versions_old[i]) > StringToInt(versions_new[i])) return false; } - + return false; } @@ -238,7 +238,7 @@ public EmptyCallback(Handle:owner, Handle:hndl, const String:error[], any:data) ConnectSQL(); return; } - + if (hndl == INVALID_HANDLE) { Timer_LogError("SQL Error on EmptyCallback: %s", error); @@ -256,7 +256,7 @@ public Action:Timer_HeartBeat(Handle:timer, any:data) Call_StartForward(g_timerOnTimerSqlStop); Call_Finish(); } - + return Plugin_Continue; } @@ -271,126 +271,126 @@ stock InstallNew() { decl String:date[32]; FormatTime(date, sizeof(date), "%Y-%m-%d %H:%M:%S", GetTime()); - + Timer_LogInfo("[timer-mysql.smx] No existing settings table found."); Timer_LogInfo("[timer-mysql.smx] MySQL connection installed with version %s.", g_Version); - + decl String:query[2048]; - + Format(query, sizeof(query), "INSERT INTO `settings`(`key`, `setting`) VALUES ('db_version', '%s');", g_Version); Timer_LogInfo("[timer-mysql.smx] Query: %s", query); SQL_TQuery(g_hSQL, EmptyCallback, query, _, DBPrio_High); - + Format(query, sizeof(query), "INSERT INTO `settings`(`key`, `setting`) VALUES ('setup', '%s');", date); Timer_LogInfo("[timer-mysql.smx] Query: %s", query); SQL_TQuery(g_hSQL, EmptyCallback, query, _, DBPrio_High); - + Format(query, sizeof(query), "INSERT INTO `settings`(`key`, `setting`) VALUES ('last_update', '%s');", date); Timer_LogInfo("[timer-mysql.smx] Query: %s", query); SQL_TQuery(g_hSQL, EmptyCallback, query, _, DBPrio_High); - - /* Create ROUND table */ - Format(query, sizeof(query), "CREATE TABLE IF NOT EXISTS `round` (`id` int(11) NOT NULL AUTO_INCREMENT, `map` varchar(32) NOT NULL, `auth` varchar(32) NOT NULL, `time` float NOT NULL, `jumps` int(11) NOT NULL, `style` int(11) NOT NULL, `track` int(11) NOT NULL, `name` varchar(64) NOT NULL, `finishcount` int(11) NOT NULL, `stage` int(11) NOT NULL, `fpsmax` int(11) NOT NULL, `jumpacc` float NOT NULL, `strafes` int(11) NOT NULL, `strafeacc` float NOT NULL, `avgspeed` float NOT NULL, `maxspeed` float NOT NULL, `finishspeed` float NOT NULL, `flashbangcount` int(11) NULL, `rank` int(11) NOT NULL, `replaypath` varchar(32) NOT NULL, `custom1` varchar(32) NULL, `custom2` varchar(32) NULL, `custom3` varchar(32) NULL, date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `single_record` (`auth`, `map`, `style`, `track`));"); + + /* Create ROUND table */ + Format(query, sizeof(query), "CREATE TABLE IF NOT EXISTS `round` (`id` int(11) NOT NULL AUTO_INCREMENT, `map` varchar(32) NOT NULL, `auth` varchar(32) NOT NULL, `time` float NOT NULL, `jumps` int(11) NOT NULL, `style` int(11) NOT NULL, `track` int(11) NOT NULL, `name` varchar(64) NOT NULL, `finishcount` int(11) NOT NULL, `stage` int(11) NOT NULL, `fpsmax` int(11) NOT NULL, `jumpacc` float NOT NULL, `strafes` int(11) NOT NULL, `strafeacc` float NOT NULL, `avgspeed` float NOT NULL, `maxspeed` float NOT NULL, `finishspeed` float NOT NULL, `flashbangcount` int(11) NULL, `rank` int(11) NOT NULL, `replaypath` varchar(32) NOT NULL, `custom1` varchar(32) NULL, `custom2` varchar(32) NULL, `custom3` varchar(32) NULL, date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `single_record` (`auth`, `map`, `style`, `track`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); Timer_LogInfo("[timer-mysql.smx] Query: %s", query); SQL_TQuery(g_hSQL, EmptyCallback, query, _, DBPrio_High); - - /* Create MAPZONE table */ - Format(query, sizeof(query), "CREATE TABLE IF NOT EXISTS `mapzone` (`id` int(11) NOT NULL AUTO_INCREMENT, `type` int(11) NOT NULL, `level_id` int(11) NOT NULL, `point1_x` float NOT NULL, `point1_y` float NOT NULL, `point1_z` float NOT NULL, `point2_x` float NOT NULL, `point2_y` float NOT NULL, `point2_z` float NOT NULL, `map` varchar(64) NOT NULL, `name` varchar(32) NOT NULL, PRIMARY KEY (`id`));"); + + /* Create MAPZONE table */ + Format(query, sizeof(query), "CREATE TABLE IF NOT EXISTS `mapzone` (`id` int(11) NOT NULL AUTO_INCREMENT, `type` int(11) NOT NULL, `level_id` int(11) NOT NULL, `point1_x` float NOT NULL, `point1_y` float NOT NULL, `point1_z` float NOT NULL, `point2_x` float NOT NULL, `point2_y` float NOT NULL, `point2_z` float NOT NULL, `map` varchar(64) NOT NULL, `name` varchar(32) NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); Timer_LogInfo("[timer-mysql.smx] Query: %s", query); SQL_TQuery(g_hSQL, EmptyCallback, query, _, DBPrio_High); - - /* Create MAPTIER table */ - Format(query, sizeof(query), "CREATE TABLE IF NOT EXISTS `maptier` (`id` int(11) NOT NULL AUTO_INCREMENT, `map` varchar(32) NOT NULL, `track` int(11) NOT NULL, `tier` int(11) NOT NULL, `stagecount` int(11) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `single_record` (`map`, `track`));"); + + /* Create MAPTIER table */ + Format(query, sizeof(query), "CREATE TABLE IF NOT EXISTS `maptier` (`id` int(11) NOT NULL AUTO_INCREMENT, `map` varchar(32) NOT NULL, `track` int(11) NOT NULL, `tier` int(11) NOT NULL, `stagecount` int(11) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `single_record` (`map`, `track`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); Timer_LogInfo("[timer-mysql.smx] Query: %s", query); SQL_TQuery(g_hSQL, EmptyCallback, query, _, DBPrio_High); - - /* Create RANKS table */ - Format(query, sizeof(query), "CREATE TABLE IF NOT EXISTS `ranks` (`auth` varchar(24) NOT NULL PRIMARY KEY, `points` int(11) NOT NULL default 0, `lastname` varchar(65) NOT NULL default '', `lastplay` int(11) NOT NULL default 0);"); + + /* Create RANKS table */ + Format(query, sizeof(query), "CREATE TABLE IF NOT EXISTS `ranks` (`auth` varchar(24) NOT NULL PRIMARY KEY, `points` int(11) NOT NULL default 0, `lastname` varchar(65) NOT NULL default '', `lastplay` int(11) NOT NULL default 0) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); Timer_LogInfo("[timer-mysql.smx] Query: %s", query); SQL_TQuery(g_hSQL, EmptyCallback, query, _, DBPrio_High); - + g_DatabaseReady = true; } stock InstallUpdates() { decl String:update_version[32]; - + decl String:query[2048]; - + Timer_LogInfo("[timer-mysql.smx] ############################################################"); Timer_LogInfo("[timer-mysql.smx] MySQL v%s is outdated.", g_DB_Version); - + Format(update_version, sizeof(update_version), "2.1.4.7"); if(CheckVersionOutdated(g_DB_Version, update_version)) { Timer_LogError("[timer-mysql.smx] Executing updates for v%s: Levelprocess fix", update_version); - + Format(query, sizeof(query), "UPDATE `round` SET `levelprocess` = 999 WHERE `bonus` = 0 AND `levelprocess` < 1;"); Timer_LogInfo("[timer-mysql.smx] Query: %s", query); SQL_TQuery(g_hSQL, EmptyCallback, query, _, DBPrio_High); - + Format(query, sizeof(query), "UPDATE `round` SET `levelprocess` = 1999 WHERE `bonus` = 1 AND `levelprocess` < 1;"); Timer_LogInfo("[timer-mysql.smx] Query: %s", query); SQL_TQuery(g_hSQL, EmptyCallback, query, _, DBPrio_High); - + Format(query, sizeof(query), "UPDATE `round` SET `levelprocess` = 500 WHERE `bonus` = 2 AND `levelprocess` < 1;"); Timer_LogInfo("[timer-mysql.smx] Query: %s", query); SQL_TQuery(g_hSQL, EmptyCallback, query, _, DBPrio_High); - + Timer_LogInfo("[timer-mysql.smx] Executing updates for v%s: Bonus start fix", update_version); - + Format(query, sizeof(query), "UPDATE mapzone SET level_id = 1001 WHERE level_id = 1000"); Timer_LogInfo("[timer-mysql.smx] Query: %s", query); SQL_TQuery(g_hSQL, EmptyCallback, query, _, DBPrio_High); } - + Format(update_version, sizeof(update_version), "2.1.5.1"); if(CheckVersionOutdated(g_DB_Version, update_version)) { Timer_LogError("[timer-mysql.smx] Executing updates for v%s: Flashbangcount fix", update_version); - + // flashbangcount fix Format(query, sizeof(query), "ALTER TABLE `round` MODIFY `flashbangcount` DEFAULT 0;"); Timer_LogInfo("[timer-mysql.smx] Query: %s", query); SQL_TQuery(g_hSQL, EmptyCallback, query, _, DBPrio_High); - + Format(query, sizeof(query), "UPDATE `round` SET `flashbangcount` = 0 WHERE `flashbangcount` < 1;"); Timer_LogInfo("[timer-mysql.smx] Query: %s", query); SQL_TQuery(g_hSQL, EmptyCallback, query, _, DBPrio_High); } - - + + Format(update_version, sizeof(update_version), "2.2.0.0"); if(CheckVersionOutdated(g_DB_Version, update_version)) { Timer_LogError("[timer-mysql.smx] Executing updates for v%s: Major update mysql module fix", update_version); - + // Rename bonus to track Format(query, sizeof(query), "ALTER TABLE round CHANGE bonus track int(11);"); Timer_LogInfo("[timer-mysql.smx] Query: %s", query); SQL_TQuery(g_hSQL, EmptyCallback, query, _, DBPrio_High); - + Format(query, sizeof(query), "ALTER TABLE maptier CHANGE bonus track int(11);"); Timer_LogInfo("[timer-mysql.smx] Query: %s", query); SQL_TQuery(g_hSQL, EmptyCallback, query, _, DBPrio_High); - + // Rename physicsdifficulty to style Format(query, sizeof(query), "ALTER TABLE round CHANGE physicsdifficulty style int(11);"); Timer_LogInfo("[timer-mysql.smx] Query: %s", query); SQL_TQuery(g_hSQL, EmptyCallback, query, _, DBPrio_High); - + // Rename levelprocess to stage Format(query, sizeof(query), "ALTER TABLE round CHANGE levelprocess stage int(11);"); Timer_LogInfo("[timer-mysql.smx] Query: %s", query); SQL_TQuery(g_hSQL, EmptyCallback, query, _, DBPrio_High); } - + Format(update_version, sizeof(update_version), "2.2.1.1"); if(CheckVersionOutdated(g_DB_Version, update_version)) { Timer_LogError("[timer-mysql.smx] Executing updates for v%s: Custom field default fix", update_version); - + // custom field default fix Format(query, sizeof(query), "ALTER TABLE `round` MODIFY `custom1` DEFAULT 0;"); Timer_LogInfo("[timer-mysql.smx] Query: %s", query); @@ -402,12 +402,12 @@ stock InstallUpdates() Timer_LogInfo("[timer-mysql.smx] Query: %s", query); SQL_TQuery(g_hSQL, EmptyCallback, query, _, DBPrio_High); } - + Format(update_version, sizeof(update_version), "2.3.0.2"); if(CheckVersionOutdated(g_DB_Version, update_version)) { Timer_LogError("[timer-mysql.smx] Executing updates for v%s: Custom field default fix", update_version); - + // collation fix Format(query, sizeof(query), "alter table maptier convert to character set utf8 collate utf8_general_ci;"); Timer_LogInfo("[timer-mysql.smx] Query: %s", query); @@ -431,16 +431,16 @@ stock InstallUpdates() Timer_LogInfo("[timer-mysql.smx] Query: %s", query); SQL_TQuery(g_hSQL, EmptyCallback, query, _, DBPrio_High); } - + decl String:date[32]; FormatTime(date, sizeof(date), "%Y-%m-%d %H:%M:%S", GetTime()); Format(query, sizeof(query), "UPDATE `settings` SET `setting` = \"%s\" WHERE `key` = \"last_update\";", date); SQL_TQuery(g_hSQL, EmptyCallback, query, _, DBPrio_High); - + Format(query, sizeof(query), "UPDATE `settings` SET `setting` = \"%s\" WHERE `key` = \"db_version\";", g_Version); SQL_TQuery(g_hSQL, EmptyCallback, query, _, DBPrio_High); Timer_LogInfo("[timer-mysql.smx] MySQL v%s version updated.", g_Version); Timer_LogInfo("[timer-mysql.smx] ############################################################"); - + g_DatabaseReady = true; } diff --git a/gameserver/addons/sourcemod/scripting/timer-online_db.sp b/gameserver/addons/sourcemod/scripting/timer-online_db.sp index aa49abe..6ca72a6 100644 --- a/gameserver/addons/sourcemod/scripting/timer-online_db.sp +++ b/gameserver/addons/sourcemod/scripting/timer-online_db.sp @@ -10,7 +10,7 @@ new bool:g_bAuthed[MAXPLAYERS + 1]; new Handle:g_hServerID = INVALID_HANDLE; new g_iServerID; -public Plugin:myinfo = +public Plugin:myinfo = { name = "[Timer] Players Online DB", author = "Zipcore", @@ -33,9 +33,9 @@ public OnPluginStart() HookConVarChange(g_hServerID, OnCVarChange); AutoExecConfig(true, "timer/timer-online_DB"); - + RegAdminCmd("sm_online_refresh", Command_RefreshTable, ADMFLAG_ROOT); - + if (g_hSQL == INVALID_HANDLE) { ConnectSQL(); @@ -76,12 +76,16 @@ RefreshTable() decl String:query[512]; Format(query, sizeof(query), "DELETE FROM `online` WHERE `server` = %d", g_iServerID); SQL_TQuery(g_hSQL, DeleteCallback, query, _, DBPrio_High); - + for(new i = 1; i <= MaxClients; i++) { if(IsClientInGame(i) && !IsFakeClient(i) && !IsClientSourceTV(i)) { - g_bAuthed[i] = GetClientAuthString(i, g_sAuth[i], sizeof(g_sAuth[])); + #if SOURCEMOD_V_MAJOR >= 1 && SOURCEMOD_V_MINOR >= 7 + g_bAuthed[i] = GetClientAuthId(i, AuthId_Steam2, g_sAuth[i], sizeof(g_sAuth[])); + #else + g_bAuthed[i] = GetClientAuthString(i, g_sAuth[i], sizeof(g_sAuth[])); + #endif if(g_bAuthed[i]) { FormatEx(query, sizeof(query), "INSERT INTO `online` (auth, server) VALUES ('%s','%d') ON DUPLICATE KEY server = %d;", g_sAuth[i], g_iServerID, g_iServerID); @@ -96,9 +100,13 @@ public OnClientPostAdminCheck(client) g_bAuthed[client] = false; if(IsFakeClient(client) || IsClientSourceTV(client)) return; - - g_bAuthed[client] = GetClientAuthString(client, g_sAuth[client], sizeof(g_sAuth[])); - + + #if SOURCEMOD_V_MAJOR >= 1 && SOURCEMOD_V_MINOR >= 7 + g_bAuthed[client] = GetClientAuthId(client, AuthId_Steam2, g_sAuth[client], sizeof(g_sAuth[])); + #else + g_bAuthed[client] = GetClientAuthString(client, g_sAuth[client], sizeof(g_sAuth[])); + #endif + if (g_hSQL != INVALID_HANDLE) { if(Client_IsValid(client) && !IsFakeClient(client)) @@ -123,10 +131,10 @@ public OnClientDisconnect_Post(client) ConnectSQL() { g_hSQL = Handle:Timer_SqlGetConnection(); - + if (g_hSQL == INVALID_HANDLE) CreateTimer(0.1, Timer_SQLReconnect, _ , TIMER_FLAG_NO_MAPCHANGE); - else + else { SQL_TQuery(g_hSQL, CreateSQLTableCallback, "CREATE TABLE IF NOT EXISTS `online` (`auth` varchar(24) NOT NULL, `server` int(11) NOT NULL, UNIQUE KEY `online_single` (`auth`));"); RefreshTable(); @@ -138,17 +146,17 @@ public CreateSQLTableCallback(Handle:owner, Handle:hndl, const String:error[], a if (owner == INVALID_HANDLE) { Timer_LogError(error); - + ConnectSQL(); return; } - + if (hndl == INVALID_HANDLE) { Timer_LogError("SQL Error on CreateSQLTable: %s", error); return; } - + RefreshTable(); } @@ -174,4 +182,4 @@ public DeleteCallback(Handle:owner, Handle:hndl, const String:error[], any:param Timer_LogError("SQL Error on DeleteCallback: %s", error); return; } -} \ No newline at end of file +} diff --git a/gameserver/addons/sourcemod/scripting/timer-physics.sp b/gameserver/addons/sourcemod/scripting/timer-physics.sp index efcb397..10fee67 100644 --- a/gameserver/addons/sourcemod/scripting/timer-physics.sp +++ b/gameserver/addons/sourcemod/scripting/timer-physics.sp @@ -18,16 +18,11 @@ #include #include -enum UserJumps -{ - Float:LastJumpTimes[4], -} - new bool:g_timerMapzones = false; new bool:g_timerLjStats = false; new bool:g_timerRankings = false; -new g_userJumps[MAXPLAYERS][UserJumps]; +new Float:g_fLastJumps[MAXPLAYERS][4]; new Handle:g_OnClientMaxJumpHeight; new Handle:g_OnClientApplyDifficulty; @@ -159,7 +154,7 @@ public Plugin:myinfo = public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max) { RegPluginLibrary("timer-physics"); - + CreateNative("Timer_GetForceStyle", Native_GetForceStyle); CreateNative("Timer_GetPickedStyle", Native_GetPickedStyle); CreateNative("Timer_ApplyPhysics", Native_ApplyPhysics); @@ -168,9 +163,11 @@ public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max) CreateNative("Timer_GetMaxSpeed", Native_GetMaxSpeed); CreateNative("Timer_GetAvgSpeed", Native_GetAvgSpeed); CreateNative("Timer_ResetAccuracy", Native_ResetAccuracy); + CreateNative("Timer_SaveLastJumps", Native_SaveLastJumps); + CreateNative("Timer_RestoreLastJumps", Native_RestoreLastJumps); g_bLateLoaded = late; - + return APLRes_Success; } @@ -178,22 +175,22 @@ public OnPluginStart() { LoadPhysics(); LoadTimerSettings(); - + new Handle:hGameConf = INVALID_HANDLE; hGameConf = LoadGameConfigFile("sdkhooks.games"); - if(hGameConf == INVALID_HANDLE) + if(hGameConf == INVALID_HANDLE) { SetFailState("GameConfigFile sdkhooks.games was not found"); return; } - + LoadTranslations("timer.phrases"); - + HookEvent("round_start",Event_RoundStart,EventHookMode_PostNoCopy); - + HookEvent("player_spawn", Event_PlayerSpawn); HookEvent("player_jump", Event_PlayerJump); - + RegAdminCmd("sm_timer_reload_config", Command_ReloadConfig, ADMFLAG_CONVARS, "Reload timer settings"); if(g_Settings[MultimodeEnable]) RegConsoleCmd("sm_style", Command_Difficulty); if(g_Settings[NoclipEnable]) RegConsoleCmd("sm_nc", Command_NoclipMe); @@ -202,24 +199,24 @@ public OnPluginStart() if(g_Settings[BhopEnable]) RegConsoleCmd("sm_autobhop", Command_ToggleAuto); if(g_Settings[BhopEnable]) RegConsoleCmd("sm_autojump", Command_ToggleAuto); RegAdminCmd("sm_colour", Command_Colour, ADMFLAG_RESERVATION); - + g_hPlattformColor = CreateConVar("timer_plattform_color", "0 255 0 255", "The color of detected plattforms."); - + HookConVarChange(g_hPlattformColor, Action_OnSettingsChange); - + AutoExecConfig(true, "timer/timer-physics"); - + new String:buffer[32]; GetConVarString(g_hPlattformColor, buffer, sizeof(buffer)); ParseColor(buffer, g_PlattformColor); - + StartPrepSDKCall(SDKCall_Entity); PrepSDKCall_SetFromConf(hGameConf,SDKConf_Virtual,"Touch"); PrepSDKCall_AddParameter(SDKType_CBaseEntity,SDKPass_Pointer); g_hSDK_Touch = EndPrepSDKCall(); CloseHandle(hGameConf); - if(g_hSDK_Touch == INVALID_HANDLE) + if(g_hSDK_Touch == INVALID_HANDLE) { SetFailState("Unable to prepare virtual function CBaseEntity::Touch"); return; @@ -230,17 +227,17 @@ public OnPluginStart() g_iOffs_vecMins = FindSendPropInfo("CBaseEntity","m_vecMins"); g_iOffs_vecMaxs = FindSendPropInfo("CBaseEntity","m_vecMaxs"); g_iOffs_Velocity = FindSendPropOffs("CBasePlayer", "m_vecVelocity[0]"); - + g_timerMapzones = LibraryExists("timer-mapzones"); g_timerLjStats = LibraryExists("timer-ljstats"); g_timerRankings = LibraryExists("timer-rankings"); - + g_OnClientMaxJumpHeight = CreateGlobalForward("OnClientMaxJumpHeight", ET_Event, Param_Cell, Param_Cell); g_OnClientApplyDifficulty = CreateGlobalForward("OnClientApplyDifficulty", ET_Event, Param_Cell, Param_Cell); g_OnClientApplyDifficultyPre = CreateGlobalForward("OnClientApplyDifficultyPre", ET_Event, Param_Cell, Param_Cell); - - if(g_bLateLoaded) + + if(g_bLateLoaded) { OnPluginPauseChange(false); } @@ -251,31 +248,31 @@ public OnLibraryAdded(const String:name[]) if (StrEqual(name, "timer-mapzones")) { g_timerMapzones = true; - } + } else if (StrEqual(name, "timer-ljstats")) { g_timerLjStats = true; - } + } else if (StrEqual(name, "timer-rankings")) { g_timerRankings = true; - } + } } public OnLibraryRemoved(const String:name[]) -{ +{ if (StrEqual(name, "timer-mapzones")) { g_timerMapzones = false; - } + } else if (StrEqual(name, "timer-ljstats")) { g_timerLjStats = false; - } + } else if (StrEqual(name, "timer-rankings")) { g_timerRankings = false; - } + } } public Action_OnSettingsChange(Handle:cvar, const String:oldvalue[], const String:newvalue[]) @@ -284,9 +281,9 @@ public Action_OnSettingsChange(Handle:cvar, const String:oldvalue[], const Strin ParseColor(newvalue, g_PlattformColor); } -public OnPluginPauseChange(bool:pause) +public OnPluginPauseChange(bool:pause) { - if(pause) + if(pause) { OnPluginEnd(); } @@ -302,7 +299,7 @@ stock ResetMultiBhop() g_iBhopButtonCount = 0; FindBhopBlocks(); - + AlterBhopBlocks(true); g_iBhopDoorCount = 0; @@ -310,12 +307,12 @@ stock ResetMultiBhop() FindBhopBlocks(); } -public Event_RoundStart(Handle:event,const String:name[],bool:dontBroadcast) +public Event_RoundStart(Handle:event,const String:name[],bool:dontBroadcast) { OnPluginPauseChange(false); } -public OnPluginEnd() +public OnPluginEnd() { AlterBhopBlocks(true); @@ -331,7 +328,7 @@ public OnClientPutInServer(client) g_PlattformColorPlayer[client][3] = 255; g_colourme[client] = 0; g_fBoost[client] = 0.0; - + ResetBhopAvoid(client); ResetBhopCollect(client); } @@ -350,7 +347,7 @@ stock ResetStats(client) g_PlattformColorPlayer[client][1] = GetRandomInt(10, 245); g_PlattformColorPlayer[client][2] = GetRandomInt(10, 245); g_PlattformColorPlayer[client][3] = 255; - + g_fSpeedCurrent[client] = 0.0; g_fSpeedMax[client] = 0.0; g_fSpeedTotal[client] = 0.0; @@ -359,14 +356,14 @@ stock ResetStats(client) Teleport(client, bhop, style) { - + decl i; new tele = -1, ent = bhop; //search door trigger list - for (i = 0; i < g_iBhopDoorCount; i++) + for (i = 0; i < g_iBhopDoorCount; i++) { - if(ent == g_iBhopDoorList[i]) + if(ent == g_iBhopDoorList[i]) { tele = g_iBhopDoorTeleList[i]; break; @@ -374,11 +371,11 @@ Teleport(client, bhop, style) } //no destination? search button trigger list - if(tele == -1) + if(tele == -1) { - for (i = 0; i < g_iBhopButtonCount; i++) + for (i = 0; i < g_iBhopButtonCount; i++) { - if(ent == g_iBhopButtonList[i]) + if(ent == g_iBhopButtonList[i]) { tele = g_iBhopButtonTeleList[i]; break; @@ -387,7 +384,7 @@ Teleport(client, bhop, style) } //set teleport destination - if(tele != -1 && IsValidEntity(tele) && g_Physics[style][StyleMultiBhop] != 2) + if(tele != -1 && IsValidEntity(tele) && g_Physics[style][StyleMultiBhop] != 2) { SDKCall(g_hSDK_Touch,tele,client); } @@ -397,12 +394,12 @@ public OnMapStart() { LoadPhysics(); LoadTimerSettings(); - + if(!g_Settings[NoGravityUpdate]) CreateTimer(1.0, Timer_UpdateGravity, _, TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT); CreateTimer(0.1, Timer_CheckNoClip, _, TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT); - + g_iVegasWinCount = 0; - + ResetMultiBhop(); } @@ -417,34 +414,34 @@ public OnMapEnd() public Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) { new client = GetClientOfUserId(GetEventInt(event, "userid")); - + if(0 < client <= MaxClients) { - g_userJumps[client][LastJumpTimes][3] = 0.0; - g_userJumps[client][LastJumpTimes][2] = 0.0; - g_userJumps[client][LastJumpTimes][1] = 0.0; - g_userJumps[client][LastJumpTimes][0] = 0.0; - + g_fLastJumps[client][3] = 0.0; + g_fLastJumps[client][2] = 0.0; + g_fLastJumps[client][1] = 0.0; + g_fLastJumps[client][0] = 0.0; + if(IsFakeClient(client)) return; - + if(GetClientTeam(client) < 2) return; - + g_bPickedStyle[client] = false; - + if(g_StyleDefault == -1) Timer_LogError("PhysicsCFG: No default style found"); - else Timer_SetStyle(client, g_StyleDefault); - + else Timer_SetStyle(client, g_StyleDefault); + ApplyDifficulty(client); - + Timer_SetTrack(client, TRACK_NORMAL); if (g_Settings[StyleMenuOnSpawn]) { FakeClientCommand(client, "sm_style"); } - + if(g_Settings[TeleportOnSpawn]) { FakeClientCommand(client, "sm_restart"); @@ -452,53 +449,101 @@ public Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) } } +new Float:g_fPauseLastJumps[MAXPLAYERS+1][4]; +new Float:g_fPauseStartTime[MAXPLAYERS+1]; + +public OnTimerPaused(client) +{ + StoreAntiBhop(client); +} + +public OnTimerResumed(client) +{ + RestoreAntiBhop(client); +} + +public OnClientStartTouchZoneType(client, MapZoneType:type) +{ + if(!Timer_GetStatus(client) && !Timer_GetPauseStatus(client)) // Timer stopped + if(type == ZtStart || type == ZtBonusStart || type == ZtBonus2Start || type == ZtBonus3Start || type == ZtBonus4Start || type == ZtBonus5Start) + TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, Float:{0.0,0.0,-100.0}); +} + +public Native_SaveLastJumps(Handle:plugin, numParams) +{ + StoreAntiBhop(GetNativeCell(1)); +} + +StoreAntiBhop(client) +{ + g_fPauseStartTime[client] = GetGameTime(); + + g_fPauseLastJumps[client][0] = g_fLastJumps[client][0]; + g_fPauseLastJumps[client][1] = g_fLastJumps[client][1]; + g_fPauseLastJumps[client][2] = g_fLastJumps[client][2]; + g_fPauseLastJumps[client][3] = g_fLastJumps[client][3]; +} + +public Native_RestoreLastJumps(Handle:plugin, numParams) +{ + RestoreAntiBhop(GetNativeCell(1)); +} + +RestoreAntiBhop(client) +{ + g_fLastJumps[client][0] = g_fPauseLastJumps[client][0] + GetGameTime() - g_fPauseStartTime[client]; + g_fLastJumps[client][1] = g_fPauseLastJumps[client][1] + GetGameTime() - g_fPauseStartTime[client]; + g_fLastJumps[client][2] = g_fPauseLastJumps[client][2] + GetGameTime() - g_fPauseStartTime[client]; + g_fLastJumps[client][3] = g_fPauseLastJumps[client][3] + GetGameTime() - g_fPauseStartTime[client]; +} + public Action:Event_PlayerJump(Handle:event, const String:name[], bool:dontBroadcast) { new client = GetClientOfUserId(GetEventInt(event, "userid")); - + new Float:time = GetGameTime(); - + new style = Timer_GetStyle(client); - + g_fLastJump[client] = time; - + GetClientAbsOrigin(client, g_fJumpLastCord[client]); - + if(g_fStamina[client] != -1.0) { SetEntPropFloat(client, Prop_Send, "m_flStamina", g_fStamina[client]); } - + if(g_Physics[style][StyleBoostForward] != 1.0) CreateTimer(0.0, Timer_Boost, client, TIMER_FLAG_NO_MAPCHANGE); - + if(g_Physics[style][StyleMaxSpeed] != 0.0) { CreateTimer(0.05, DelayedSlowDown, client); } - + if(g_Physics[style][StyleAntiBhop] > 0) { - new Float:timediff = time - g_userJumps[client][LastJumpTimes][3]; - g_userJumps[client][LastJumpTimes][3] = g_userJumps[client][LastJumpTimes][2]; - g_userJumps[client][LastJumpTimes][2] = g_userJumps[client][LastJumpTimes][1]; - g_userJumps[client][LastJumpTimes][1] = g_userJumps[client][LastJumpTimes][0]; - g_userJumps[client][LastJumpTimes][0] = time; - - if (timediff <= 4.0 && g_userJumps[client][LastJumpTimes][3] != 0.0 && g_userJumps[client][LastJumpTimes][2] != 0.0) + new Float:timediff = time - g_fLastJumps[client][3]; + g_fLastJumps[client][3] = g_fLastJumps[client][2]; + g_fLastJumps[client][2] = g_fLastJumps[client][1]; + g_fLastJumps[client][1] = g_fLastJumps[client][0]; + g_fLastJumps[client][0] = time; + + if (timediff <= 4.0 && g_fLastJumps[client][3] != 0.0 && g_fLastJumps[client][2] != 0.0) { // If set to 1 prevent bhop everywhere, if set to 2 use it only inside start zones - if(g_Physics[style][StyleAntiBhop] == 1 || Timer_IsPlayerTouchingZoneType(client, ZtStart) || Timer_IsPlayerTouchingZoneType(client, ZtBonusStart)) + if(!Timer_IsPlayerTouchingZoneType(client, ZtBhop) && (g_Physics[style][StyleAntiBhop] == 1 || Timer_IsPlayerTouchingStartZone(client))) { - g_userJumps[client][LastJumpTimes][0] = 0.0; - g_userJumps[client][LastJumpTimes][1] = 0.0; - g_userJumps[client][LastJumpTimes][2] = 0.0; - g_userJumps[client][LastJumpTimes][3] = 0.0; + g_fLastJumps[client][0] = 0.0; + g_fLastJumps[client][1] = 0.0; + g_fLastJumps[client][2] = 0.0; + g_fLastJumps[client][3] = 0.0; CreateTimer(0.05, DelayedSlowDownDefault, client); } } } - + return Plugin_Continue; } @@ -516,37 +561,40 @@ public Action:DelayedSlowDownDefault(Handle:timer, any:client) public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon, &subtype, &cmdnum, &tickcount, &seed, mouse[2]) { new iInitialButtons = buttons; - + if(!IsPlayerAlive(client)) return Plugin_Continue; - + if(Client_IsOnLadder(client)) g_fLastTimeLadderUsed[client] = GetGameTime(); - + new style = Timer_GetStyle(client); new Float:fGameTime = GetGameTime(); new bool:abuse = false; new bool:oldgroundstatus = g_bStayOnGround[client]; new bool:onground = bool:(GetEntityFlags(client) & FL_ONGROUND); + if(onground && !oldgroundstatus) + SetEntityGravity(client, g_Physics[style][StyleGravity]); + new Float:vecVelocity[3]; GetEntDataVector(client, g_iOffs_Velocity, vecVelocity); - + new bool:GainHeight = false; - + if(g_fCord_Old[client][2] < g_fCord_New[client][2]) { GainHeight = true; } - + decl Float:fVelocity[3]; GetEntPropVector(client, Prop_Data, "m_vecVelocity", fVelocity); //velocity new Float:currentspeed = SquareRoot(Pow(fVelocity[0],2.0)+Pow(fVelocity[1],2.0)); //player speed (units per secound) - + g_fSpeedTotal[client] += currentspeed; g_iCommandCount[client] ++; g_fSpeedCurrent[client] = currentspeed; - + if(currentspeed > g_fSpeedMax[client]) { g_fSpeedMax[client] = currentspeed; @@ -555,9 +603,9 @@ public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:ang g_fCord_Old[client][0] = g_fCord_New[client][0]; g_fCord_Old[client][1] = g_fCord_New[client][1]; g_fCord_Old[client][2] = g_fCord_New[client][2]; - + GetClientAbsOrigin(client, g_fCord_New[client]); - + if(g_fCord_Old[client][2] > g_fCord_New[client][2] && GainHeight) { Call_StartForward(g_OnClientMaxJumpHeight); @@ -565,7 +613,7 @@ public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:ang Call_PushCell(g_fCord_Old[client][2]-g_fJumpLastCord[client][2]); Call_Finish(); } - + if(!onground && !Client_IsOnLadder(client)) { if(!Timer_IsPlayerTouchingZoneType(client, ZtFreeStyle)) @@ -573,15 +621,15 @@ public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:ang if(g_Physics[style][StyleForceHalfSideways] == 1) { g_iMoveCount[client] = 0; - + new Float:fCheck_KeyCounts = 0.25; //time after 2 buttons have to be pressed in seconds new Float:fReset_KeyHits = 3.00; //time after keyhits are resetted in seconds new iCheck_Key_hits = 5; //max keyhits allowed within "fCheck_KeyCounts" time - - + + new Float:fTickrate = 1.0 / GetTickInterval(); //get server tickrate new Float:fCheck_KeyCounts_ticks = fCheck_KeyCounts*fTickrate; //calculate how many ticks has to be ticked to match "fCheck_KeyCounts" time - + if(buttons & IN_FORWARD) { g_iMoveCount[client]++; //count how many keys are pressed @@ -595,7 +643,7 @@ public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:ang } g_fCount_FORWARD[client] = 0.0; //reset count after key is released } - + if(buttons & IN_BACK) { g_iMoveCount[client]++; //count how many keys are pressed @@ -609,7 +657,7 @@ public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:ang } g_fCount_BACK[client] = 0.0; //reset count after key is released } - + if(buttons & IN_MOVELEFT) { g_iMoveCount[client]++; //count how many keys are pressed @@ -623,7 +671,7 @@ public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:ang } g_fCount_MOVELEFT[client] = 0.0; //reset count after key is released } - + if(buttons & IN_MOVERIGHT) { g_iMoveCount[client]++; //count how many keys are pressed @@ -637,11 +685,11 @@ public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:ang } g_fCount_MOVERIGHT[client] = 0.0; //reset count after key is released } - + g_fCount_Keys[client] = g_fCount_FORWARD[client]+g_fCount_BACK[client]+g_fCount_MOVELEFT[client]+g_fCount_MOVERIGHT[client]; //calculate time between button presses - + g_iKey_hits[client] = g_iFORWARD_hits[client]+g_iBACK_hits[client]+g_iMOVELEFT_hits[client]+g_iMOVERIGHT_hits[client]; //calculate all key hits - + if ((g_iMoveCount[client] == 1 && (g_fCount_Keys[client] >= fCheck_KeyCounts_ticks)) || (g_iKey_hits[client] >= iCheck_Key_hits)) //punish the client and reset keyhits/keycounts { abuse = true; @@ -654,7 +702,7 @@ public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:ang g_iMOVELEFT_hits[client] = 0; g_iMOVERIGHT_hits[client] = 0; } - + if (g_iMoveCount[client] == 2) // reset keyhits/keycounts if 2 buttons are pressed { g_fCount_FORWARD[client] = 0.0; @@ -666,7 +714,7 @@ public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:ang g_iMOVELEFT_hits[client] = 0; g_iMOVERIGHT_hits[client] = 0; } - + g_iKey_hits_reset[client]++; if(g_iKey_hits_reset[client] > (fReset_KeyHits*fTickrate)) // reset keyhits { @@ -680,23 +728,23 @@ public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:ang else if(g_Physics[style][StyleForceHalfSideways] == 2) { new iMoveCount = 0; - + if(buttons & IN_FORWARD) iMoveCount++; - + if(buttons & IN_BACK) iMoveCount++; - + if(buttons & IN_MOVELEFT) iMoveCount++; - + if(buttons & IN_MOVERIGHT) iMoveCount++; - + if (iMoveCount == 1) abuse = true; } - + if(g_Physics[style][StylePreventMoveleft]) { if (buttons & IN_MOVELEFT || vel[1] < 0) @@ -704,7 +752,7 @@ public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:ang abuse = true; } } - + if(g_Physics[style][StylePreventMoveright]) { if (buttons & IN_MOVERIGHT || vel[1] > 0) @@ -712,7 +760,7 @@ public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:ang abuse = true; } } - + if(g_Physics[style][StylePreventPlusleft]) { if (buttons & IN_LEFT) //Can't disable @@ -723,10 +771,10 @@ public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:ang } } } - + if(g_Physics[style][StylePreventPlusright]) { - if (buttons & IN_RIGHT) //Can't disable + if (buttons & IN_RIGHT) //Can't disable { if(Timer_GetStatus(client) > 0) { @@ -734,7 +782,7 @@ public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:ang } } } - + if(g_Physics[style][StylePreventMoveforward]) { if (buttons & IN_FORWARD || vel[0] > 0) @@ -742,7 +790,7 @@ public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:ang abuse = true; } } - + if(g_Physics[style][StylePreventMoveback]) { if (buttons & IN_BACK || vel[0] < 0) @@ -750,7 +798,7 @@ public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:ang abuse = true; } } - + if(g_Physics[style][StyleBlockMovementDirection] != 0) { //backwards @@ -771,7 +819,7 @@ public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:ang } } } - + if(g_Physics[style][StylePreventPlusleft]) { if(buttons & IN_LEFT) @@ -779,7 +827,7 @@ public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:ang abuse = true; } } - + if(g_Physics[style][StylePreventPlusright]) { if(buttons & IN_RIGHT) @@ -787,7 +835,7 @@ public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:ang abuse = true; } } - + if(g_Physics[style][StyleHoverScale] != 0.0) { if(fVelocity[2] < 0.0) @@ -799,19 +847,19 @@ public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:ang } } } - + // Freestyle for players which touched a ladder before if(g_Physics[style][StyleLadderFreestyleCooldown] > 0.0 && GetGameTime() - g_fLastTimeLadderUsed[client] < g_Physics[style][StyleLadderFreestyleCooldown]) { abuse = false; } - + if(abuse) { PunishAbuse(client); g_fUnblockControl[client] = fGameTime+g_Physics[style][StylePunishMovementControlCooldown]; } - else if(g_timerMapzones) + else if(g_timerMapzones) { if(!Timer_IsPlayerTouchingZoneType(client, ZtPushEast) && !Timer_IsPlayerTouchingZoneType(client, ZtPushWest) @@ -826,11 +874,11 @@ public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:ang { Block_MovementControl(client, true); } - + if (buttons & IN_JUMP) { new bool:boost = false; - + if(g_timerMapzones) { if(!Timer_IsPlayerTouchingZoneType(client, ZtNoBoost)) @@ -839,17 +887,17 @@ public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:ang } } else boost = true; - + if(boost && onground && g_fBoost[client] > 0.0) { g_bPushWait[client] = true; CreateTimer(0.0, Timer_Push, client, TIMER_FLAG_NO_MAPCHANGE); } - + if(!onground) { new auto = false; - + if(g_timerMapzones) { //Settings/Zone check @@ -859,7 +907,7 @@ public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:ang } } else auto = true; - + if(auto) { //Ladder check @@ -883,7 +931,7 @@ public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:ang new oldjumps = g_iFullJumpCount[client]; new bool:perfect = false; - + // Ignore this jump if the player is in a tight space or stuck in the ground. if ((buttons & IN_JUMP) && !abuse) { @@ -899,41 +947,36 @@ public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:ang g_iFullJumpCount[client]++; g_fJumpAccuracy[client] = 100-((100/g_Settings[MultiBhopDelay])*g_fFullJumpTimeAmount[client])/g_iFullJumpCount[client]; } - else - { - fCheckTime[client] = fGameTime + g_Settings[MultiBhopJumpTime]; - } + else fCheckTime[client] = fGameTime + g_Settings[MultiBhopJumpTime]; } else if(fCheckTime[client] != 0.0) - { fCheckTime[client] = 0.0; - } } } - + if(!abuse && !perfect) { //Save new on ground status - if(onground) + if(onground) { - if(!g_bStayOnGround[client] && g_fBoost[client] > 0.0) + if(!g_bStayOnGround[client] && g_fBoost[client] > 0.0) { g_bPushWait[client] = false; } - + g_bStayOnGround[client] = true; } else { g_bStayOnGround[client] = false; } - + //Player landed if(g_bStayOnGround[client] && g_bStayOnGround[client] != oldgroundstatus) { g_fLandedTime[client] = fGameTime; } - + //Player jumped if(!g_bStayOnGround[client] && g_bStayOnGround[client] != oldgroundstatus) { @@ -942,11 +985,11 @@ public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:ang g_iFullJumpCount[client]++; } } - + //Player has jumped? How good was his jump? if(oldjumps < g_iFullJumpCount[client]) //don't count first jump { - if(fGameTime-g_fLandedTime[client] > g_Settings[MultiBhopDelay]) + if(fGameTime-g_fLandedTime[client] > g_Settings[MultiBhopDelay]) { g_fFullJumpTimeAmount[client] += g_Settings[MultiBhopDelay]; } @@ -954,17 +997,17 @@ public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:ang { g_fFullJumpTimeAmount[client] += fGameTime-g_fLandedTime[client]; } - + //update jump accuracy g_fJumpAccuracy[client] = 100-((100/g_Settings[MultiBhopDelay])*g_fFullJumpTimeAmount[client])/g_iFullJumpCount[client]; } } - + iPrevButtons[client] = buttons; - + if(iInitialButtons != buttons) return Plugin_Changed; - + return Plugin_Continue; } @@ -984,31 +1027,31 @@ CreatePhysicsMenu(client, MCategory:category) if(category == MCategory_Ranked) SetMenuTitle(menu, "Ranked Styles", client); else if(category == MCategory_Fun) SetMenuTitle(menu, "Fun Styles", client); else if(category == MCategory_Practise) SetMenuTitle(menu, "Practise Styles", client); - + SetMenuExitBackButton(menu, true); SetMenuExitButton(menu, true); - + new count = 0; new found = 0; - + new maxorder[3] = {0, ...}; - for (new i = 0; i < MAX_STYLES-1; i++) + for (new i = 0; i < MAX_STYLES-1; i++) { if(!g_Physics[i][StyleEnable]) continue; if(g_Physics[i][StyleCategory] != category) continue; - + if(g_Physics[i][StyleOrder] > maxorder[category]) maxorder[category] = g_Physics[i][StyleOrder]; - + count++; } - - for (new order = 0; order <= maxorder[category]; order++) + + for (new order = 0; order <= maxorder[category]; order++) { - for (new i = 0; i < MAX_STYLES-1; i++) + for (new i = 0; i < MAX_STYLES-1; i++) { if(!g_Physics[i][StyleEnable]) continue; @@ -1016,15 +1059,15 @@ CreatePhysicsMenu(client, MCategory:category) continue; if(g_Physics[i][StyleOrder] != order) continue; - + found++; - + new String:buffer[8]; IntToString(i, buffer, sizeof(buffer)); - + AddMenuItem(menu, buffer, g_Physics[i][StyleName]); } - + if(found == count) break; } @@ -1035,17 +1078,16 @@ CreatePhysicsMenu(client, MCategory:category) public MenuHandler_Physics(Handle:menu, MenuAction:action, client, itemNum) { - if (action == MenuAction_End) + if (action == MenuAction_End) { CloseHandle(menu); } - else if (action == MenuAction_Cancel) + else if (action == MenuAction_Cancel) { - if (itemNum == MenuCancel_ExitBack) - { - if(IsClientInGame(client)) FakeClientCommand(client, "sm_style"); - } - } + if (itemNum == MenuCancel_ExitBack) + if(IsClientInGame(client)) + FakeClientCommand(client, "sm_style"); + } else if ( action == MenuAction_Select ) { decl String:info[100], String:info2[100]; @@ -1053,29 +1095,26 @@ public MenuHandler_Physics(Handle:menu, MenuAction:action, client, itemNum) if(found) { new style = StringToInt(info); - + if(0 <= style < MAX_STYLES-1 && g_Physics[style][StyleEnable]) { if((g_iBhopButtonCount == 0 && g_iBhopDoorCount == 0) && g_Physics[style][StyleMultiBhop] > 0) { CPrintToChat(client, PLUGIN_PREFIX, "Multi bhop not available", client); - if(IsClientInGame(client)) FakeClientCommand(client, "sm_style"); + if(IsClientInGame(client)) + FakeClientCommand(client, "sm_style"); } else { g_bPickedStyle[client] = true; Timer_SetStyle(client, style); - + if(g_Physics[style][StyleCustom]) - { CreateCustomMenu(client); - } } } - else - { - if(IsClientInGame(client)) FakeClientCommand(client, "sm_style"); - } + else if(IsClientInGame(client)) + FakeClientCommand(client, "sm_style"); } } } @@ -1097,7 +1136,7 @@ CreateDifficultyMenu(client) SetMenuTitle(menu, "Styles", client); SetMenuExitButton(menu, true); - + if(g_StyleCountRankedEnabled > 0) { AddMenuItem(menu, "timed", "Ranked Styles"); @@ -1110,9 +1149,9 @@ CreateDifficultyMenu(client) { AddMenuItem(menu, "practise", "Practise Styles"); } - + AddMenuItem(menu, "main", "Back"); - + DisplayMenu(menu, client, MENU_TIME_FOREVER); } } @@ -1122,7 +1161,7 @@ CreateDifficultyMenu(client) public MenuHandler_Difficulty(Handle:menu, MenuAction:action, client, itemNum) { - if (action == MenuAction_End) + if (action == MenuAction_End) { CloseHandle(menu); } @@ -1154,11 +1193,13 @@ public MenuHandler_Difficulty(Handle:menu, MenuAction:action, client, itemNum) } else if(StrEqual(info, "main")) { - if(IsClientInGame(client)) FakeClientCommand(client, "sm_menu"); + if(IsClientInGame(client)) + FakeClientCommand(client, "sm_menu"); } else { - if(IsClientInGame(client)) FakeClientCommand(client, "sm_style"); + if(IsClientInGame(client)) + FakeClientCommand(client, "sm_style"); } } } @@ -1191,17 +1232,13 @@ public MenuHandler_Settings(Handle:menu, MenuAction:action, client, itemNum) { if(0 < client < MaxClients) { - if (action == MenuAction_End) + if (action == MenuAction_End) { if(IsClientConnected(client)) FakeClientCommand(client, "sm_style"); } else if ( action == MenuAction_Select ) { - if(GetClientTeam(client) < 2) - { - - } - else + if(GetClientTeam(client) >= 2) { decl String:info[100], String:info2[100]; new bool:found = GetMenuItem(menu, itemNum, info, sizeof(info), _, info2, sizeof(info2)); @@ -1239,9 +1276,9 @@ public MenuHandler_Settings(Handle:menu, MenuAction:action, client, itemNum) { g_bCustomLowGravity[client] = false; } - + CreateSettingsMenu(client); - + ApplyDifficulty(client); } } @@ -1262,13 +1299,13 @@ CreateCustomMenu(client) if(!g_bCustomAuto[client]) AddMenuItem(menu, "enable_auto", "Enable Auto-Mode"); else AddMenuItem(menu, "disable_auto", "Disable Auto-Mode"); - + if(!g_bCustomBoost[client]) AddMenuItem(menu, "enable_boost", "Enable Jump Height Boost"); else AddMenuItem(menu, "disable_boost", "Disable Jump Height Boost"); - + if(!g_bCustomFullStamina[client]) AddMenuItem(menu, "enable_stamina", "Enable Speed Loss (Stamina)"); else AddMenuItem(menu, "disable_stamina", "Disable Speed Loss (Stamina)"); - + if(!g_bCustomLowGravity[client]) AddMenuItem(menu, "enable_lowgravity", "Enable Low Gravity"); else AddMenuItem(menu, "disable_lowgravity", "Disable Low Gravity"); @@ -1279,7 +1316,7 @@ public MenuHandler_Custom(Handle:menu, MenuAction:action, client, itemNum) { if(0 < client < MaxClients) { - if (action == MenuAction_End) + if (action == MenuAction_End) { if(IsClientConnected(client)) FakeClientCommand(client, "sm_bhop"); } @@ -1287,7 +1324,7 @@ public MenuHandler_Custom(Handle:menu, MenuAction:action, client, itemNum) { if(GetClientTeam(client) < 2) { - + } else { @@ -1327,9 +1364,9 @@ public MenuHandler_Custom(Handle:menu, MenuAction:action, client, itemNum) { g_bCustomLowGravity[client] = false; } - + CreateCustomMenu(client); - + ApplyDifficulty(client); } } @@ -1346,23 +1383,23 @@ ApplyDifficulty(client) if (IsClientInGame(client) && IsClientConnected(client) && !IsClientSourceTV(client)) { new style = Timer_GetStyle(client); - + Call_StartForward(g_OnClientApplyDifficultyPre); Call_PushCell(client); Call_PushCell(style); Call_Finish(); - + // Get style again for the case it was changed on the forward style = Timer_GetStyle(client); - + if(g_Physics[style][StyleCustom]) { if(g_bCustomFullStamina[client]) g_fStamina[client] = STAMINA_FULL; else g_fStamina[client] = STAMINA_DISABLED; - + if(g_bCustomBoost[client]) g_fBoost[client] = g_Physics[style][StyleBoost]; else g_fBoost[client] = 0.0; - + g_bAuto[client] = g_bCustomAuto[client]; } else @@ -1371,49 +1408,43 @@ ApplyDifficulty(client) g_bAuto[client] = g_Physics[style][StyleAuto]; g_fBoost[client] = g_Physics[style][StyleBoost]; } - + //only allow on normal if(!g_Physics[style][StyleLJStats] && g_timerLjStats) { SetLJMode(client, false); } - + //stop timer Timer_Stop(client); - + SetEntityGravity(client, g_Physics[style][StyleGravity]); - + //stop him TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, Float:{0.0,0.0,-100.0}); - + SetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue", g_Physics[style][StyleTimeScale]); - + SetEntProp(client, Prop_Send, "m_iFOV", g_Physics[style][StyleFOV]); SetEntProp(client, Prop_Send, "m_iDefaultFOV", g_Physics[style][StyleFOV]); - + decl String:auth[32]; #if SOURCEMOD_V_MAJOR >= 1 && SOURCEMOD_V_MINOR >= 7 GetClientAuthId(client, AuthId_Steam2, auth, sizeof(auth)); #else GetClientAuthString(client, auth, sizeof(auth)); #endif - - if(StrEqual(g_Physics[style][StyleDesc], "")) - { - - } - else - { + + if(!StrEqual(g_Physics[style][StyleDesc], "")) CPrintToChat(client, "%s %s", PLUGIN_PREFIX2, g_Physics[style][StyleDesc]); - } - + if(g_Settings[TeleportOnStyleChanged]) { if(Timer_GetTrack(client) == TRACK_BONUS) FakeClientCommand(client, "sm_b"); else FakeClientCommand(client, "sm_start"); } - + Call_StartForward(g_OnClientApplyDifficulty); Call_PushCell(client); Call_PushCell(style); @@ -1444,10 +1475,10 @@ public Native_GetMaxSpeed(Handle:plugin, numParams) public Native_GetAvgSpeed(Handle:plugin, numParams) { new client = GetNativeCell(1); - + if(g_iCommandCount[client] <= 0) return false; - + SetNativeCellRef(2, g_fSpeedTotal[client]/g_iCommandCount[client]); return true; } @@ -1469,43 +1500,27 @@ public Native_ResetAccuracy(Handle:plugin, numParams) g_iFullJumpCount[client] = 0; } -stock SetThirdPersonView(client, bool:third) -{ - if(third) - { - SetEntPropEnt(client, Prop_Send, "m_hObserverTarget", 0); - SetEntProp(client, Prop_Send, "m_iObserverMode", 1); - SetEntProp(client, Prop_Send, "m_bDrawViewmodel", 0); - } - else if(!third) - { - SetEntPropEnt(client, Prop_Send, "m_hObserverTarget", -1); - SetEntProp(client, Prop_Send, "m_iObserverMode", 0); - SetEntProp(client, Prop_Send, "m_bDrawViewmodel", 1); - } -} - -public Entity_Touch(bhop,client) +public Entity_Touch(bhop,client) { new doorID = GetBhopDoorID(bhop); new buttonID = GetBhopButtonID(bhop); - + //bhop = entity - if(0 < client <= MaxClients) + if(0 < client <= MaxClients) { new style = Timer_GetStyle(client); - + if(g_Settings[VegasEnable]) { new bool:avoid; - + if(doorID != -1 && g_bBhopDoorAvoid[doorID]) { if(!g_bBhopDoorClientAvoid[doorID][client]) { g_bBhopDoorClientAvoid[doorID][client] = true; avoid = true; - if(g_iBhopClientAvoid[client] == 1) + if(g_iBhopClientAvoid[client] == 1) CPrintToChat(client, PLUGIN_PREFIX, "You failed vegas mission", client); } } @@ -1515,20 +1530,20 @@ public Entity_Touch(bhop,client) { g_bBhopButtonClientAvoid[buttonID][client] = true; avoid = true; - if(g_iBhopClientAvoid[client] == 1) + if(g_iBhopClientAvoid[client] == 1) CPrintToChat(client, PLUGIN_PREFIX, "You failed vegas mission", client); } } - + if(avoid) { g_iBhopClientAvoid[client]++; - + ResetBhopCollect(client); } - + new bool:collect; - + if(doorID != -1 && g_bBhopDoorCollect[doorID]) { if(!g_bBhopDoorClientCollect[doorID][client]) @@ -1545,27 +1560,27 @@ public Entity_Touch(bhop,client) collect = true; } } - + if(collect) { g_iBhopClientCollect[client]++; - + if(GetBhopCollectComplete(client)) { g_iVegasWinCount++; - + if(g_timerRankings) { Timer_AddPoints(client, g_Settings[PointsVegas]+(g_Settings[PointsVegasAdd]*g_iVegasWinCount)); Timer_SavePoints(client); - + decl String:sName[32]; GetClientName(client, sName, sizeof(sName)); CPrintToChatAll(PLUGIN_PREFIX, "Vegas won", sName, g_Settings[PointsVegasAdd]*g_iVegasWinCount); AlterBhopBlocks(true); AlterBhopBlocks(false); } - + if(g_iVegasWinCount >= g_Settings[VegasMapMaxGames]) { CPrintToChatAll(PLUGIN_PREFIX, "Vegas final game"); @@ -1577,27 +1592,27 @@ public Entity_Touch(bhop,client) } } } - + static Float:flPunishTime[MAXPLAYERS + 1], iLastBlock[MAXPLAYERS + 1] = { -1,... }; - + new Float:time = GetGameTime(); - + new Float:diff = time - flPunishTime[client]; - + if ((GetUserFlagBits(client) & ADMFLAG_RESERVATION) && g_colourme[client]) { SetEntDataArray(bhop, g_iOffs_clrRender , g_PlattformColorPlayer[client], 4, 1, true); CreateTimer(0.5, RemoveColouredBlocks,bhop); } - - if(iLastBlock[client] != bhop || diff > g_Settings[MultiBhopCooldown]) + + if(iLastBlock[client] != bhop || diff > g_Settings[MultiBhopCooldown]) { //reset cooldown iLastBlock[client] = bhop; flPunishTime[client] = time + g_Settings[MultiBhopDelay]; - + } - else if(diff > g_Settings[MultiBhopDelay]) + else if(diff > g_Settings[MultiBhopDelay]) { if(g_Physics[style][StyleMultiBhop] == 1 && time - g_fLastJump[client] > (g_Settings[MultiBhopCooldown] + g_Settings[MultiBhopDelay])) { @@ -1619,16 +1634,16 @@ public Action:RemoveColouredBlocks(Handle:timer, any:bhop) SetEntDataArray(bhop, g_iOffs_clrRender , colour, 4, 1, true); } -FindBhopBlocks() +FindBhopBlocks() { if(g_Settings[MultiBhopEnable]) { decl Float:startpos[3], Float:endpos[3], Float:mins[3], Float:maxs[3], tele; new ent = -1; - while((ent = FindEntityByClassname(ent,"func_door")) != -1) + while((ent = FindEntityByClassname(ent,"func_door")) != -1) { - if(g_iDoorOffs_vecPosition1 == -1) + if(g_iDoorOffs_vecPosition1 == -1) { g_iDoorOffs_vecPosition1 = FindDataMapOffs(ent,"m_vecPosition1"); g_iDoorOffs_vecPosition2 = FindDataMapOffs(ent,"m_vecPosition2"); @@ -1642,7 +1657,7 @@ FindBhopBlocks() GetEntDataVector(ent,g_iDoorOffs_vecPosition1,startpos); GetEntDataVector(ent,g_iDoorOffs_vecPosition2,endpos); - if(startpos[2] > endpos[2]) + if(startpos[2] > endpos[2]) { GetEntDataVector(ent,g_iOffs_vecMins,mins); GetEntDataVector(ent,g_iOffs_vecMaxs,maxs); @@ -1651,12 +1666,12 @@ FindBhopBlocks() startpos[1] += (mins[1] + maxs[1]) * 0.5; startpos[2] += maxs[2]; - if((tele = CustomTraceForTeleports(startpos,endpos[2] + maxs[2])) != -1) + if((tele = CustomTraceForTeleports(startpos,endpos[2] + maxs[2])) != -1) { g_iBhopDoorList[g_iBhopDoorCount] = ent; g_iBhopDoorTeleList[g_iBhopDoorCount] = tele; - if(++g_iBhopDoorCount == sizeof g_iBhopDoorList) + if(++g_iBhopDoorCount == sizeof g_iBhopDoorList) { break; } @@ -1666,9 +1681,9 @@ FindBhopBlocks() ent = -1; - while((ent = FindEntityByClassname(ent,"func_button")) != -1) + while((ent = FindEntityByClassname(ent,"func_button")) != -1) { - if(g_iButtonOffs_vecPosition1 == -1) + if(g_iButtonOffs_vecPosition1 == -1) { g_iButtonOffs_vecPosition1 = FindDataMapOffs(ent,"m_vecPosition1"); g_iButtonOffs_vecPosition2 = FindDataMapOffs(ent,"m_vecPosition2"); @@ -1679,7 +1694,7 @@ FindBhopBlocks() GetEntDataVector(ent,g_iButtonOffs_vecPosition1,startpos); GetEntDataVector(ent,g_iButtonOffs_vecPosition2,endpos); - if(startpos[2] > endpos[2] && (GetEntData(ent,g_iButtonOffs_spawnflags,4) & SF_BUTTON_TOUCH_ACTIVATES)) + if(startpos[2] > endpos[2] && (GetEntData(ent,g_iButtonOffs_spawnflags,4) & SF_BUTTON_TOUCH_ACTIVATES)) { GetEntDataVector(ent,g_iOffs_vecMins,mins); GetEntDataVector(ent,g_iOffs_vecMaxs,maxs); @@ -1688,12 +1703,12 @@ FindBhopBlocks() startpos[1] += (mins[1] + maxs[1]) * 0.5; startpos[2] += maxs[2]; - if((tele = CustomTraceForTeleports(startpos,endpos[2] + maxs[2])) != -1) + if((tele = CustomTraceForTeleports(startpos,endpos[2] + maxs[2])) != -1) { g_iBhopButtonList[g_iBhopButtonCount] = ent; g_iBhopButtonTeleList[g_iBhopButtonCount] = tele; - if(++g_iBhopButtonCount == sizeof g_iBhopButtonList) + if(++g_iBhopButtonCount == sizeof g_iBhopButtonList) { break; } @@ -1706,77 +1721,77 @@ FindBhopBlocks() stock GetBhopDoorID(entity) { - for (new i = 0; i < g_iBhopDoorCount; i++) + for (new i = 0; i < g_iBhopDoorCount; i++) { if(entity == g_iBhopDoorList[i]) return i; } - + return -1; } stock GetBhopButtonID(entity) { - for (new i = 0; i < g_iBhopButtonCount; i++) + for (new i = 0; i < g_iBhopButtonCount; i++) { if(entity == g_iBhopButtonList[i]) return i; } - + return -1; } stock bool:GetBhopAvoidComplete(client) { - for (new i = 0; i < g_iBhopDoorCount; i++) + for (new i = 0; i < g_iBhopDoorCount; i++) { if(!g_bBhopDoorAvoid[i]) continue; - + if(g_bBhopDoorClientAvoid[i][client]) return false; } - - for (new i = 0; i < g_iBhopButtonCount; i++) + + for (new i = 0; i < g_iBhopButtonCount; i++) { if(!g_bBhopButtonAvoid[i]) continue; - + if(g_bBhopButtonClientAvoid[i][client]) return false; } - + return true; } stock bool:GetBhopCollectComplete(client) { - for (new i = 0; i < g_iBhopDoorCount; i++) + for (new i = 0; i < g_iBhopDoorCount; i++) { if(!g_bBhopDoorCollect[i]) continue; - + if(!g_bBhopDoorClientCollect[i][client]) return false; } - - for (new i = 0; i < g_iBhopButtonCount; i++) + + for (new i = 0; i < g_iBhopButtonCount; i++) { if(!g_bBhopButtonCollect[i]) continue; - + if(!g_bBhopButtonClientCollect[i][client]) return false; } - + return true; } stock ResetBhopAvoid(client) { g_iBhopClientAvoid[client] = 0; - - for (new i = 0; i < g_iBhopDoorCount; i++) + + for (new i = 0; i < g_iBhopDoorCount; i++) { g_bBhopDoorClientAvoid[i][client] = false; g_bBhopButtonClientAvoid[i][client] = false; @@ -1786,15 +1801,15 @@ stock ResetBhopAvoid(client) stock ResetBhopCollect(client) { g_iBhopClientCollect[client] = 0; - - for (new i = 0; i < g_iBhopDoorCount; i++) + + for (new i = 0; i < g_iBhopDoorCount; i++) { g_bBhopDoorClientCollect[i][client] = false; g_bBhopButtonClientCollect[i][client] = false; } } -AlterBhopBlocks(bool:bRevertChanges) +AlterBhopBlocks(bool:bRevertChanges) { if(g_Settings[MultiBhopEnable]) { @@ -1809,12 +1824,12 @@ AlterBhopBlocks(bool:bRevertChanges) decl ent, i; - if(bRevertChanges) + if(bRevertChanges) { g_iBhopCollectMax = 0; g_iBhopAvoidMax = 0; - - for (i = 0; i < g_iBhopDoorCount; i++) + + for (i = 0; i < g_iBhopDoorCount; i++) { ent = g_iBhopDoorList[i]; g_bBhopDoorAvoid[i] = false; @@ -1825,15 +1840,15 @@ AlterBhopBlocks(bool:bRevertChanges) g_bBhopDoorClientAvoid[i][client] = false; g_bBhopDoorClientCollect[i][client] = false; } - - if(IsValidEntity(ent)) + + if(IsValidEntity(ent)) { SetEntDataArray(ent, g_iOffs_clrRender , {255, 255, 255, 255}, 4, 1, true); SetEntDataVector(ent,g_iDoorOffs_vecPosition2,vecDoorPosition2[i]); SetEntDataFloat(ent,g_iDoorOffs_flSpeed,flDoorSpeed[i]); SetEntData(ent,g_iDoorOffs_spawnflags,iDoorSpawnflags[i],4); - - if(!bDoorLocked[i]) + + if(!bDoorLocked[i]) { AcceptEntityInput(ent,"Unlock"); } @@ -1842,10 +1857,10 @@ AlterBhopBlocks(bool:bRevertChanges) } } - for (i = 0; i < g_iBhopButtonCount; i++) + for (i = 0; i < g_iBhopButtonCount; i++) { ent = g_iBhopButtonList[i]; - + g_bBhopButtonAvoid[i] = false; g_bBhopButtonCollect[i] = false; @@ -1854,8 +1869,8 @@ AlterBhopBlocks(bool:bRevertChanges) g_bBhopButtonClientAvoid[i][client] = false; g_bBhopButtonClientCollect[i][client] = false; } - - if(IsValidEntity(ent)) + + if(IsValidEntity(ent)) { SetEntDataArray(ent, g_iOffs_clrRender , {255, 255, 255, 255}, 4, 1, true); SetEntDataVector(ent,g_iButtonOffs_vecPosition2,vecButtonPosition2[i]); @@ -1866,30 +1881,30 @@ AlterBhopBlocks(bool:bRevertChanges) } } } - else + else { g_iBhopCollectMax = 0; g_iBhopAvoidMax = 0; - + g_PlattformColorAvoid[0] = 255; g_PlattformColorAvoid[1] = 0; g_PlattformColorAvoid[2] = 0; g_PlattformColorAvoid[3] = 255; - + g_PlattformColorCollect[0] = 0; g_PlattformColorCollect[1] = 255; g_PlattformColorCollect[2] = 0; g_PlattformColorCollect[3] = 255; - + new Float:random; - + //note: This only gets called directly after finding the blocks, so the entities are valid. decl Float:startpos[3]; - for (i = 0; i < g_iBhopDoorCount; i++) + for (i = 0; i < g_iBhopDoorCount; i++) { ent = g_iBhopDoorList[i]; - + if(g_Settings[VegasEnable] && g_Settings[VegasMinPlattfors] <= g_iBhopDoorCount+g_iBhopButtonCount && (g_iVegasWinCount < g_Settings[VegasMapMaxGames] || g_Settings[VegasMapMaxGames] == 0)) { for (new client = 1; client <= MaxClients; client++) @@ -1901,23 +1916,23 @@ AlterBhopBlocks(bool:bRevertChanges) } random = GetRandomFloat(0.0, 100.0); - + new Float:avoidchance = g_Settings[VegasAvoidChance]+(g_Settings[VegasAvoidChanceAdd]*g_iVegasWinCount); - - if(random < avoidchance) + + if(random < avoidchance) { g_bBhopDoorAvoid[i] = true; g_iBhopAvoidMax++; SetEntDataArray(ent, g_iOffs_clrRender , g_PlattformColorAvoid, 4, 1, true); } - else if(random < avoidchance+g_Settings[VegasCollectChance]+(g_Settings[VegasCollectChanceAdd]*g_iVegasWinCount)) + else if(random < avoidchance+g_Settings[VegasCollectChance]+(g_Settings[VegasCollectChanceAdd]*g_iVegasWinCount)) { g_bBhopDoorCollect[i] = true; g_iBhopCollectMax++; SetEntDataArray(ent, g_iOffs_clrRender , g_PlattformColorCollect, 4, 1, true); } } - + GetEntDataVector(ent,g_iDoorOffs_vecPosition2,vecDoorPosition2[i]); flDoorSpeed[i] = GetEntDataFloat(ent,g_iDoorOffs_flSpeed); iDoorSpawnflags[i] = GetEntData(ent,g_iDoorOffs_spawnflags,4); @@ -1935,7 +1950,7 @@ AlterBhopBlocks(bool:bRevertChanges) SDKHook(ent,SDKHook_Touch,Entity_Touch); } - for (i = 0; i < g_iBhopButtonCount; i++) + for (i = 0; i < g_iBhopButtonCount; i++) { ent = g_iBhopButtonList[i]; @@ -1950,14 +1965,14 @@ AlterBhopBlocks(bool:bRevertChanges) } random = GetRandomFloat(0.0, 100.0); - - if(random < g_Settings[VegasAvoidChance]) + + if(random < g_Settings[VegasAvoidChance]) { SetEntDataArray(ent, g_iOffs_clrRender , g_PlattformColorAvoid, 4, 1, true); g_iBhopAvoidMax++; g_bBhopButtonAvoid[i] = true; } - else if(random < g_Settings[VegasCollectChance]+g_Settings[VegasAvoidChance]) + else if(random < g_Settings[VegasCollectChance]+g_Settings[VegasAvoidChance]) { SetEntDataArray(ent, g_iOffs_clrRender , g_PlattformColorCollect, 4, 1, true); g_iBhopCollectMax++; @@ -1981,12 +1996,12 @@ AlterBhopBlocks(bool:bRevertChanges) } } -CustomTraceForTeleports(const Float:startpos[3],Float:endheight,Float:step=1.0) +CustomTraceForTeleports(const Float:startpos[3],Float:endheight,Float:step=1.0) { decl teleports[512]; new tpcount, ent = -1; - while((ent = FindEntityByClassname(ent,"trigger_teleport")) != -1 && tpcount != sizeof teleports) + while((ent = FindEntityByClassname(ent,"trigger_teleport")) != -1 && tpcount != sizeof teleports) { teleports[tpcount++] = ent; } @@ -1997,13 +2012,14 @@ CustomTraceForTeleports(const Float:startpos[3],Float:endheight,Float:step=1.0) origin[1] = startpos[1]; origin[2] = startpos[2]; - do { - for (i = 0; i < tpcount; i++) + do + { + for (i = 0; i < tpcount; i++) { ent = teleports[i]; GetAbsBoundingBox(ent,mins,maxs); - if(mins[0] <= origin[0] <= maxs[0] && mins[1] <= origin[1] <= maxs[1] && mins[2] <= origin[2] <= maxs[2]) + if(mins[0] <= origin[0] <= maxs[0] && mins[1] <= origin[1] <= maxs[1] && mins[2] <= origin[2] <= maxs[2]) { return ent; } @@ -2015,7 +2031,7 @@ CustomTraceForTeleports(const Float:startpos[3],Float:endheight,Float:step=1.0) return -1; } -GetAbsBoundingBox(ent,Float:mins[3],Float:maxs[3]) +GetAbsBoundingBox(ent,Float:mins[3],Float:maxs[3]) { decl Float:origin[3]; @@ -2040,11 +2056,11 @@ public Action:Timer_UpdateGravity(Handle:timer) { if(IsClientConnected(client) && IsClientSourceTV(client)) continue; - + if(g_timerMapzones) - if(Timer_IsPlayerTouchingZoneType(client, ZtNoGravityOverwrite)) + if(Timer_IsPlayerTouchingZoneType(client, ZtNoGravityOverwrite)) continue; - + //gravity update new style = Timer_GetStyle(client); if(g_Physics[style][StyleCustom] && !g_bCustomLowGravity[client]) @@ -2057,7 +2073,7 @@ public Action:Timer_UpdateGravity(Handle:timer) SetEntityGravity(client, g_Physics[style][StyleGravity]); continue; } - + SetEntityGravity(client, 1.0); } } @@ -2073,7 +2089,7 @@ public Action:Timer_CheckNoClip(Handle:timer) { if(IsClientConnected(client) && IsClientSourceTV(client)) continue; - + //has player noclip? if(GetEntProp(client, Prop_Send, "movetype", 1) == 8) { @@ -2082,7 +2098,7 @@ public Action:Timer_CheckNoClip(Handle:timer) SetEntityMoveType(client, MOVETYPE_WALK); CheckVelocity(client, 1, 0.1); } - + Timer_Stop(client, false); ResetBhopAvoid(client); ResetBhopCollect(client); @@ -2097,7 +2113,7 @@ ParseColor(const String:color[], result[]) { decl String:buffers[4][4]; ExplodeString(color, " ", buffers, sizeof(buffers), sizeof(buffers[])); - + for (new i = 0; i < sizeof(buffers); i++) result[i] = StringToInt(buffers[i]); } @@ -2106,33 +2122,33 @@ stock Client_Push(client, Float:clientEyeAngle[3], Float:power, VelocityOverride { decl Float:forwardVector[3], Float:newVel[3]; - + GetAngleVectors(clientEyeAngle, forwardVector, NULL_VECTOR, NULL_VECTOR); NormalizeVector(forwardVector, forwardVector); ScaleVector(forwardVector, power); - + Entity_GetAbsVelocity(client,newVel); - + for (new i=0;i<3;i++){ switch(override[i]){ case VelocityOvr_Velocity:{ newVel[i] = 0.0; } - case VelocityOvr_OnlyWhenNegative:{ + case VelocityOvr_OnlyWhenNegative:{ if(newVel[i] < 0.0){ newVel[i] = 0.0; } } - case VelocityOvr_InvertReuseVelocity:{ + case VelocityOvr_InvertReuseVelocity:{ if(newVel[i] < 0.0){ newVel[i] *= -1.0; } } } - + newVel[i] += forwardVector[i]; } - + Entity_SetAbsVelocity(client,newVel); } @@ -2140,9 +2156,9 @@ public Action:Command_ReloadConfig(client, args) { LoadPhysics(); LoadTimerSettings(); - + ReplyToCommand(client, "Timer: Settings reloaded."); - + return Plugin_Handled; } @@ -2153,7 +2169,7 @@ public Action:Command_NoclipMe(client, args) ReplyToCommand(client, "\x04[SM] \x05You need to be alive to use noclip"); return Plugin_Handled; } - + if(g_Settings[NoclipEnable]) { if (GetEntityMoveType(client) != MOVETYPE_NOCLIP && !Timer_IsPlayerTouchingZoneType(client, ZtAntiNoclip)) @@ -2170,7 +2186,7 @@ public Action:Command_NoclipMe(client, args) } } else ReplyToCommand(client, "You have not access to this command."); - + return Plugin_Handled; } @@ -2180,7 +2196,7 @@ public Action:Command_Colour(client, args) { return Plugin_Handled; } - + if (g_colourme[client] == 1) { g_colourme[client] = 0; @@ -2189,7 +2205,7 @@ public Action:Command_Colour(client, args) { g_colourme[client] = 1; } - + return Plugin_Handled; } @@ -2199,7 +2215,7 @@ public Action:Command_ToggleAuto(client, args) { return Plugin_Handled; } - + if (g_bAutoDisable[client]) { g_bAutoDisable[client] = false; @@ -2216,7 +2232,7 @@ public Action:Command_ToggleAuto(client, args) public Action:Timer_Push(Handle:timer, any:client) { Push_Client(client); - + return Plugin_Stop; } @@ -2232,7 +2248,7 @@ public Action:Timer_Boost(Handle:timer, any:client) { new style = Timer_GetStyle(client); Client_BoostForward(client, g_Physics[style][StyleBoostForward], g_Physics[style][StyleBoostForwardMax]); - + return Plugin_Stop; } @@ -2240,10 +2256,10 @@ Client_BoostForward(client, Float:scale, Float:maxspeed) { new Float:fVelocity[3]; GetEntPropVector(client, Prop_Data, "m_vecVelocity", fVelocity); - + fVelocity[0] = fVelocity[0]*scale; fVelocity[1] = fVelocity[1]*scale; - + if(maxspeed == 0.0 || SquareRoot(Pow(fVelocity[0],2.0)+Pow(fVelocity[1],2.0)) < maxspeed) { TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, fVelocity); @@ -2253,13 +2269,13 @@ Client_BoostForward(client, Float:scale, Float:maxspeed) PunishAbuse(client, type = -1) { new style = Timer_GetStyle(client); - + if(type == -1) type = g_Physics[style][StylePunishType]; - + if(type <= 0) return; - + //Block controls if(type == 1) { diff --git a/gameserver/addons/sourcemod/scripting/timer-rankings.sp b/gameserver/addons/sourcemod/scripting/timer-rankings.sp index c77968b..55a302f 100644 --- a/gameserver/addons/sourcemod/scripting/timer-rankings.sp +++ b/gameserver/addons/sourcemod/scripting/timer-rankings.sp @@ -1,3 +1,5 @@ +#pragma dynamic 131072 + #include #include #include @@ -551,17 +553,15 @@ public OnClientDisconnect(client) if(!g_iEnabled) return; - //g_sAuth[client][0] = '\0'; - if(g_bAuthed[client]) { new points, points_start; if(KvJumpToKey(g_hSession, g_sAuth[client], false)) { points_start = KvGetNum(g_hSession, "points", 0); - points = Timer_GetPoints(client); + points = g_iCurrentPoints[client]; } - + KvSetFloat(g_hSession, "disconnec_time", GetEngineTime()); new String:sPre[3]; @@ -575,8 +575,8 @@ public OnClientDisconnect(client) { GetArrayString(g_hCfgArray_DisplayChat, g_iCurrentIndex[client], sNameBuffer, sizeof(sNameBuffer)); } - - if(g_iPositionMethod == 2) + + if(g_iPositionMethod == 2 || points <= 0) { #if defined LEGACY_COLORS CFormat(sNameBuffer, 1024, client); @@ -605,9 +605,11 @@ public OnClientDisconnect(client) g_bLoadedCookies[client] = false; g_iNextIndex[client] = -1; + + g_iCurrentPoints[client] = -1; + g_iCurrentRank[client] = -1; g_iCurrentIndex[client] = -1; g_iCompletions[client] = 0; - g_iCurrentPoints[client] = -1; g_iLastGlobalMessage[client] = 0; g_iClientDisplay[client] = 0; } @@ -1613,7 +1615,7 @@ ShowConnectMsg(client) { #if defined LEGACY_COLORS CFormat(sNameBuffer, 1024, client); - CPrintToChatAll("%s%N {olive}[{lightred}%d points{olive}] connected from %s.", sNameBuffer, client, g_iCurrentPoints[client], s_Country); + CPrintToChatAll("%s%N: {default}rank {yellow}%d/%d {default}with {yellow}%d points {default}connected from {lightgreen}%s{default}.", sNameBuffer, client, g_iCurrentRank[client], g_iTotalPlayers, g_iCurrentPoints[client], s_Country); #else CReplaceColorCodes(sNameBuffer, client, false, 1024); CPrintToChatAll("%s%N {green}[{yellow}%d points{green}] connected from %s.", sNameBuffer, client, g_iCurrentPoints[client], s_Country); @@ -2596,9 +2598,16 @@ public Native_GetPointRank(Handle:plugin, numParams) public Native_GetTag(Handle:plugin, numParams) { - decl String:sTagBuffer[128]; - GetArrayString(g_hCfgArray_DisplayTag, g_iCurrentIndex[GetNativeCell(3)], sTagBuffer, sizeof(sTagBuffer)); - SetNativeString(1, sTagBuffer, GetNativeCell(2)); + if(g_iCurrentIndex[GetNativeCell(3)] != -1) + { + decl String:sTagBuffer[128]; + GetArrayString(g_hCfgArray_DisplayTag, g_iCurrentIndex[GetNativeCell(3)], sTagBuffer, sizeof(sTagBuffer)); + SetNativeString(1, sTagBuffer, GetNativeCell(2)); + } + else + { + SetNativeString(1, g_sLoadingChatTag, GetNativeCell(2)); + } } public Native_GetChatTag(Handle:plugin, numParams) diff --git a/gameserver/addons/sourcemod/scripting/timer-sound.sp b/gameserver/addons/sourcemod/scripting/timer-sound.sp index d208df0..2dcde18 100644 --- a/gameserver/addons/sourcemod/scripting/timer-sound.sp +++ b/gameserver/addons/sourcemod/scripting/timer-sound.sp @@ -9,23 +9,29 @@ #define MAX_FILE_LEN 128 -new Handle:Sound_TimerFinish = INVALID_HANDLE; -new String:SND_TIMER_FINISH[MAX_FILE_LEN]; +new Handle:g_hTimerFinish = INVALID_HANDLE; +new String:g_sTimerFinish[MAX_FILE_LEN]; +new bool:g_bTimerFinish = false; -new Handle:Sound_TimerResume = INVALID_HANDLE; -new String:SND_TIMER_RESUME[MAX_FILE_LEN]; +new Handle:g_hTimerResume = INVALID_HANDLE; +new String:g_sTimerResume[MAX_FILE_LEN]; +new bool:g_bTimerResume = false; -new Handle:Sound_TimerPause = INVALID_HANDLE; -new String:SND_TIMER_PAUSE[MAX_FILE_LEN]; +new Handle:g_hTimerPause = INVALID_HANDLE; +new String:g_sTimerPause[MAX_FILE_LEN]; +new bool:g_bTimerPause = false; -new Handle:Sound_TimerWorldRecord = INVALID_HANDLE; -new String:SND_TIMER_WORLDRECORD[MAX_FILE_LEN]; +new Handle:g_hTimerWorldRecord = INVALID_HANDLE; +new String:g_sTimerWorldRecord[MAX_FILE_LEN]; +new bool:g_bTimerWorldRecord = false; -new Handle:Sound_TimerWorldRecordAll = INVALID_HANDLE; -new String:SND_TIMER_WORLDRECORD_ALL[MAX_FILE_LEN]; +new Handle:g_hTimerWorldRecordAll = INVALID_HANDLE; +new String:g_sTimerWorldRecordAll[MAX_FILE_LEN]; +new bool:g_bTimerWorldRecordAll = false; -new Handle:Sound_TimerPersonalBest = INVALID_HANDLE; -new String:SND_TIMER_PERSONALBEST[MAX_FILE_LEN]; +new Handle:g_hTimerPersonalBest = INVALID_HANDLE; +new String:g_sTimerPersonalBest[MAX_FILE_LEN]; +new bool:g_bTimerPersonalBest = false; public Plugin:myinfo = { @@ -38,81 +44,114 @@ public Plugin:myinfo = public OnPluginStart() { - Sound_TimerFinish = CreateConVar("timer_sound_finish", "ui/freeze_cam.wav", ""); - Sound_TimerWorldRecord = CreateConVar("timer_sound_worldrecord", "ui/freeze_cam.wav", ""); - Sound_TimerWorldRecordAll = CreateConVar("timer_sound_worldrecord_all", "ui/freeze_cam.wav", ""); - Sound_TimerPause = CreateConVar("timer_sound_pause", "ui/freeze_cam.wav", ""); - Sound_TimerResume = CreateConVar("timer_sound_resume", "ui/freeze_cam.wav", ""); - Sound_TimerPersonalBest = CreateConVar("timer_sound_personalbest", "ui/freeze_cam.wav", ""); - - AutoExecConfig(true, "timer/timer-sounds"); + g_hTimerFinish = CreateConVar("timer_sound_finish", "ui/freeze_cam.wav", ""); + g_hTimerWorldRecord = CreateConVar("timer_sound_worldrecord", "ui/freeze_cam.wav", ""); + g_hTimerWorldRecordAll = CreateConVar("timer_sound_worldrecord_all", "ui/freeze_cam.wav", ""); + g_hTimerPause = CreateConVar("timer_sound_pause", "ui/freeze_cam.wav", ""); + g_hTimerResume = CreateConVar("timer_sound_resume", "ui/freeze_cam.wav", ""); + g_hTimerPersonalBest = CreateConVar("timer_sound_personalbest", "ui/freeze_cam.wav", ""); + + AutoExecConfig(true, "timer/timer-sounds"); } public OnConfigsExecuted() { - CacheSounds(); - Timer_LogTrace("[Sound] Sounds cached OnConfigsExecuted"); + CacheSounds(); + Timer_LogTrace("[Sound] Sounds cached OnConfigsExecuted"); } public CacheSounds() { - GetConVarString(Sound_TimerFinish, SND_TIMER_FINISH, sizeof(SND_TIMER_FINISH)); - PrepareSound(SND_TIMER_FINISH); - - GetConVarString(Sound_TimerPause, SND_TIMER_PAUSE, sizeof(SND_TIMER_PAUSE)); - PrepareSound(SND_TIMER_PAUSE); - - GetConVarString(Sound_TimerResume, SND_TIMER_RESUME, sizeof(SND_TIMER_RESUME)); - PrepareSound(SND_TIMER_FINISH); - - GetConVarString(Sound_TimerWorldRecord, SND_TIMER_WORLDRECORD, sizeof(SND_TIMER_WORLDRECORD)); - PrepareSound(SND_TIMER_WORLDRECORD); - - GetConVarString(Sound_TimerWorldRecordAll, SND_TIMER_WORLDRECORD_ALL, sizeof(SND_TIMER_WORLDRECORD_ALL)); - PrepareSound(SND_TIMER_WORLDRECORD_ALL); - - GetConVarString(Sound_TimerPersonalBest, SND_TIMER_PERSONALBEST, sizeof(SND_TIMER_PERSONALBEST)); - PrepareSound(SND_TIMER_PERSONALBEST); + GetConVarString(g_hTimerFinish, g_sTimerFinish, sizeof(g_sTimerFinish)); + GetConVarString(g_hTimerPause, g_sTimerPause, sizeof(g_sTimerPause)); + GetConVarString(g_hTimerResume, g_sTimerResume, sizeof(g_sTimerResume)); + GetConVarString(g_hTimerWorldRecord, g_sTimerWorldRecord, sizeof(g_sTimerWorldRecord)); + GetConVarString(g_hTimerWorldRecordAll, g_sTimerWorldRecordAll, sizeof(g_sTimerWorldRecordAll)); + GetConVarString(g_hTimerPersonalBest, g_sTimerPersonalBest, sizeof(g_sTimerPersonalBest)); + + if(GetEngineVersion() == Engine_CSGO && StrContains(g_sTimerFinish, ".mp3", false) || GetEngineVersion() == Engine_CSS && StrContains(g_sTimerFinish, ".mp3", false) || StrContains(g_sTimerFinish, ".wav", false)) + { + g_bTimerFinish = PrepareSound(g_sTimerFinish); + } + if(GetEngineVersion() == Engine_CSGO && StrContains(g_sTimerPause, ".mp3", false) || GetEngineVersion() == Engine_CSS && StrContains(g_sTimerPause, ".mp3", false) || StrContains(g_sTimerPause, ".wav", false)) + { + g_bTimerPause = PrepareSound(g_sTimerPause); + } + if(GetEngineVersion() == Engine_CSGO && StrContains(g_sTimerResume, ".mp3", false) || GetEngineVersion() == Engine_CSS && StrContains(g_sTimerResume, ".mp3", false) || StrContains(g_sTimerResume, ".wav", false)) + { + g_bTimerResume = PrepareSound(g_sTimerResume); + } + if(GetEngineVersion() == Engine_CSGO && StrContains(g_sTimerWorldRecord, ".mp3", false) || GetEngineVersion() == Engine_CSS && StrContains(g_sTimerWorldRecord, ".mp3", false) || StrContains(g_sTimerWorldRecord, ".wav", false)) + { + g_bTimerWorldRecord = PrepareSound(g_sTimerWorldRecord); + } + if(GetEngineVersion() == Engine_CSGO && StrContains(g_sTimerWorldRecordAll, ".mp3", false) || GetEngineVersion() == Engine_CSS && StrContains(g_sTimerWorldRecordAll, ".mp3", false) || StrContains(g_sTimerWorldRecordAll, ".wav", false)) + { + g_bTimerWorldRecordAll = PrepareSound(g_sTimerWorldRecordAll); + } + if(GetEngineVersion() == Engine_CSGO && StrContains(g_sTimerPersonalBest, ".mp3", false) || GetEngineVersion() == Engine_CSS && StrContains(g_sTimerPersonalBest, ".mp3", false) || StrContains(g_sTimerPersonalBest, ".wav", false)) + { + g_bTimerPersonalBest = PrepareSound(g_sTimerPersonalBest); + } } -public PrepareSound(String: sound[MAX_FILE_LEN]) +public bool:PrepareSound(String: sound[MAX_FILE_LEN]) { - decl String:fileSound[MAX_FILE_LEN]; + decl String:fileSound[MAX_FILE_LEN]; - FormatEx(fileSound, MAX_FILE_LEN, "sound/%s", sound); + FormatEx(fileSound, MAX_FILE_LEN, "sound/%s", sound); - if (FileExists(fileSound)) - { - PrecacheSoundAny(sound, true); - AddFileToDownloadsTable(fileSound); - Timer_LogTrace("[Sound] File '%s' added to downloads table.", fileSound); - } + if (FileExists(fileSound) && g_bTimerWorldRecord) + { + new bool:bReturn; + bReturn = PrecacheSoundAny(sound, true); + AddFileToDownloadsTable(fileSound); + Timer_LogTrace("[Sound] File '%s' added to downloads table.", fileSound); + + return bReturn; + } + return false; } public OnTimerPaused(client) { - EmitSoundToClientAny(client, SND_TIMER_PAUSE); + if(g_bTimerPause) + { + EmitSoundToClientAny(client, g_sTimerPause); + } } public OnTimerResumed(client) { - EmitSoundToClientAny(client, SND_TIMER_RESUME); + if(g_bTimerResume) + { + EmitSoundToClientAny(client, g_sTimerResume); + } } public OnTimerWorldRecord(client) { - //Stop the sound first - EmitSoundToAllAny(SND_TIMER_WORLDRECORD_ALL, _, _, _, SND_STOPLOOPING); - - EmitSoundToAllAny(SND_TIMER_WORLDRECORD_ALL); + if(g_bTimerWorldRecordAll) + { + //Stop the sound first + EmitSoundToAllAny(g_sTimerWorldRecordAll, _, _, _, SND_STOPLOOPING); + + EmitSoundToAllAny(g_sTimerWorldRecordAll); + } } public OnTimerPersonalRecord(client) { - EmitSoundToClientAny(client, SND_TIMER_PERSONALBEST); + if(g_bTimerPersonalBest) + { + EmitSoundToClientAny(client, g_sTimerPersonalBest); + } } public OnTimerRecord(client) { - EmitSoundToClientAny(client, SND_TIMER_FINISH); + if(g_bTimerFinish) + { + EmitSoundToClientAny(client, g_sTimerFinish); + } } diff --git a/gameserver/addons/sourcemod/scripting/timer-spec.sp b/gameserver/addons/sourcemod/scripting/timer-spec.sp index 3ee8887..d4fff6b 100644 --- a/gameserver/addons/sourcemod/scripting/timer-spec.sp +++ b/gameserver/addons/sourcemod/scripting/timer-spec.sp @@ -16,11 +16,10 @@ public Plugin:myinfo ={ }; public OnPluginStart() -{ +{ RegConsoleCmd("sm_spec", Command_spec, "sm_spec - Spectates a player."); RegConsoleCmd("sm_spectate", Command_spec, "sm_spectate - Spectates a player."); RegConsoleCmd("sm_specmost", Cmd_SpecMost); - RegConsoleCmd("sm_speclist", Cmd_SpecList); RegConsoleCmd("sm_specfar", Cmd_SpecFar); LoadTranslations("common.phrases"); } @@ -42,9 +41,9 @@ public Action:Command_spec(client, args) } new String:arg1[64]; GetCmdArgString(arg1, sizeof(arg1)); - + new target = FindTarget(client, arg1, true, true); - if (target == -1) + if (target == -1) { return Plugin_Handled; } @@ -71,9 +70,9 @@ public Action:Cmd_SpecMost(client, args) { if(i == client) continue; - - spectators = 0; - + + spectators = 0; + if(Client_IsValid(i, true)) { for(new x = 1; x <= MaxClients; x++) @@ -82,9 +81,9 @@ public Action:Cmd_SpecMost(client, args) { continue; } - + new SpecMode = GetEntProp(x, Prop_Send, "m_iObserverMode"); - + if(SpecMode == 4 || SpecMode == 5) { if(GetEntPropEnt(x, Prop_Send, "m_hObserverTarget") == target) @@ -108,64 +107,25 @@ public Action:Cmd_SpecMost(client, args) return Plugin_Handled; } -public Action:Cmd_SpecList(client, args) -{ - new spectators = 0, String:buffer[1024]; - - for(new i = 1; i <= MaxClients; i++) - { - if(i == client) - continue; - - if(Client_IsValid(i, true)) - { - // missing check for IsClientInGame in Client_IsValid? - if(IsClientInGame(i)) - { - new SpecMode = GetEntProp(i, Prop_Send, "m_iObserverMode"); - - if(SpecMode == 4 || SpecMode == 5) - { - if(GetEntPropEnt(i, Prop_Send, "m_hObserverTarget") == client) - { - spectators++; - if(spectators > 1) Format(buffer, sizeof(buffer), "%s, %N", buffer, i); - else Format(buffer, sizeof(buffer), "%N", i); - } - } - } - } - } - - if(spectators > 0) - { - PrintToChat(client, "[SPEC-LIST] You have %d spectators:", spectators); - PrintToChat(client, "%s.", buffer); - } - else PrintToChat(client, "[SPEC-LIST] Nobody is spectating you."); - - return Plugin_Handled; -} - public Action:Cmd_SpecFar(client, args) { new MaxLevel, Level, target, oldtarget; oldtarget = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget"); - + for(new i = 1; i <= MaxClients; i++) { if(i == client) continue; - + if(i == oldtarget) continue; - + if(!Client_IsValid(i, true)) continue; - + Level = Timer_GetClientLevel(i); - + if(Level > MaxLevel) { MaxLevel = Level; diff --git a/gameserver/addons/sourcemod/scripting/timer-teams.sp b/gameserver/addons/sourcemod/scripting/timer-teams.sp index ecc4047..27fb4fe 100644 --- a/gameserver/addons/sourcemod/scripting/timer-teams.sp +++ b/gameserver/addons/sourcemod/scripting/timer-teams.sp @@ -21,7 +21,6 @@ new String:g_currentMap[64]; new g_clientTeammate[MAXPLAYERS+1]=0; new bool:g_bClientCoop[MAXPLAYERS+1]; -new g_iCoopCountdown[MAXPLAYERS+1]; new bool:g_bClientChallenge[MAXPLAYERS+1]; new g_iChallengeCountdown[MAXPLAYERS+1]; @@ -41,10 +40,7 @@ new Handle:g_OnChallengeConfirm; new Handle:g_OnChallengeWin; new Handle:g_OnChallengeForceEnd; -new Handle:g_OnCoopStart; new Handle:g_OnCoopConfirm; -new Handle:g_OnCoopWin; -new Handle:g_OnCoopForceEnd; new Float:g_fLastRun[MAXPLAYERS+1]; @@ -64,28 +60,40 @@ public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max) RegPluginLibrary("timer-teams"); CreateNative("Timer_GetChallengeStatus", Native_GetChallengeStatus); CreateNative("Timer_GetCoopStatus", Native_GetCoopStatus); - + CreateNative("Timer_GetClientTeammate", Native_GetClientTeammate); CreateNative("Timer_SetClientTeammate", Native_SetClientTeammate); - + return APLRes_Success; } public OnPluginStart() { g_timerPhysics = LibraryExists("timer-physics"); - + LoadPhysics(); LoadTimerSettings(); - + LoadTranslations("timer.phrases"); if(g_Settings[ChallengeEnable]) RegConsoleCmd("sm_challenge", Command_Challenge); - if(g_Settings[CoopEnable]) RegConsoleCmd("sm_coop", Command_Coop); + + if(g_Settings[CoopEnable]) + { + RegConsoleCmd("sm_coop", Command_Coop); + RegConsoleCmd("sm_partner", Command_Coop); + RegConsoleCmd("sm_mate", Command_Coop); + RegConsoleCmd("sm_party", Command_Coop); + + RegConsoleCmd("sm_uncoop", Command_UnCoop); + RegConsoleCmd("sm_unpartner", Command_UnCoop); + RegConsoleCmd("sm_unmate", Command_UnCoop); + RegConsoleCmd("sm_unparty", Command_UnCoop); + } Sound_ChallengeStart = CreateConVar("timer_sound_challenge_start", "ui/freeze_cam.wav", ""); Sound_TimerOwned = CreateConVar("timer_sound_owned", "ui/freeze_cam.wav", ""); - + HookConVarChange(Sound_ChallengeStart, Action_OnSettingsChange); HookConVarChange(Sound_TimerOwned, Action_OnSettingsChange); @@ -93,14 +101,11 @@ public OnPluginStart() g_OnChallengeStart = CreateGlobalForward("OnChallengeStart", ET_Event, Param_Cell,Param_Cell); g_OnChallengeWin = CreateGlobalForward("OnChallengeWin", ET_Event, Param_Cell,Param_Cell); g_OnChallengeForceEnd = CreateGlobalForward("OnChallengeForceEnd", ET_Event, Param_Cell,Param_Cell); - + g_OnCoopConfirm = CreateGlobalForward("OnCoopConfirm", ET_Event, Param_Cell,Param_Cell,Param_Cell); - g_OnCoopStart = CreateGlobalForward("OnCoopStart", ET_Event, Param_Cell,Param_Cell); - g_OnCoopWin = CreateGlobalForward("OnCoopWin", ET_Event, Param_Cell,Param_Cell); - g_OnCoopForceEnd = CreateGlobalForward("OnCoopForceEnd", ET_Event, Param_Cell,Param_Cell); - + AutoExecConfig(true, "timer/timer-teams"); - + HookEvent("player_spawn", Event_Reset); HookEvent("player_connect", Event_Reset); HookEvent("player_disconnect", Event_Reset); @@ -111,10 +116,10 @@ public OnPluginStart() public OnMapStart() { GetCurrentMap(g_currentMap, sizeof(g_currentMap)); - + LoadPhysics(); LoadTimerSettings(); - + for (new i = 1; i <= MaxClients; i++) { g_clientTeammate[i] = 0; @@ -132,7 +137,7 @@ public OnLibraryAdded(const String:name[]) } public OnLibraryRemoved(const String:name[]) -{ +{ if (StrEqual(name, "timer-physics")) { g_timerPhysics = false; @@ -148,7 +153,7 @@ public CacheSounds() { GetConVarString(Sound_ChallengeStart, SND_CHALLENGE_START, sizeof(SND_CHALLENGE_START)); PrepareSound(SND_CHALLENGE_START); - + GetConVarString(Sound_TimerOwned, SND_TIMER_OWNED, sizeof(SND_TIMER_OWNED)); PrepareSound(SND_TIMER_OWNED); } @@ -196,21 +201,19 @@ public OnClientStartTouchZoneType(client, MapZoneType:type) { if(!client) return; - + new mate = Timer_GetClientTeammate(client); - + if(!mate) return; - + if(!g_bClientChallenge[client] && !g_bClientCoop[client]) return; - + if (type == ZtEnd) { - if(g_bClientChallenge[client]) + if(g_bClientChallenge[client]) EndChallenge(client, 0); - else if (g_bClientCoop[client] && Timer_IsPlayerTouchingZoneType(mate, ZtEnd)) - EndCoop(client, 0); } } @@ -218,15 +221,15 @@ public OnClientEndTouchZoneType(client, MapZoneType:type) { if(!client) return; - + new mate = Timer_GetClientTeammate(client); - + if(!mate) return; - + if(!g_bClientChallenge[client] && !g_bClientCoop[client]) return; - + if (type == ZtStart) { if(g_Settings[CoopOnly]) @@ -244,7 +247,7 @@ public Action:Command_Challenge(client, args) { if(!client) return Plugin_Handled; - + if(g_bClientCoop[client]) { CPrintToChat(client, "%s You are already challenging.", PLUGIN_PREFIX2); @@ -253,12 +256,12 @@ public Action:Command_Challenge(client, args) { CPrintToChat(client, "%s You are already in coop mode.", PLUGIN_PREFIX2); } - else + else { new Handle:menu = CreateMenu(Handle_PointSelectMenu); - + SetMenuTitle(menu, "Select bet"); - + decl String:buffer[32]; FormatEx(buffer, sizeof(buffer), "%d", g_Settings[ChallengeBet1]); AddMenuItem(menu, buffer, "Very Low"); @@ -270,13 +273,13 @@ public Action:Command_Challenge(client, args) AddMenuItem(menu, buffer, "Pro"); FormatEx(buffer, sizeof(buffer), "%d", g_Settings[ChallengeBet5]); AddMenuItem(menu, buffer, "Match"); - + DisplayMenu(menu, client, MENU_TIME_FOREVER); } - + return Plugin_Handled; } - + public Handle_PointSelectMenu(Handle:menu, MenuAction:action, client, itemNum) { if ( action == MenuAction_Select ) @@ -292,50 +295,50 @@ public Handle_PointSelectMenu(Handle:menu, MenuAction:action, client, itemNum) } Menu_SelectChallengeMate(client) -{ +{ new Handle:menu = CreateMenu(MenuHandlerChallenge); SetMenuTitle(menu, "Select your opponent"); - + new iCount = 0; - + for (new i = 1; i <= MaxClients; i++) { if(!Client_IsValid(i)) { continue; } - + if(IsFakeClient(i)) { continue; } - + if(client == i) { continue; } - + if(g_bClientCoop[i]) { continue; } - + if(g_bClientChallenge[i]) { continue; } - + if(GetGameTime() < g_fIgnoreTime[i]) { continue; } - + decl String:name2[32]; FormatEx(name2, sizeof(name2), "%N", i); decl String:zone2[32]; FormatEx(zone2,sizeof(zone2),"%d", i); AddMenuItem(menu, zone2, name2); - + iCount++; } @@ -344,7 +347,7 @@ Menu_SelectChallengeMate(client) CPrintToChat(client, "%s No Target found.", PLUGIN_PREFIX2); return; } - + SetMenuExitButton(menu, true); DisplayMenu(menu, client, 20); } @@ -356,18 +359,18 @@ public MenuHandlerChallenge(Handle:menu, MenuAction:action, creator, param2) decl String:info[100], String:info2[100]; new bool:found = GetMenuItem(menu, param2, info, sizeof(info), _, info2, sizeof(info2)); new client = StringToInt(info); - + if(IsFakeClient(client)) { StartChallenge(client, creator); - + Call_StartForward(g_OnChallengeConfirm); Call_PushCell(client); Call_PushCell(creator); Call_PushCell(g_iBet[creator]); Call_Finish(); } - + if(found) { if(IsClientInGame(client)) @@ -378,12 +381,12 @@ public MenuHandlerChallenge(Handle:menu, MenuAction:action, creator, param2) SetMenuTitle(menu2, "Confirm Challenge with %N on style: %s.", creator, g_Physics[Timer_GetStyle(creator)][StyleName]); } else SetMenuTitle(menu2, "Confirm Challenge with %N.", creator); - + decl String:name[32]; FormatEx(name, sizeof(name),"%d", creator); AddMenuItem(menu2, name, "Yes"); AddMenuItem(menu2, "no", "no"); - + SetMenuExitButton(menu, true); DisplayMenu(menu2, client, 20); } @@ -398,29 +401,29 @@ public MenuHandlerChallengeConfirm(Handle:menu, MenuAction:action, client, param decl String:info[100], String:info2[100]; new bool:found = GetMenuItem(menu, param2, info, sizeof(info), _, info2, sizeof(info2)); new target = StringToInt(info); - + if(!target || target <= 0) { CPrintToChat(client, "%s Invalid target. Something went wrong, sry.", PLUGIN_PREFIX2); return; } - + if(StrEqual(info, "no")) { g_fIgnoreTime[client] = GetGameTime()+g_Settings[ChallengeIgnoreCooldown]; if(g_Settings[ChallengeIgnoreCooldown] > 0) CPrintToChat(client, "%s You can't be challenged next %ds.", PLUGIN_PREFIX2, RoundToFloor(g_Settings[ChallengeIgnoreCooldown])); - - if(IsClientInGame(target)) - if(g_Settings[ChallengeIgnoreCooldown] > 0) + + if(IsClientInGame(target)) + if(g_Settings[ChallengeIgnoreCooldown] > 0) CPrintToChat(target, "%s %N rejected your challenge request. You have to wait %ds to ask for a new challenge", PLUGIN_PREFIX2, client, RoundToFloor(g_Settings[ChallengeIgnoreCooldown])); - else + else CPrintToChat(target, "%s %N rejected your challenge request.", PLUGIN_PREFIX2, client); } else if(found) { g_iBet[client] = g_iBet[target]; StartChallenge(client, target); - + Call_StartForward(g_OnChallengeConfirm); Call_PushCell(client); Call_PushCell(target); @@ -434,25 +437,25 @@ StartChallenge(client, target) { FakeClientCommand(client, "sm_start"); FakeClientCommand(target, "sm_start"); - + Timer_SetClientTeammate(client, target, 1); Timer_SetStyle(client, Timer_GetStyle(target)); - + SetEntityMoveType(client, MOVETYPE_NONE); SetEntityMoveType(target, MOVETYPE_NONE); - + Timer_SetClientHide(client, 1); Timer_SetClientHide(target, 1); - + g_iChallengeCountdown[client] = 5; g_iChallengeCountdown[target] = 5; - + g_fLastRun[client] = 0.0; g_fLastRun[client] = 0.0; - + Timer_SetTrack(client, TRACK_NORMAL); Timer_SetTrack(target, TRACK_NORMAL); - + g_bClientChallenge[client] = true; g_bClientChallenge[target] = true; @@ -464,11 +467,11 @@ public Action:ChallengeCountdown(Handle:timer, any:client) { if(!IsClientInGame(client)) return Plugin_Stop; - + PrintCenterText(client, "%d", g_iChallengeCountdown[client]); - + g_iChallengeCountdown[client]--; - + if(g_iChallengeCountdown[client] <= 0) { PrintCenterText(client, "GO GO GO !!!"); @@ -476,20 +479,20 @@ public Action:ChallengeCountdown(Handle:timer, any:client) EmitSoundToClient(client, SND_CHALLENGE_START); SetEntityMoveType(client, MOVETYPE_WALK); new mate = Timer_GetClientTeammate(client); - + Call_StartForward(g_OnChallengeStart); Call_PushCell(client); Call_PushCell(mate); Call_Finish(); - + Timer_Start(client); Timer_Start(mate); - + new Float:time = GetGameTime(); - + g_fStartTime[client] = time; g_fStartTime[mate] = time; - + return Plugin_Stop; } @@ -501,9 +504,9 @@ public Action:Command_Coop(client, args) new Handle:menu = CreateMenu(MenuHandlerCoop); SetMenuTitle(menu, "Teammate Select"); //new bool:isadmin = Client_IsAdmin(client); - + new iCount = 0; - + //show rest for (new i = 1; i <= MaxClients; i++) { @@ -523,25 +526,25 @@ public Action:Command_Coop(client, args) { continue; } - + decl String:name2[32]; FormatEx(name2, sizeof(name2), "%N", i); decl String:zone2[32]; FormatEx(zone2,sizeof(zone2),"%d", i); AddMenuItem(menu, zone2, name2); - + iCount++; } - + if(iCount == 0) { CPrintToChat(client, "%s No Target found.", PLUGIN_PREFIX2); return Plugin_Handled; } - + SetMenuExitButton(menu, true); DisplayMenu(menu, client, 20); - + return Plugin_Handled; } @@ -565,12 +568,12 @@ public MenuHandlerCoop(Handle:menu, MenuAction:action, client, param2) new Handle:menu2 = CreateMenu(MenuHandlerCoopConfirm); SetMenuTitle(menu2, "Confirm Coop-Modus with %N", client); //new bool:isadmin = Client_IsAdmin(client); - + decl String:xclient[32]; FormatEx(xclient, sizeof(xclient),"%d", client); AddMenuItem(menu2, xclient, "Yes"); AddMenuItem(menu2, "no", "no"); - + SetMenuExitButton(menu, true); DisplayMenu(menu2, target, 20); } @@ -588,10 +591,10 @@ public MenuHandlerCoopConfirm(Handle:menu, MenuAction:action, client, param2) new target = StringToInt(info); if(StrEqual(info, "no")) { - + } else if(found) - { + { if(!target || target <= 0) { } @@ -600,7 +603,7 @@ public MenuHandlerCoopConfirm(Handle:menu, MenuAction:action, client, param2) StartCoop(client, target); } } - + Call_StartForward(g_OnCoopConfirm); Call_PushCell(client); Call_PushCell(target); @@ -612,57 +615,33 @@ public MenuHandlerCoopConfirm(Handle:menu, MenuAction:action, client, param2) StartCoop(client, target) { Timer_SetClientTeammate(client, target, 1); + Timer_SetTrack(client, Timer_GetTrack(target)); - - SetEntityMoveType(client, MOVETYPE_NONE); - SetEntityMoveType(target, MOVETYPE_NONE); - - g_iCoopCountdown[client] = 5; - g_iCoopCountdown[target] = 5; - - Timer_SetTrack(client, TRACK_NORMAL); - Timer_SetTrack(target, TRACK_NORMAL); - - g_bClientCoop[client] = false; - g_bClientCoop[target] = false; - CreateTimer(1.0, CoopCountdown, client, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); - CreateTimer(1.0, CoopCountdown, target, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); + Timer_ClientTeleportLevel(client, LEVEL_START); + Timer_ClientTeleportLevel(target, LEVEL_START); + + g_bClientCoop[client] = true; + g_bClientCoop[target] = true; } -public Action:CoopCountdown(Handle:timer, any:client) +public Action:Command_UnCoop(client, args) { - if(!IsClientInGame(client)) - return Plugin_Stop; - - PrintCenterText(client, "%d", g_iCoopCountdown[client]); - - g_iCoopCountdown[client]--; - - SetEntityMoveType(client, MOVETYPE_NONE); + new mate = g_clientTeammate[client]; + + g_clientTeammate[client] = 0; + g_clientTeammate[mate] = 0; + + Timer_SetTrack(client, TRACK_NORMAL); + Timer_SetTrack(mate, TRACK_NORMAL); + Timer_ClientTeleportLevel(client, LEVEL_START); - - if(g_iCoopCountdown[client] <= 0) - { - PrintCenterText(client, "GO GO GO !!!"); - SetEntityMoveType(client, MOVETYPE_WALK); - new mate = Timer_GetClientTeammate(client); - - g_bClientCoop[client] = true; - g_bClientCoop[mate] = true; - - Call_StartForward(g_OnCoopStart); - Call_PushCell(client); - Call_PushCell(mate); - Call_Finish(); - - Timer_Start(client); - Timer_Start(mate); - - return Plugin_Stop; - } + Timer_ClientTeleportLevel(mate, LEVEL_START); - return Plugin_Continue; + g_bClientCoop[client] = false; + g_bClientCoop[mate] = false; + + return Plugin_Handled; } new Float:g_fLastFail[MAXPLAYERS+1]; @@ -672,7 +651,7 @@ public Action:EndChallenge(client, force) new mate = Timer_GetClientTeammate(client); new Float:fTime = GetGameTime(); new bool:fake_death = false; - + if(g_bClientChallenge[client] && g_bClientChallenge[mate]) { //Failed? @@ -681,17 +660,17 @@ public Action:EndChallenge(client, force) if(fTime - g_fLastFail[client] > 1.0) { g_fLastFail[client] = fTime; - + Call_StartForward(g_OnChallengeForceEnd); Call_PushCell(client); Call_PushCell(mate); Call_Finish(); - + if(fTime - g_fStartTime[mate] > g_Settings[ChallengeAbortTime]) { CPrintToChat(client, "%s You have surrendered this challenge.", PLUGIN_PREFIX2); CPrintToChat(mate, "%s %N has surrendered this challenge.", PLUGIN_PREFIX2, client); - + EndChallenge(mate, 2); //Mate Wins } else @@ -702,78 +681,78 @@ public Action:EndChallenge(client, force) } else { - + } } //We have a winner else if(force == 0) { - decl String:pname[32], String:pname2[32]; - + decl String:pname[32], String:pname2[32]; + FormatEx(pname, sizeof(pname), "%N", client); FormatEx(pname2, sizeof(pname2), "%N", mate); - + //Play sounds EmitSoundToClient(client, SND_TIMER_OWNED); EmitSoundToClient(mate, SND_TIMER_OWNED); - + new bool:enabled = false; new jumps = 0; new Float:time; new fpsmax; - + if (g_Settings[ChallengeSaveRecords] && Timer_GetClientTimer(client, enabled, time, jumps, fpsmax)) { new style = 0; if (g_timerPhysics) style = Timer_GetStyle(client); - + Timer_FinishRound(client, g_currentMap, time, jumps, style, fpsmax, 0); } - + //Forward Call_StartForward(g_OnChallengeWin); Call_PushCell(client); Call_PushCell(mate); Call_Finish(); - + fake_death = true; } else if(force == 2) { - decl String:pname[32], String:pname2[32]; - + decl String:pname[32], String:pname2[32]; + FormatEx(pname, sizeof(pname), "%N", client); FormatEx(pname2, sizeof(pname2), "%N", mate); - + //Play sounds EmitSoundToClient(client, SND_TIMER_OWNED); EmitSoundToClient(mate, SND_TIMER_OWNED); - + //Forward Call_StartForward(g_OnChallengeWin); Call_PushCell(client); Call_PushCell(mate); Call_Finish(); - + fake_death = true; } } - + //end challenge g_bClientChallenge[client] = false; g_bClientChallenge[mate] = false; - + //dissolve team Timer_SetClientTeammate(client, 0, 0); Timer_SetClientTeammate(mate, 0, 0); - + //Reset hide Timer_SetClientHide(client, 0); Timer_SetClientHide(mate, 0); - + g_fLastRun[client] = fTime; - + if(fake_death) { //Fake death event @@ -786,63 +765,9 @@ public Action:EndChallenge(client, force) FireEvent(event, false); } } - - Timer_Reset(client); - Timer_Reset(mate); -} -public Action:EndCoop(client, force) -{ - new mate = Timer_GetClientTeammate(client); - - if(g_bClientCoop[client] && g_bClientCoop[mate]) - { - decl String:pname[32], String:pname2[32]; - - FormatEx(pname, sizeof(pname), "%N", client); - FormatEx(pname2, sizeof(pname2), "%N", mate); - - if (force == 1) - { - PrintToChatAll(PLUGIN_PREFIX, "Coop Fail", pname, pname2); - - Call_StartForward(g_OnCoopForceEnd); - Call_PushCell(client); - Call_PushCell(mate); - Call_Finish(); - } - else if (force == 0) - { - PrintToChatAll(PLUGIN_PREFIX, "Coop Win", pname, pname2); - - Call_StartForward(g_OnCoopWin); - Call_PushCell(client); - Call_PushCell(mate); - Call_Finish(); - - new bool:enabled; //tier running - new jumps; //current jump count - new fpsmax; //fps settings - new bool:track = false; //track timer running - new Float:time; //current time - - new style = Timer_GetStyle(client); - - Timer_GetClientTimer(client, enabled, time, jumps, fpsmax); - - Timer_FinishRound(client, g_currentMap, time, jumps, style, fpsmax, track); - Timer_FinishRound(mate, g_currentMap, time, jumps, style, fpsmax, track); - } - } - - g_bClientCoop[client] = false; - g_bClientCoop[mate] = false; - Timer_Reset(client); Timer_Reset(mate); - - Timer_SetClientTeammate(client, 0, 0); - Timer_SetClientTeammate(mate, 0, 0); } public OnTimerStopped(client) @@ -868,17 +793,13 @@ public OnTimerReseted(client) ForceEnd(client) { new mate = Timer_GetClientTeammate(client); - + if(mate != 0) { - if(g_bClientChallenge[client]) + if(g_bClientChallenge[client]) { EndChallenge(client,1); } - else if (g_bClientCoop[client]) - { - EndCoop(client,1); - } } } @@ -892,32 +813,32 @@ public Native_SetClientTeammate(Handle:plugin, numParams) new client = GetNativeCell(1); new mate = GetNativeCell(2); new bool:teleport = bool:GetNativeCell(2); - + if(0 < client) { //Make sure there are no issues with other mates new oldcmate = g_clientTeammate[client]; new oldmmate = g_clientTeammate[mate]; - + g_clientTeammate[oldcmate] = 0; g_clientTeammate[oldmmate] = 0; g_clientTeammate[client] = 0; g_clientTeammate[mate] = 0; - + if(0 < mate) { g_clientTeammate[client] = mate; g_clientTeammate[mate] = client; } - + if(teleport) { Timer_ClientTeleportLevel(client, LEVEL_START); Timer_ClientTeleportLevel(mate, LEVEL_START); - + if(oldcmate && oldcmate != mate) Timer_ClientTeleportLevel(oldcmate, LEVEL_START); - + if(oldmmate && oldmmate != client) Timer_ClientTeleportLevel(oldmmate, LEVEL_START); } @@ -932,4 +853,4 @@ public Native_GetChallengeStatus(Handle:plugin, numParams) public Native_GetCoopStatus(Handle:plugin, numParams) { return g_bClientCoop[GetNativeCell(1)]; -} \ No newline at end of file +} diff --git a/gameserver/addons/sourcemod/scripting/timer-teleme.sp b/gameserver/addons/sourcemod/scripting/timer-teleme.sp index d3cb428..dc55857 100644 --- a/gameserver/addons/sourcemod/scripting/timer-teleme.sp +++ b/gameserver/addons/sourcemod/scripting/timer-teleme.sp @@ -23,9 +23,9 @@ public OnPluginStart() { LoadPhysics(); LoadTimerSettings(); - + g_timerMapzones = LibraryExists("timer-mapzones"); - + RegConsoleCmd("sm_teleme", Command_TeleMe); RegConsoleCmd("sm_tpto", Command_TeleMe); RegConsoleCmd("sm_teleport", Command_TeleMe); @@ -42,7 +42,7 @@ public OnLibraryAdded(const String:name[]) } public OnLibraryRemoved(const String:name[]) -{ +{ if(StrEqual(name, "timer-mapzones")) { g_timerMapzones = false; @@ -57,20 +57,23 @@ public OnMapStart() public Action:Command_TeleMe(client, args) { - if(IsPlayerAlive(client) && g_Settings[PlayerTeleportEnable]) + if(!g_Settings[PlayerTeleportEnable]) + CPrintToChat(client, "%s This command has been disabled.", PLUGIN_PREFIX2); + + if(IsPlayerAlive(client)) { - if(!g_Settings[PlayerTeleportEnable]) + if(!g_Settings[PlayerTeleportEnable]) { ReplyToCommand(client, "Teleport disabled by server."); return Plugin_Handled; } - + new Handle:menu = CreateMenu(MenuHandlerTeleMe); SetMenuTitle(menu, "Teleport to selected player"); //new bool:isadmin = Client_IsAdmin(client); - + new iCount = 0; - + //show rest for (new i = 1; i <= MaxClients; i++) { @@ -78,19 +81,19 @@ public Action:Command_TeleMe(client, args) { continue; } - + decl String:name2[32]; - if(g_timerMapzones) + if(g_timerMapzones) FormatEx(name2, sizeof(name2), "%N Stage: %d", i, Timer_GetClientLevel(i)); - else + else FormatEx(name2, sizeof(name2), "%N", i); - + decl String:zone2[32]; FormatEx(zone2,sizeof(zone2),"%d", i); AddMenuItem(menu, zone2, name2); iCount++; } - + if(iCount > 0) { SetMenuExitButton(menu, true); @@ -102,7 +105,7 @@ public Action:Command_TeleMe(client, args) { CPrintToChat(client, "%s You have to be alive", PLUGIN_PREFIX2); } - + return Plugin_Handled; } @@ -122,7 +125,7 @@ public MenuHandlerTeleMe(Handle:menu, MenuAction:action, client, param2) new Float:origin[3], Float:angles[3]; GetClientAbsOrigin(target, origin); GetClientAbsAngles(target, angles); - + //Do not reset his pretty timer if it can be paused if (g_Settings[PauseEnable]) { @@ -131,8 +134,8 @@ public MenuHandlerTeleMe(Handle:menu, MenuAction:action, client, param2) else { Timer_Reset(client); - } - + } + TeleportEntity(client, origin, angles, NULL_VECTOR); } } diff --git a/gameserver/addons/sourcemod/scripting/timer-worldrecord.sp b/gameserver/addons/sourcemod/scripting/timer-worldrecord.sp index 4f012f8..92a76af 100644 --- a/gameserver/addons/sourcemod/scripting/timer-worldrecord.sp +++ b/gameserver/addons/sourcemod/scripting/timer-worldrecord.sp @@ -5,10 +5,15 @@ #include #include -#include #include #include +#undef REQUIRE_PLUGIN +#include +#include +#include +#include + //Max. number of records per style to cache /** @@ -53,14 +58,14 @@ enum RecordStats /** * New World Record Cache */ - + new Handle:g_hCache[MAX_STYLES][MAX_TRACKS]; new nCacheTemplate[RecordCache]; /** * Old World Record Cache */ - + //new g_cache[MAX_STYLES][3][MAX_CACHE][RecordCache]; /** @@ -89,6 +94,7 @@ new g_iAdminSelectedStyle[MAXPLAYERS+1]; new g_iAdminSelectedTrack[MAXPLAYERS+1]; new bool:g_timerPhysics = false; +new bool:g_timerStrafes = false; new Handle:g_OnRecordCacheLoaded; @@ -104,7 +110,7 @@ public Plugin:myinfo = public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max) { RegPluginLibrary("timer-worldrecord"); - + CreateNative("Timer_ForceReloadCache", Native_ForceReloadCache); CreateNative("Timer_GetStyleRecordWRStats", Native_GetStyleRecordWRStats); CreateNative("Timer_GetStyleRank", Native_GetStyleRank); @@ -132,43 +138,44 @@ public OnPluginStart() { LoadPhysics(); LoadTimerSettings(); - + ConnectSQL(true); - + g_timerPhysics = LibraryExists("timer-physics"); - + g_timerStrafes = LibraryExists("timer-strafes"); + LoadTranslations("timer.phrases"); - + RegConsoleCmd("sm_top", Command_WorldRecord); RegConsoleCmd("sm_wr", Command_WorldRecord); - if(g_Settings[BonusWrEnable]) + if(g_Settings[BonusWrEnable]) { RegConsoleCmd("sm_btop", Command_BonusWorldRecord); RegConsoleCmd("sm_topb", Command_BonusWorldRecord); RegConsoleCmd("sm_bwr", Command_BonusWorldRecord); RegConsoleCmd("sm_wrb", Command_BonusWorldRecord); - + RegConsoleCmd("sm_b2top", Command_Bonus2WorldRecord); RegConsoleCmd("sm_topb2", Command_Bonus2WorldRecord); RegConsoleCmd("sm_b2wr", Command_Bonus2WorldRecord); RegConsoleCmd("sm_wrb2", Command_Bonus2WorldRecord); - + RegConsoleCmd("sm_b3top", Command_Bonus3WorldRecord); RegConsoleCmd("sm_topb3", Command_Bonus3WorldRecord); RegConsoleCmd("sm_b3wr", Command_Bonus3WorldRecord); RegConsoleCmd("sm_wrb3", Command_Bonus3WorldRecord); - + RegConsoleCmd("sm_b4top", Command_Bonus4WorldRecord); RegConsoleCmd("sm_topb4", Command_Bonus4WorldRecord); RegConsoleCmd("sm_b4wr", Command_Bonus4WorldRecord); RegConsoleCmd("sm_wrb4", Command_Bonus4WorldRecord); - + RegConsoleCmd("sm_b5top", Command_Bonus5WorldRecord); RegConsoleCmd("sm_topb5", Command_Bonus5WorldRecord); RegConsoleCmd("sm_b5wr", Command_Bonus5WorldRecord); RegConsoleCmd("sm_wrb5", Command_Bonus5WorldRecord); } - + RegConsoleCmd("sm_record", Command_PersonalRecord); RegConsoleCmd("sm_rank", Command_PersonalRecord); //RegConsoleCmd("sm_delete", Command_Delete); @@ -177,18 +184,18 @@ public OnPluginStart() RegAdminCmd("sm_deleterecord_map", Command_DeletePlayerRecord_Map, ADMFLAG_ROOT, "sm_deleterecord_map STEAM_ID"); RegAdminCmd("sm_deleterecord", Command_DeletePlayerRecord_ID, ADMFLAG_RCON, "sm_deleterecord RECORDID"); RegAdminCmd("sm_deletemaprecords", Command_DeleteMapRecords_All, ADMFLAG_RCON, "sm_deleterecord MAPNAME"); - + AutoExecConfig(true, "timer/timer-worldrecord"); - + new Handle:topmenu; if (LibraryExists("adminmenu") && ((topmenu = GetAdminTopMenu()) != INVALID_HANDLE)) { OnAdminMenuReady(topmenu); } - + g_OnRecordCacheLoaded = CreateGlobalForward("OnRecordCacheLoaded", ET_Event, Param_Cell, Param_Cell); - for(new i = 0; i < MAX_STYLES-1; i++) + for(new i = 0; i < MAX_STYLES-1; i++) { if(!StrEqual(g_Physics[i][StyleQuickWrCommand], "")) { @@ -221,7 +228,7 @@ public OnPluginStart() AddCommandListener(Hook_WrCommands, g_Physics[i][StyleQuickBonus5WrCommand]); } } - + CacheReset(); } @@ -230,15 +237,23 @@ public OnLibraryAdded(const String:name[]) if (StrEqual(name, "timer-physics")) { g_timerPhysics = true; - } + } + else if (StrEqual(name, "timer-strafes")) + { + g_timerStrafes = true; + } } public OnLibraryRemoved(const String:name[]) -{ +{ if (StrEqual(name, "timer-physics")) { g_timerPhysics = false; } + else if (StrEqual(name, "timer-strafes")) + { + g_timerStrafes = false; + } else if (StrEqual(name, "adminmenu")) { hTopMenu = INVALID_HANDLE; @@ -248,10 +263,10 @@ public OnLibraryRemoved(const String:name[]) public OnMapStart() { GetCurrentMap(g_currentMap, sizeof(g_currentMap)); - + LoadPhysics(); LoadTimerSettings(); - + CacheReset(); RefreshCache(); } @@ -265,14 +280,14 @@ UpdateRanks() { if (g_hSQL == INVALID_HANDLE) return; - - for(new track = 0; track < MAX_TRACKS; track++) + + for(new track = 0; track < MAX_TRACKS; track++) { - for(new style = 0; style < g_StyleCount; style++) + for(new style = 0; style < g_StyleCount; style++) { if(!g_Physics[style][StyleEnable]) continue; - + if(g_Physics[style][StyleCategory] == MCategory_Ranked) { decl String:query[2048]; @@ -300,57 +315,57 @@ public Action:Command_WorldRecord(client, args) CreateRankedWRMenu(client); else CreateWRMenu(client, g_StyleDefault, TRACK_NORMAL); - + return Plugin_Handled; } public Action:Command_BonusWorldRecord(client, args) { if (g_timerPhysics && g_Settings[MultimodeEnable]) - CreateRankedBWRMenu(client, 1); + CreateRankedBWRMenu(client, TRACK_BONUS); else CreateWRMenu(client, g_StyleDefault, TRACK_BONUS); - + return Plugin_Handled; } public Action:Command_Bonus2WorldRecord(client, args) { if (g_timerPhysics && g_Settings[MultimodeEnable]) - CreateRankedBWRMenu(client, 2); + CreateRankedBWRMenu(client, TRACK_BONUS2); else - CreateWRMenu(client, g_StyleDefault, TRACK_BONUS); - + CreateWRMenu(client, g_StyleDefault, TRACK_BONUS2); + return Plugin_Handled; } public Action:Command_Bonus3WorldRecord(client, args) { if (g_timerPhysics && g_Settings[MultimodeEnable]) - CreateRankedBWRMenu(client, 3); + CreateRankedBWRMenu(client, TRACK_BONUS3); else - CreateWRMenu(client, g_StyleDefault, TRACK_BONUS); - + CreateWRMenu(client, g_StyleDefault, TRACK_BONUS3); + return Plugin_Handled; } public Action:Command_Bonus4WorldRecord(client, args) { if (g_timerPhysics && g_Settings[MultimodeEnable]) - CreateRankedBWRMenu(client, 4); + CreateRankedBWRMenu(client, TRACK_BONUS4); else - CreateWRMenu(client, g_StyleDefault, TRACK_BONUS); - + CreateWRMenu(client, g_StyleDefault, TRACK_BONUS4); + return Plugin_Handled; } public Action:Command_Bonus5WorldRecord(client, args) { if (g_timerPhysics && g_Settings[MultimodeEnable]) - CreateRankedBWRMenu(client, 5); + CreateRankedBWRMenu(client, TRACK_BONUS5); else - CreateWRMenu(client, g_StyleDefault, TRACK_BONUS); - + CreateWRMenu(client, g_StyleDefault, TRACK_BONUS5); + return Plugin_Handled; } @@ -360,14 +375,14 @@ public Action:Hook_WrCommands(client, const String:sCommand[], argc) { return Plugin_Continue; } - for(new i = 0; i < MAX_STYLES-1; i++) + for(new i = 0; i < MAX_STYLES-1; i++) { if(!g_Physics[i][StyleEnable]) continue; - + if(g_Physics[i][StyleCategory] != MCategory_Ranked) continue; - + if(!StrEqual(g_Physics[i][StyleQuickWrCommand], "") && StrEqual(g_Physics[i][StyleQuickWrCommand], sCommand)) { CreateWRMenu(client, i, TRACK_NORMAL); @@ -399,7 +414,7 @@ public Action:Hook_WrCommands(client, const String:sCommand[], argc) return Plugin_Handled; } } - + return Plugin_Continue; } @@ -418,7 +433,7 @@ public Action:Command_PersonalRecord(client, args) { new argsCount = GetCmdArgs(); new target = -1; - + if (argsCount == 0) { @@ -428,7 +443,7 @@ public Action:Command_PersonalRecord(client, args) { decl String:name[64]; GetCmdArg(1, name, sizeof(name)); - + new targets[2]; decl String:targetName[32]; new bool:ml = false; @@ -444,26 +459,26 @@ public Action:Command_PersonalRecord(client, args) else { new style = Timer_GetStyle(client); - + new track = Timer_GetTrack(client); - + decl String:auth[32]; GetClientAuthString(target, auth, sizeof(auth)); - + for (new i = 0; i < GetArraySize(g_hCache[style][track]); i++) { new nCache[RecordCache]; GetArrayArray(g_hCache[style][track], i, nCache[0]); - + if (StrEqual(nCache[Auth], auth)) { g_wrStyleMode[client] = style; - CreatePlayerInfoMenu(client, nCache[Id], track); + CreateRecordInfoMenu(client, i, track); break; } - } + } } - + return Plugin_Handled; } @@ -488,18 +503,18 @@ public Action:Command_DeletePlayerRecord_All(client, args) FormatEx(query, sizeof(query), "DELETE FROM round WHERE auth = '%s'", auth); SQL_TQuery(g_hSQL, DeleteRecordsCallback, query, _, DBPrio_Normal); - + return Plugin_Handled; } public Action:Command_DeletePlayerRecord_Map(client, args) -{ +{ if (args < 1) { ReplyToCommand(client, "Usage: sm_deleterecord_map "); return Plugin_Handled; } - + new String:auth[32]; GetCmdArgString(auth, sizeof(auth)); @@ -507,18 +522,18 @@ public Action:Command_DeletePlayerRecord_Map(client, args) FormatEx(query, sizeof(query), "DELETE FROM round WHERE auth = '%s' AND map = '%s'", auth, g_currentMap); SQL_TQuery(g_hSQL, DeleteRecordsCallback, query, _, DBPrio_Normal); - + return Plugin_Handled; } public Action:Command_DeletePlayerRecord_ID(client, args) -{ +{ if (args < 1) { ReplyToCommand(client, "Usage: sm_deleterecord "); return Plugin_Handled; } - + new String:id[32]; GetCmdArgString(id, sizeof(id)); @@ -526,18 +541,18 @@ public Action:Command_DeletePlayerRecord_ID(client, args) FormatEx(query, sizeof(query), "DELETE FROM round WHERE id = '%s'", id); SQL_TQuery(g_hSQL, DeleteRecordsCallback, query, _, DBPrio_Normal); - + return Plugin_Handled; } public Action:Command_DeleteMapRecords_All(client, args) -{ +{ if (args < 1) { ReplyToCommand(client, "Usage: sm_deleterecord "); return Plugin_Handled; } - + new String:mapname[32]; GetCmdArgString(mapname, sizeof(mapname)); @@ -545,7 +560,7 @@ public Action:Command_DeleteMapRecords_All(client, args) FormatEx(query, sizeof(query), "DELETE FROM round WHERE map = '%s'", mapname); SQL_TQuery(g_hSQL, DeleteRecordsCallback, query, _, DBPrio_Normal); - + return Plugin_Handled; } @@ -566,26 +581,26 @@ public OnAdminMenuReady(Handle:topmenu) if (topmenu == hTopMenu) { return; } - + // Save the Handle hTopMenu = topmenu; - + if ((oMapZoneMenu = FindTopMenuCategory(topmenu, "Timer Records")) == INVALID_TOPMENUOBJECT) { oMapZoneMenu = AddToTopMenu(hTopMenu,"Timer Records",TopMenuObject_Category,AdminMenu_CategoryHandler,INVALID_TOPMENUOBJECT); } - + AddToTopMenu(hTopMenu, "timer_delete",TopMenuObject_Item,AdminMenu_DeleteRecord, oMapZoneMenu,"timer_delete",ADMFLAG_RCON); - + AddToTopMenu(hTopMenu, "timer_deletemaprecords",TopMenuObject_Item,AdminMenu_DeleteMapRecords, oMapZoneMenu,"timer_deletemaprecords",ADMFLAG_RCON); - - AddToTopMenu(hTopMenu, "sm_reloadcache", TopMenuObject_Item,AdminMenu_ReloadCache, + + AddToTopMenu(hTopMenu, "sm_reloadcache", TopMenuObject_Item,AdminMenu_ReloadCache, oMapZoneMenu, "sm_reloadcache",ADMFLAG_CHANGEMAP); } -public AdminMenu_CategoryHandler(Handle:topmenu, +public AdminMenu_CategoryHandler(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, @@ -599,7 +614,7 @@ public AdminMenu_CategoryHandler(Handle:topmenu, } } -public AdminMenu_DeleteMapRecords(Handle:topmenu, +public AdminMenu_DeleteMapRecords(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, @@ -611,40 +626,40 @@ public AdminMenu_DeleteMapRecords(Handle:topmenu, } else if (action == TopMenuAction_SelectOption) { decl String:map[32]; GetCurrentMap(map, sizeof(map)); - + if(param == 0) DeleteMapRecords(map); else DeleteMapRecordsMenu(param); } } -public AdminMenu_ReloadCache(Handle:topmenu, +public AdminMenu_ReloadCache(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, client, String:buffer[], maxlength) { - if (action == TopMenuAction_DisplayOption) + if (action == TopMenuAction_DisplayOption) { FormatEx(buffer, maxlength, "Refresh Cache"); - } else if (action == TopMenuAction_SelectOption) + } else if (action == TopMenuAction_SelectOption) { CPrintToChatAll(PLUGIN_PREFIX, "Word Record Cache Loaded"); RefreshCache(); } } -public AdminMenu_DeleteRecord(Handle:topmenu, +public AdminMenu_DeleteRecord(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, client, String:buffer[], maxlength) { - if (action == TopMenuAction_DisplayOption) + if (action == TopMenuAction_DisplayOption) { FormatEx(buffer, maxlength, "Delete Single Record"); - } else if (action == TopMenuAction_SelectOption) + } else if (action == TopMenuAction_SelectOption) { if(g_Settings[MultimodeEnable]) CreateAdminModeSelection(client); else CreateAdminTrackSelection(client); @@ -656,21 +671,21 @@ DeleteMapRecordsMenu(client) if (0 < client < MaxClients) { new Handle:menu = CreateMenu(Handle_DeleteMapRecordsMenu); - + SetMenuTitle(menu, "Are you sure!"); - - AddMenuItem(menu, "no", "Oh no"); + AddMenuItem(menu, "no", "Oh no"); AddMenuItem(menu, "no", "Oh no"); - AddMenuItem(menu, "yes", "!!! YES DELETE ALL RECORDS !!!"); AddMenuItem(menu, "no", "Oh no"); + AddMenuItem(menu, "yes", "!!! YES DELETE ALL RECORDS !!!"); AddMenuItem(menu, "no", "Oh no"); AddMenuItem(menu, "no", "Oh no"); - + AddMenuItem(menu, "no", "Oh no"); + DisplayMenu(menu, client, MENU_TIME_FOREVER); } } - + public Handle_DeleteMapRecordsMenu(Handle:menu, MenuAction:action, client, itemNum) { if ( action == MenuAction_Select ) @@ -695,38 +710,38 @@ CreateAdminModeSelection(client) SetMenuTitle(menu, "Select Style"); SetMenuExitButton(menu, true); - + new items = 0; - - for(new i = 0; i < MAX_STYLES-1; i++) + + for(new i = 0; i < MAX_STYLES-1; i++) { if(!g_Physics[i][StyleEnable]) continue; - + decl String:text[92]; FormatEx(text, sizeof(text), "%s", g_Physics[i][StyleName]); - + decl String:text2[32]; FormatEx(text2, sizeof(text2), "%d", i); - + AddMenuItem(menu, text2, text); items++; } - + if(items > 0) DisplayMenu(menu, client, MENU_TIME_FOREVER); else CloseHandle(menu); } public MenuHandler_AdminModeSelection(Handle:menu, MenuAction:action, client, itemNum) { - if (action == MenuAction_End) + if (action == MenuAction_End) { RefreshCache(); CloseHandle(menu); } - else if (action == MenuAction_Select) + else if (action == MenuAction_Select) { - decl String:info[32]; + decl String:info[32]; GetMenuItem(menu, itemNum, info, sizeof(info)); g_iAdminSelectedStyle[client] = StringToInt(info); CreateAdminTrackSelection(client); @@ -739,32 +754,32 @@ CreateAdminTrackSelection(client) SetMenuTitle(menu, "Select Style"); SetMenuExitButton(menu, true); - + AddMenuItem(menu, "0", "Normal"); - if(Timer_GetMapzoneCount(ZtBonusStart) > 0) + if(Timer_GetMapzoneCount(ZtBonusStart) > 0) AddMenuItem(menu, "1", "Bonus"); - if(Timer_GetMapzoneCount(ZtBonus2Start) > 0) + if(Timer_GetMapzoneCount(ZtBonus2Start) > 0) AddMenuItem(menu, "2", "Bonus 2"); - if(Timer_GetMapzoneCount(ZtBonus3Start) > 0) + if(Timer_GetMapzoneCount(ZtBonus3Start) > 0) AddMenuItem(menu, "3", "Bonus 3"); - if(Timer_GetMapzoneCount(ZtBonus4Start) > 0) + if(Timer_GetMapzoneCount(ZtBonus4Start) > 0) AddMenuItem(menu, "4", "Bonus 4"); - if(Timer_GetMapzoneCount(ZtBonus5Start) > 0) + if(Timer_GetMapzoneCount(ZtBonus5Start) > 0) AddMenuItem(menu, "5", "Bonus 5"); - + DisplayMenu(menu, client, MENU_TIME_FOREVER); } public MenuHandler_AdminTrackSelection(Handle:menu, MenuAction:action, client, itemNum) { - if (action == MenuAction_End) + if (action == MenuAction_End) { RefreshCache(); CloseHandle(menu); } - else if (action == MenuAction_Select) + else if (action == MenuAction_Select) { - decl String:info[32]; + decl String:info[32]; GetMenuItem(menu, itemNum, info, sizeof(info)); g_iAdminSelectedTrack[client] = StringToInt(info); CreateAdminRecordSelection(client, g_iAdminSelectedStyle[client], g_iAdminSelectedTrack[client]); @@ -777,21 +792,21 @@ CreateAdminRecordSelection(client, style, track) SetMenuTitle(menu, "Select Record"); SetMenuExitButton(menu, true); - - new items = 0; - - + + new items = 0; + + for (new i = 0; i < GetArraySize(g_hCache[style][track]); i++) { new nCache[RecordCache]; GetArrayArray(g_hCache[style][track], i, nCache[0]); - + if (nCache[Ignored]) continue; - + decl String:text[92]; FormatEx(text, sizeof(text), "%s - %s", nCache[TimeString], nCache[Name]); - + if (g_Settings[JumpsEnable]) Format(text, sizeof(text), "%s (%d %T)", text, nCache[Jumps], "Jumps", client); @@ -812,20 +827,20 @@ CreateAdminRecordSelection(client, style, track) public MenuHandler_SelectPlayer(Handle:menu, MenuAction:action, client, itemNum) { - if (action == MenuAction_End) + if (action == MenuAction_End) { CloseHandle(menu); } - else if (action == MenuAction_Select) + else if (action == MenuAction_Select) { - decl String:info[32]; + decl String:info[32]; GetMenuItem(menu, itemNum, info, sizeof(info)); - + decl String:query[512]; FormatEx(query, sizeof(query), "DELETE FROM `round` WHERE id = '%s'", info); SQL_TQuery(g_hSQL, DeletePlayersRecordCallback, query, client, DBPrio_Normal); - + RefreshCache(); } } @@ -837,15 +852,15 @@ public DeletePlayersRecordCallback(Handle:owner, Handle:hndl, const String:error Timer_LogError("SQL Error on DeletePlayerRecord: %s", error); return; } - + CreateAdminModeSelection(client); } -DeleteMapRecords(const String:map[]) +DeleteMapRecords(const String:map[]) { decl String:query[128]; - FormatEx(query, sizeof(query), "DELETE FROM `round` WHERE map = '%s'", map); + FormatEx(query, sizeof(query), "DELETE FROM `round` WHERE map = '%s'", map); SQL_TQuery(g_hSQL, DeleteRecordsCallback, query, _, DBPrio_Normal); } @@ -857,37 +872,37 @@ RefreshCache() ConnectSQL(true); } else - { + { for (new style = 0; style < MAX_STYLES-1; style++) { if(!g_Physics[style][StyleEnable]) continue; if(g_Physics[style][StyleCategory] != MCategory_Ranked) continue; - + g_cacheLoaded[style][0] = false; g_cacheLoaded[style][1] = false; g_cacheLoaded[style][2] = false; - + decl String:query[512]; - FormatEx(query, sizeof(query), "SELECT id, auth, time, jumps, style, name, date, finishcount, stage, rank, jumpacc, finishspeed, maxspeed, avgspeed, strafes, strafeacc, replaypath, custom1, custom2, custom3 FROM round WHERE map = '%s' AND style = %d AND track = %d ORDER BY time ASC;", g_currentMap, style, TRACK_NORMAL); + FormatEx(query, sizeof(query), "SELECT id, auth, time, jumps, style, name, date, finishcount, stage, rank, jumpacc, finishspeed, maxspeed, avgspeed, strafes, strafeacc, replaypath, custom1, custom2, custom3 FROM round WHERE map = '%s' AND style = %d AND track = %d ORDER BY time ASC;", g_currentMap, style, TRACK_NORMAL); SQL_TQuery(g_hSQL, RefreshCacheCallback, query, style, DBPrio_Low); - + if(g_Settings[BonusWrEnable]) { - FormatEx(query, sizeof(query), "SELECT id, auth, time, jumps, style, name, date, finishcount, stage, rank, jumpacc, finishspeed, maxspeed, avgspeed, strafes, strafeacc, replaypath, custom1, custom2, custom3 FROM round WHERE map = '%s' AND style = %d AND track = %d ORDER BY time ASC;", g_currentMap, style, TRACK_BONUS); + FormatEx(query, sizeof(query), "SELECT id, auth, time, jumps, style, name, date, finishcount, stage, rank, jumpacc, finishspeed, maxspeed, avgspeed, strafes, strafeacc, replaypath, custom1, custom2, custom3 FROM round WHERE map = '%s' AND style = %d AND track = %d ORDER BY time ASC;", g_currentMap, style, TRACK_BONUS); SQL_TQuery(g_hSQL, RefreshBonusCacheCallback, query, style, DBPrio_Low); - - FormatEx(query, sizeof(query), "SELECT id, auth, time, jumps, style, name, date, finishcount, stage, rank, jumpacc, finishspeed, maxspeed, avgspeed, strafes, strafeacc, replaypath, custom1, custom2, custom3 FROM round WHERE map = '%s' AND style = %d AND track = %d ORDER BY time ASC;", g_currentMap, style, TRACK_BONUS2); + + FormatEx(query, sizeof(query), "SELECT id, auth, time, jumps, style, name, date, finishcount, stage, rank, jumpacc, finishspeed, maxspeed, avgspeed, strafes, strafeacc, replaypath, custom1, custom2, custom3 FROM round WHERE map = '%s' AND style = %d AND track = %d ORDER BY time ASC;", g_currentMap, style, TRACK_BONUS2); SQL_TQuery(g_hSQL, RefreshBonus2CacheCallback, query, style, DBPrio_Low); - - FormatEx(query, sizeof(query), "SELECT id, auth, time, jumps, style, name, date, finishcount, stage, rank, jumpacc, finishspeed, maxspeed, avgspeed, strafes, strafeacc, replaypath, custom1, custom2, custom3 FROM round WHERE map = '%s' AND style = %d AND track = %d ORDER BY time ASC;", g_currentMap, style, TRACK_BONUS3); + + FormatEx(query, sizeof(query), "SELECT id, auth, time, jumps, style, name, date, finishcount, stage, rank, jumpacc, finishspeed, maxspeed, avgspeed, strafes, strafeacc, replaypath, custom1, custom2, custom3 FROM round WHERE map = '%s' AND style = %d AND track = %d ORDER BY time ASC;", g_currentMap, style, TRACK_BONUS3); SQL_TQuery(g_hSQL, RefreshBonus3CacheCallback, query, style, DBPrio_Low); - - FormatEx(query, sizeof(query), "SELECT id, auth, time, jumps, style, name, date, finishcount, stage, rank, jumpacc, finishspeed, maxspeed, avgspeed, strafes, strafeacc, replaypath, custom1, custom2, custom3 FROM round WHERE map = '%s' AND style = %d AND track = %d ORDER BY time ASC;", g_currentMap, style, TRACK_BONUS4); + + FormatEx(query, sizeof(query), "SELECT id, auth, time, jumps, style, name, date, finishcount, stage, rank, jumpacc, finishspeed, maxspeed, avgspeed, strafes, strafeacc, replaypath, custom1, custom2, custom3 FROM round WHERE map = '%s' AND style = %d AND track = %d ORDER BY time ASC;", g_currentMap, style, TRACK_BONUS4); SQL_TQuery(g_hSQL, RefreshBonus4CacheCallback, query, style, DBPrio_Low); - - FormatEx(query, sizeof(query), "SELECT id, auth, time, jumps, style, name, date, finishcount, stage, rank, jumpacc, finishspeed, maxspeed, avgspeed, strafes, strafeacc, replaypath, custom1, custom2, custom3 FROM round WHERE map = '%s' AND style = %d AND track = %d ORDER BY time ASC;", g_currentMap, style, TRACK_BONUS5); + + FormatEx(query, sizeof(query), "SELECT id, auth, time, jumps, style, name, date, finishcount, stage, rank, jumpacc, finishspeed, maxspeed, avgspeed, strafes, strafeacc, replaypath, custom1, custom2, custom3 FROM round WHERE map = '%s' AND style = %d AND track = %d ORDER BY time ASC;", g_currentMap, style, TRACK_BONUS5); SQL_TQuery(g_hSQL, RefreshBonus5CacheCallback, query, style, DBPrio_Low); } } @@ -897,11 +912,11 @@ RefreshCache() CollectCache(track, style, Handle:hndl) { CacheResetSingle(track, style); - + while (SQL_FetchRow(hndl)) { new nNewCache[RecordCache]; - + nNewCache[Id] = SQL_FetchInt(hndl, 0); SQL_FetchString(hndl, 1, nNewCache[Auth], 32); nNewCache[Time] = SQL_FetchFloat(hndl, 2); @@ -914,7 +929,7 @@ CollectCache(track, style, Handle:hndl) nNewCache[Stage] = SQL_FetchInt(hndl, 8); nNewCache[CurrentRank] = SQL_FetchInt(hndl, 9); nNewCache[JumpAcc] = SQL_FetchFloat(hndl, 10); - + nNewCache[FinishSpeed] = SQL_FetchFloat(hndl, 11); nNewCache[MaxSpeed] = SQL_FetchFloat(hndl, 12); nNewCache[AvgSpeed] = SQL_FetchFloat(hndl, 13); @@ -924,14 +939,14 @@ CollectCache(track, style, Handle:hndl) SQL_FetchString(hndl, 17, nNewCache[Custom1], 32); SQL_FetchString(hndl, 18, nNewCache[Custom2], 32); SQL_FetchString(hndl, 19, nNewCache[Custom3], 32); - + nNewCache[Ignored] = false; - + PushArrayArray(g_hCache[style][track], nNewCache[0]); } - + g_cacheLoaded[style][track] = true; - + /* Forwards */ Call_StartForward(g_OnRecordCacheLoaded); Call_PushCell(style); @@ -948,7 +963,7 @@ public RefreshCacheCallback(Handle:owner, Handle:hndl, const String:error[], any Timer_LogError("SQL Error on RefreshCache: %s", error); return; } - + CollectCache(TRACK_NORMAL, style, hndl); } @@ -959,7 +974,7 @@ public RefreshBonusCacheCallback(Handle:owner, Handle:hndl, const String:error[] Timer_LogError("SQL Error on RefreshBonusCache: %s", error); return; } - + CollectCache(TRACK_BONUS, style, hndl); } @@ -970,7 +985,7 @@ public RefreshBonus2CacheCallback(Handle:owner, Handle:hndl, const String:error[ Timer_LogError("SQL Error on RefreshBonus2Cache: %s", error); return; } - + CollectCache(TRACK_BONUS2, style, hndl); } @@ -981,7 +996,7 @@ public RefreshBonus3CacheCallback(Handle:owner, Handle:hndl, const String:error[ Timer_LogError("SQL Error on RefreshBonus3Cache: %s", error); return; } - + CollectCache(TRACK_BONUS3, style, hndl); } @@ -992,7 +1007,7 @@ public RefreshBonus4CacheCallback(Handle:owner, Handle:hndl, const String:error[ Timer_LogError("SQL Error on RefreshBonus4Cache: %s", error); return; } - + CollectCache(TRACK_BONUS4, style, hndl); } @@ -1003,7 +1018,7 @@ public RefreshBonus5CacheCallback(Handle:owner, Handle:hndl, const String:error[ Timer_LogError("SQL Error on RefreshBonus5Cache: %s", error); return; } - + CollectCache(TRACK_BONUS5, style, hndl); } @@ -1014,17 +1029,17 @@ CollectBestCache(track, any:style) g_cachestats[style][track][RecordStatsBestTime] = 0.0; FormatEx(g_cachestats[style][track][RecordStatsName], 32, ""); FormatEx(g_cachestats[style][track][RecordStatsBestTimeString], 32, ""); - + for (new i = 0; i < GetArraySize(g_hCache[style][track]); i++) { new nCache[RecordCache]; GetArrayArray(g_hCache[style][track], i, nCache[0]); - + if(nCache[Time] <= 0.0) continue; - + g_cachestats[style][track][RecordStatsCount]++; - + if(g_cachestats[style][track][RecordStatsBestTime] == 0.0 || g_cachestats[style][track][RecordStatsBestTime] > nCache[Time]) { g_cachestats[style][track][RecordStatsID] = nCache[Id]; @@ -1041,9 +1056,9 @@ ConnectSQL(bool:refreshCache) { CloseHandle(g_hSQL); } - + g_hSQL = INVALID_HANDLE; - + if (SQL_CheckConfig("timer")) { SQL_TConnect(ConnectSQLCallback, "timer", refreshCache); @@ -1059,7 +1074,7 @@ public ConnectSQLCallback(Handle:owner, Handle:hndl, const String:error[], any:d if (hndl == INVALID_HANDLE) { Timer_LogError("Connection to SQL database has failed, Reason: %s", error); - + g_reconnectCounter++; if (g_reconnectCounter >= 5) { @@ -1067,13 +1082,13 @@ public ConnectSQLCallback(Handle:owner, Handle:hndl, const String:error[], any:d //SetFailState("PLUGIN STOPPED - Reason: reconnect counter reached max - PLUGIN STOPPED"); //return; } - + ConnectSQL(data); return; } g_hSQL = CloneHandle(hndl); - + decl String:driver[16]; SQL_GetDriverIdent(owner, driver, sizeof(driver)); @@ -1081,7 +1096,7 @@ public ConnectSQLCallback(Handle:owner, Handle:hndl, const String:error[], any:d if (data) { - RefreshCache(); + RefreshCache(); } } @@ -1092,31 +1107,31 @@ CreateRankedWRMenu(client) new Handle:menu = CreateMenu(MenuHandler_RankedWR); SetMenuTitle(menu, "%t", "World Record Menu Title", client); - + SetMenuExitBackButton(menu, true); SetMenuExitButton(menu, true); - + new count = 0; new found = 0; - + new maxorder[3] = {0, ...}; - for(new i = 0; i < MAX_STYLES-1; i++) + for(new i = 0; i < MAX_STYLES-1; i++) { if(!g_Physics[i][StyleEnable]) continue; if(g_Physics[i][StyleCategory] != MCategory_Ranked) continue; - + if(g_Physics[i][StyleOrder] > maxorder[MCategory_Ranked]) maxorder[MCategory_Ranked] = g_Physics[i][StyleOrder]; - + count++; } - - for(new order = 0; order <= maxorder[MCategory_Ranked]; order++) + + for(new order = 0; order <= maxorder[MCategory_Ranked]; order++) { - for(new i = 0; i < MAX_STYLES-1; i++) + for(new i = 0; i < MAX_STYLES-1; i++) { if(!g_Physics[i][StyleEnable]) continue; @@ -1124,15 +1139,15 @@ CreateRankedWRMenu(client) continue; if(g_Physics[i][StyleOrder] != order) continue; - + found++; - + new String:buffer[8]; IntToString(i, buffer, sizeof(buffer)); - + AddMenuItem(menu, buffer, g_Physics[i][StyleName]); } - + if(found == count) break; } @@ -1143,15 +1158,15 @@ CreateRankedWRMenu(client) public MenuHandler_RankedWR(Handle:menu, MenuAction:action, client, itemNum) { - if (action == MenuAction_End) + if (action == MenuAction_End) { CloseHandle(menu); } - else if (action == MenuAction_Select) + else if (action == MenuAction_Select) { - decl String:info[8]; + decl String:info[8]; GetMenuItem(menu, itemNum, info, sizeof(info)); - + CreateWRMenu(client, StringToInt(info), 0); } } @@ -1181,33 +1196,33 @@ CreateRankedBWRMenu(client, track) { menu = CreateMenu(MenuHandler_RankedB5WR); } - + SetMenuTitle(menu, "%t", "Bonus World Record Menu Title", client); - + SetMenuExitBackButton(menu, true); SetMenuExitButton(menu, true); - + new count = 0; new found = 0; - + new maxorder[3] = {0, ...}; - for(new i = 0; i < MAX_STYLES-1; i++) + for(new i = 0; i < MAX_STYLES-1; i++) { if(!g_Physics[i][StyleEnable]) continue; if(g_Physics[i][StyleCategory] != MCategory_Ranked) continue; - + if(g_Physics[i][StyleOrder] > maxorder[MCategory_Ranked]) maxorder[MCategory_Ranked] = g_Physics[i][StyleOrder]; - + count++; } - - for(new order = 0; order <= maxorder[MCategory_Ranked]; order++) + + for(new order = 0; order <= maxorder[MCategory_Ranked]; order++) { - for(new i = 0; i < MAX_STYLES-1; i++) + for(new i = 0; i < MAX_STYLES-1; i++) { if(!g_Physics[i][StyleEnable]) continue; @@ -1215,15 +1230,15 @@ CreateRankedBWRMenu(client, track) continue; if(g_Physics[i][StyleOrder] != order) continue; - + found++; - + new String:buffer[8]; IntToString(i, buffer, sizeof(buffer)); - + AddMenuItem(menu, buffer, g_Physics[i][StyleName]); } - + if(found == count) break; } @@ -1234,91 +1249,76 @@ CreateRankedBWRMenu(client, track) public MenuHandler_RankedBWR(Handle:menu, MenuAction:action, client, itemNum) { - if (action == MenuAction_End) + if (action == MenuAction_End) { CloseHandle(menu); } - else if (action == MenuAction_Select) + else if (action == MenuAction_Select) { - decl String:info[32]; + decl String:info[32]; GetMenuItem(menu, itemNum, info, sizeof(info)); - - CreateWRMenu(client, StringToInt(info), 1); + + CreateWRMenu(client, StringToInt(info), TRACK_BONUS); } } public MenuHandler_RankedB2WR(Handle:menu, MenuAction:action, client, itemNum) { - if (action == MenuAction_End) + if (action == MenuAction_End) { CloseHandle(menu); } - else if (action == MenuAction_Select) + else if (action == MenuAction_Select) { - decl String:info[32]; + decl String:info[32]; GetMenuItem(menu, itemNum, info, sizeof(info)); - - CreateWRMenu(client, StringToInt(info), 2); + + CreateWRMenu(client, StringToInt(info), TRACK_BONUS2); } } public MenuHandler_RankedB3WR(Handle:menu, MenuAction:action, client, itemNum) { - if (action == MenuAction_End) + if (action == MenuAction_End) { CloseHandle(menu); } - else if (action == MenuAction_Select) + else if (action == MenuAction_Select) { - decl String:info[32]; + decl String:info[32]; GetMenuItem(menu, itemNum, info, sizeof(info)); - - CreateWRMenu(client, StringToInt(info), 3); + + CreateWRMenu(client, StringToInt(info), TRACK_BONUS3); } } public MenuHandler_RankedB4WR(Handle:menu, MenuAction:action, client, itemNum) { - if (action == MenuAction_End) + if (action == MenuAction_End) { CloseHandle(menu); } - else if (action == MenuAction_Select) + else if (action == MenuAction_Select) { - decl String:info[32]; + decl String:info[32]; GetMenuItem(menu, itemNum, info, sizeof(info)); - - CreateWRMenu(client, StringToInt(info), 4); + + CreateWRMenu(client, StringToInt(info), TRACK_BONUS4); } } public MenuHandler_RankedB5WR(Handle:menu, MenuAction:action, client, itemNum) { - if (action == MenuAction_End) + if (action == MenuAction_End) { CloseHandle(menu); } - else if (action == MenuAction_Select) + else if (action == MenuAction_Select) { - decl String:info[32]; + decl String:info[32]; GetMenuItem(menu, itemNum, info, sizeof(info)); - - CreateWRMenu(client, StringToInt(info), 5); - } -} -public MenuHandler_RankedSWR(Handle:menu, MenuAction:action, client, itemNum) -{ - if (action == MenuAction_End) - { - CloseHandle(menu); - } - else if (action == MenuAction_Select) - { - decl String:info[32]; - GetMenuItem(menu, itemNum, info, sizeof(info)); - - CreateWRMenu(client, StringToInt(info), 2); + CreateWRMenu(client, StringToInt(info), TRACK_BONUS5); } } @@ -1327,59 +1327,59 @@ CreateWRMenu(client, style, track) new Handle:menu; new total = GetArraySize(g_hCache[style][track]); - + if(track == TRACK_NORMAL) { menu = CreateMenu(MenuHandler_WR); SetMenuTitle(menu, "Top players on %s [%d total]", g_currentMap, total); } - else if (track == TRACK_BONUS) + else if (track == TRACK_BONUS) { menu = CreateMenu(MenuHandler_BonusWR); SetMenuTitle(menu, "Bonus-Top players on %s [%d total]", g_currentMap, total); } - else if (track == TRACK_BONUS2) + else if (track == TRACK_BONUS2) { menu = CreateMenu(MenuHandler_Bonus2WR); SetMenuTitle(menu, "Bonus2-Top players on %s [%d total]", g_currentMap, total); } - else if (track == TRACK_BONUS3) + else if (track == TRACK_BONUS3) { menu = CreateMenu(MenuHandler_Bonus3WR); SetMenuTitle(menu, "Bonus3-Top players on %s [%d total]", g_currentMap, total); } - else if (track == TRACK_BONUS4) + else if (track == TRACK_BONUS4) { menu = CreateMenu(MenuHandler_Bonus4WR); SetMenuTitle(menu, "Bonus4-Top players on %s [%d total]", g_currentMap, total); } - else if (track == TRACK_BONUS5) + else if (track == TRACK_BONUS5) { menu = CreateMenu(MenuHandler_Bonus5WR); SetMenuTitle(menu, "Bonus5-Top players on %s [%d total]", g_currentMap, total); } - + if (g_timerPhysics && g_Settings[MultimodeEnable]) SetMenuExitBackButton(menu, true); else SetMenuExitButton(menu, true); - + new items = 0; - + for (new i = 0; i < GetArraySize(g_hCache[style][track]); i++) { new nCache[RecordCache]; GetArrayArray(g_hCache[style][track], i, nCache[0]); - + decl String:id[64]; - IntToString(nCache[Id], id, sizeof(id)); - + IntToString(i, id, sizeof(id)); + decl String:text[92]; FormatEx(text, sizeof(text), "#%d | %s - %s", i+1, nCache[Name], nCache[TimeString]); - + if (g_Settings[JumpsEnable]) Format(text, sizeof(text), "%s (%d jumps)", text, nCache[Jumps]); - + AddMenuItem(menu, id, text); items++; } @@ -1387,13 +1387,13 @@ CreateWRMenu(client, style, track) if (items == 0) { CloseHandle(menu); - + if (style == -1) - CPrintToChat(client, PLUGIN_PREFIX, "No Records"); + CPrintToChat(client, PLUGIN_PREFIX, "No Records"); else { CPrintToChat(client, PLUGIN_PREFIX, "No Difficulty Records"); - + if(g_Settings[MultimodeEnable]) { if(track == TRACK_NORMAL) CreateRankedWRMenu(client); @@ -1410,142 +1410,142 @@ CreateWRMenu(client, style, track) public MenuHandler_WR(Handle:menu, MenuAction:action, param1, param2) { - if (action == MenuAction_End) + if (action == MenuAction_End) { CloseHandle(menu); } - else if (action == MenuAction_Cancel) + else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack) + if (param2 == MenuCancel_ExitBack) { if (g_timerPhysics) CreateRankedWRMenu(param1); } - } - else if (action == MenuAction_Select) + } + else if (action == MenuAction_Select) { - decl String:info[64]; + decl String:info[64]; GetMenuItem(menu, param2, info, sizeof(info)); - CreatePlayerInfoMenu(param1, StringToInt(info), 0); + CreateRecordInfoMenu(param1, StringToInt(info), TRACK_NORMAL); } } public MenuHandler_BonusWR(Handle:menu, MenuAction:action, param1, param2) { - if (action == MenuAction_End) + if (action == MenuAction_End) { CloseHandle(menu); } - else if (action == MenuAction_Cancel) + else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack) + if (param2 == MenuCancel_ExitBack) { if (g_timerPhysics) - CreateRankedBWRMenu(param1, 1); + CreateRankedBWRMenu(param1, TRACK_BONUS); } - } - else if (action == MenuAction_Select) + } + else if (action == MenuAction_Select) { - decl String:info[64]; + decl String:info[64]; GetMenuItem(menu, param2, info, sizeof(info)); - - CreatePlayerInfoMenu(param1, StringToInt(info), 1); + + CreateRecordInfoMenu(param1, StringToInt(info), TRACK_BONUS); } } public MenuHandler_Bonus2WR(Handle:menu, MenuAction:action, param1, param2) { - if (action == MenuAction_End) + if (action == MenuAction_End) { CloseHandle(menu); } - else if (action == MenuAction_Cancel) + else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack) + if (param2 == MenuCancel_ExitBack) { if (g_timerPhysics) - CreateRankedBWRMenu(param1, 2); + CreateRankedBWRMenu(param1, TRACK_BONUS2); } - } - else if (action == MenuAction_Select) + } + else if (action == MenuAction_Select) { - decl String:info[64]; + decl String:info[64]; GetMenuItem(menu, param2, info, sizeof(info)); - - CreatePlayerInfoMenu(param1, StringToInt(info), 2); + + CreateRecordInfoMenu(param1, StringToInt(info), TRACK_BONUS2); } } public MenuHandler_Bonus3WR(Handle:menu, MenuAction:action, param1, param2) { - if (action == MenuAction_End) + if (action == MenuAction_End) { CloseHandle(menu); } - else if (action == MenuAction_Cancel) + else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack) + if (param2 == MenuCancel_ExitBack) { if (g_timerPhysics) - CreateRankedBWRMenu(param1, 3); + CreateRankedBWRMenu(param1, TRACK_BONUS3); } - } - else if (action == MenuAction_Select) + } + else if (action == MenuAction_Select) { - decl String:info[64]; + decl String:info[64]; GetMenuItem(menu, param2, info, sizeof(info)); - - CreatePlayerInfoMenu(param1, StringToInt(info), 3); + + CreateRecordInfoMenu(param1, StringToInt(info), TRACK_BONUS3); } } public MenuHandler_Bonus4WR(Handle:menu, MenuAction:action, param1, param2) { - if (action == MenuAction_End) + if (action == MenuAction_End) { CloseHandle(menu); } - else if (action == MenuAction_Cancel) + else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack) + if (param2 == MenuCancel_ExitBack) { if (g_timerPhysics) - CreateRankedBWRMenu(param1, 4); + CreateRankedBWRMenu(param1, TRACK_BONUS4); } - } - else if (action == MenuAction_Select) + } + else if (action == MenuAction_Select) { - decl String:info[64]; + decl String:info[64]; GetMenuItem(menu, param2, info, sizeof(info)); - - CreatePlayerInfoMenu(param1, StringToInt(info), 4); + + CreateRecordInfoMenu(param1, StringToInt(info), TRACK_BONUS4); } } public MenuHandler_Bonus5WR(Handle:menu, MenuAction:action, param1, param2) { - if (action == MenuAction_End) + if (action == MenuAction_End) { CloseHandle(menu); } - else if (action == MenuAction_Cancel) + else if (action == MenuAction_Cancel) { - if (param2 == MenuCancel_ExitBack) + if (param2 == MenuCancel_ExitBack) { if (g_timerPhysics) - CreateRankedBWRMenu(param1, 5); + CreateRankedBWRMenu(param1, TRACK_BONUS5); } - } - else if (action == MenuAction_Select) + } + else if (action == MenuAction_Select) { - decl String:info[64]; + decl String:info[64]; GetMenuItem(menu, param2, info, sizeof(info)); - - CreatePlayerInfoMenu(param1, StringToInt(info), 5); + + CreateRecordInfoMenu(param1, StringToInt(info), TRACK_BONUS5); } } -CreatePlayerInfoMenu(client, id, track) +CreateRecordInfoMenu(client, index, track) { new Handle:menu; @@ -1573,72 +1573,65 @@ CreatePlayerInfoMenu(client, id, track) { menu = CreateMenu(MenuHandler_RankedB5WR); } - + new style = g_wrStyleMode[client]; SetMenuExitButton(menu, true); - for (new i = 0; i < GetArraySize(g_hCache[style][track]); i++) + new nCache[RecordCache]; + GetArrayArray(g_hCache[style][track], index, nCache[0]); + + decl String:sStyle[5]; + IntToString(style, sStyle, sizeof(sStyle)); + + decl String:text[92]; + + SetMenuTitle(menu, "Record Info [ID: %d]\n \n", nCache[Id]); + + FormatEx(text, sizeof(text), "Date: %s", nCache[Date]); + AddMenuItem(menu, sStyle, text); + + FormatEx(text, sizeof(text), "Player: %s (%s)", nCache[Name], nCache[Auth]); + AddMenuItem(menu, sStyle, text); + + FormatEx(text, sizeof(text), "Rank: #%d [FC: %d]", index+1, nCache[FinishCount]); + AddMenuItem(menu, sStyle, text); + + FormatEx(text, sizeof(text), "Time: %s", nCache[TimeString]); + AddMenuItem(menu, sStyle, text); + + FormatEx(text, sizeof(text), "Speed [Avg: %.2f | Max: %.2f | Fin: %.2f]", nCache[AvgSpeed], nCache[MaxSpeed], nCache[FinishSpeed]); + AddMenuItem(menu, sStyle, text); + + if (g_Settings[JumpsEnable]) { - new nCache[RecordCache]; - GetArrayArray(g_hCache[style][track], i, nCache[0]); - - if (nCache[Id] == id) - { - decl String:sStyle[5]; - IntToString(style, sStyle, sizeof(sStyle)); - - decl String:text[92]; - - SetMenuTitle(menu, "Record Info [ID: %d]\n \n", id); - - FormatEx(text, sizeof(text), "Date: %s", nCache[Date]); - AddMenuItem(menu, sStyle, text); - - FormatEx(text, sizeof(text), "Player: %s (%s)", nCache[Name], nCache[Auth]); - AddMenuItem(menu, sStyle, text); - - FormatEx(text, sizeof(text), "Rank: #%d (#%d) [FC: %d]", i+1, nCache[CurrentRank], nCache[FinishCount]); - AddMenuItem(menu, sStyle, text); - - FormatEx(text, sizeof(text), "Time: %s", nCache[TimeString]); - AddMenuItem(menu, sStyle, text); - - FormatEx(text, sizeof(text), "Speed [Avg: %.2f | Max: %.2f | Fin: %.2f]", nCache[AvgSpeed], nCache[MaxSpeed], nCache[FinishSpeed]); - AddMenuItem(menu, sStyle, text); - - if (g_Settings[JumpsEnable]) - { - FormatEx(text, sizeof(text), "Jumps: %d", nCache[Jumps]); - Format(text, sizeof(text), "%s [%.2f ⁰⁄₀]", text, nCache[JumpAcc]); - AddMenuItem(menu, sStyle, text); - } - - if (g_Settings[StrafesEnable]) - { - FormatEx(text, sizeof(text), "Strafes: %d", nCache[Strafes]); - Format(text, sizeof(text), "%s [%.2f ⁰⁄₀]", text, nCache[StrafeAcc]); - AddMenuItem(menu, sStyle, text); - } - - if (g_Settings[MultimodeEnable]) - { - FormatEx(text, sizeof(text), "%Style: %s", g_Physics[style][StyleName]); - AddMenuItem(menu, sStyle, text); - } - break; - } + FormatEx(text, sizeof(text), "Jumps: %d", nCache[Jumps]); + Format(text, sizeof(text), "%s [%.2f ⁰⁄₀]", text, nCache[JumpAcc]); + AddMenuItem(menu, sStyle, text); } - DisplayMenu(menu, client, MENU_TIME_FOREVER); + if (g_Settings[StrafesEnable]) + { + FormatEx(text, sizeof(text), "Strafes: %d", nCache[Strafes]); + Format(text, sizeof(text), "%s [%.2f ⁰⁄₀]", text, nCache[StrafeAcc]); + AddMenuItem(menu, sStyle, text); + } + + if (g_Settings[MultimodeEnable]) + { + FormatEx(text, sizeof(text), "%Style: %s", g_Physics[style][StyleName]); + AddMenuItem(menu, sStyle, text); + } + + DisplayMenu(menu, client, MENU_TIME_FOREVER); } CreateDeleteMenu(client, target, String:targetmap[64], ignored = -1) -{ +{ decl String:buffer[128]; - if(ignored != -1) + if(ignored != -1) FormatEx(buffer, sizeof(buffer), " AND NOT id = '%d'", ignored); - + if (g_hSQL == INVALID_HANDLE) { ConnectSQL(false); @@ -1647,28 +1640,28 @@ CreateDeleteMenu(client, target, String:targetmap[64], ignored = -1) { decl String:auth[32]; GetClientAuthString(target, auth, sizeof(auth)); - + decl String:query[512]; - FormatEx(query, sizeof(query), "SELECT id, time, jumps, style, auth FROM `round` WHERE map = '%s' AND auth = '%s'%s ORDER BY style, time, jumps", targetmap, auth, buffer); - + FormatEx(query, sizeof(query), "SELECT id, time, jumps, style, auth FROM `round` WHERE map = '%s' AND auth = '%s'%s ORDER BY style, time, jumps", targetmap, auth, buffer); + g_deleteMenuSelection[client] = target; SQL_TQuery(g_hSQL, CreateDeleteMenuCallback, query, client, DBPrio_Normal); - } + } else { decl String:auth[32]; GetClientAuthString(target, auth, sizeof(auth)); - + decl String:query[512]; - FormatEx(query, sizeof(query), "SELECT id, time, jumps, style, auth FROM `round` WHERE map = '%s' AND auth = '%s'%s ORDER BY style, time, jumps", targetmap, auth, buffer); - + FormatEx(query, sizeof(query), "SELECT id, time, jumps, style, auth FROM `round` WHERE map = '%s' AND auth = '%s'%s ORDER BY style, time, jumps", targetmap, auth, buffer); + g_deleteMenuSelection[client] = target; SQL_TQuery(g_hSQL, CreateDeleteMenuCallback, query, client, DBPrio_Normal); } } public CreateDeleteMenuCallback(Handle:owner, Handle:hndl, const String:error[], any:client) -{ +{ if (hndl == INVALID_HANDLE) { Timer_LogError("SQL Error on CreateDeleteMenu: %s", error); @@ -1679,33 +1672,33 @@ public CreateDeleteMenuCallback(Handle:owner, Handle:hndl, const String:error[], SetMenuTitle(menu, "%T", "Delete Records", client); SetMenuExitButton(menu, true); - + decl String:auth[32]; GetClientAuthString(client, auth, sizeof(auth)); - + while (SQL_FetchRow(hndl)) { decl String:steamid[32]; SQL_FetchString(hndl, 4, steamid, sizeof(steamid)); - + if (!StrEqual(steamid, auth)) { CloseHandle(menu); return; } - + decl String:id[10]; IntToString(SQL_FetchInt(hndl, 0), id, sizeof(id)); decl String:time[16]; Timer_SecondsToTime(SQL_FetchFloat(hndl, 1), time, sizeof(time), 3); - + decl String:value[92]; FormatEx(value, sizeof(value), "%s %s", time, g_Physics[SQL_FetchInt(hndl, 3)][StyleName]); - + if (g_Settings[JumpsEnable]) Format(value, sizeof(value), "%s %T: %d", value, "Jumps", client, SQL_FetchInt(hndl, 2)); - + AddMenuItem(menu, id, value); } @@ -1714,22 +1707,22 @@ public CreateDeleteMenuCallback(Handle:owner, Handle:hndl, const String:error[], public MenuHandler_DeleteRecord(Handle:menu, MenuAction:action, client, itemNum) { - if (action == MenuAction_End) + if (action == MenuAction_End) { RefreshCache(); CloseHandle(menu); } - else if (action == MenuAction_Select) + else if (action == MenuAction_Select) { - - decl String:info[32]; + + decl String:info[32]; GetMenuItem(menu, itemNum, info, sizeof(info)); - + //fake refresh CreateDeleteMenu(client, g_deleteMenuSelection[client], g_currentMap, StringToInt(info)); - + decl String:query[384]; - FormatEx(query, sizeof(query), "DELETE FROM `round` WHERE id = %s", info); + FormatEx(query, sizeof(query), "DELETE FROM `round` WHERE id = %s", info); SQL_TQuery(g_hSQL, DeleteRecordCallback, query, client, DBPrio_Normal); } @@ -1754,19 +1747,19 @@ public Native_GetStyleRank(Handle:plugin, numParams) new client = GetNativeCell(1); new track = GetNativeCell(2); new style = GetNativeCell(3); - + decl String:auth[32]; GetClientAuthString(client, auth, sizeof(auth)); - + for (new i = 0; i < GetArraySize(g_hCache[style][track]); i++) { new nCache[RecordCache]; GetArrayArray(g_hCache[style][track], i, nCache[0]); - + if (StrEqual(nCache[Auth], auth)) return i+1; } - + return 0; } @@ -1779,11 +1772,11 @@ public Native_GetStyleRecordWRStats(Handle:plugin, numParams) { new style = GetNativeCell(1); new track = GetNativeCell(2); - + SetNativeCellRef(3, g_cachestats[style][track][RecordStatsID]); SetNativeCellRef(4, g_cachestats[style][track][RecordStatsBestTime]); SetNativeCellRef(5, g_cachestats[style][track][RecordStatsCount]); - + return true; } @@ -1792,18 +1785,18 @@ public Native_GetBestRound(Handle:plugin, numParams) new client = GetNativeCell(1); new style = GetNativeCell(2); new track = GetNativeCell(3); - + decl String:auth[32]; GetClientAuthString(client, auth, sizeof(auth)); - + if(GetArraySize(g_hCache[style][track]) <= 0) return false; - + for (new i = 0; i < GetArraySize(g_hCache[style][track]); i++) { new nCache[RecordCache]; GetArrayArray(g_hCache[style][track], i, nCache[0]); - + if (StrEqual(nCache[Auth], auth)) { SetNativeCellRef(4, nCache[Time]); @@ -1811,7 +1804,7 @@ public Native_GetBestRound(Handle:plugin, numParams) return true; } } - + return false; } @@ -1820,50 +1813,50 @@ public Native_GetNewPossibleRank(Handle:plugin, numParams) new style = GetNativeCell(1); new track = GetNativeCell(2); new Float:time = GetNativeCell(3); - + if(time == 0.0) return 0; - + if(GetArraySize(g_hCache[style][track]) <= 0) return 1; - + new i = 0; for (i = 0; i < GetArraySize(g_hCache[style][track]); i++) { new nCache[RecordCache]; GetArrayArray(g_hCache[style][track], i, nCache[0]); - + if (nCache[Time] > time) return i+1; } - + return GetArraySize(g_hCache[style][track])+1; } public Native_GetCacheMapName(Handle:plugin, numParams) { - new nlen = GetNativeCell(2); - + new nlen = GetNativeCell(2); + if (nlen <= 0) return false; - + if (SetNativeString(1, g_currentMap, nlen, true) == SP_ERROR_NONE) return true; - + return false; } public Native_SetCacheMapName(Handle:plugin, numParams) { - new nlen = GetNativeCell(2); + new nlen = GetNativeCell(2); new String:buffer[nlen]; - + GetNativeString(1, buffer, nlen); - + FormatEx(g_currentMap, sizeof(g_currentMap), "%s", buffer); - + RefreshCache(); - + return true; } @@ -1872,16 +1865,16 @@ public Native_GetRankID(Handle:plugin, numParams) new style = GetNativeCell(1); new track = GetNativeCell(2); new rank = GetNativeCell(3); - + if(rank < 1) return false; - + if(GetArraySize(g_hCache[style][track]) < rank) return false; - + new nCache[RecordCache]; GetArrayArray(g_hCache[style][track], rank-1, nCache[0]); - + return nCache[Id]; } @@ -1891,24 +1884,24 @@ public Native_GetRecordHolderName(Handle:plugin, numParams) new track = GetNativeCell(2); new rank = GetNativeCell(3); new nlen = GetNativeCell(5); - + if (nlen <= 0) return false; - + if(rank < 1) return false; - + if(GetArraySize(g_hCache[style][track]) < rank) return false; - + new nCache[RecordCache]; GetArrayArray(g_hCache[style][track], rank-1, nCache[0]); - + decl String:buffer[nlen]; FormatEx(buffer, nlen, "%s", nCache[Name]); if (SetNativeString(4, buffer, nlen, true) == SP_ERROR_NONE) return true; - + return false; } @@ -1918,24 +1911,24 @@ public Native_GetRecordHolderAuth(Handle:plugin, numParams) new track = GetNativeCell(2); new rank = GetNativeCell(3); new nlen = GetNativeCell(5); - + if (nlen <= 0) return false; - + if(rank < 1) return false; - + if(GetArraySize(g_hCache[style][track]) < rank) return false; - + new nCache[RecordCache]; GetArrayArray(g_hCache[style][track], rank-1, nCache[0]); - + decl String:buffer[nlen]; FormatEx(buffer, nlen, "%s", nCache[Auth]); if (SetNativeString(4, buffer, nlen, true) == SP_ERROR_NONE) return true; - + return false; } @@ -1945,24 +1938,24 @@ public Native_GetRecordDate(Handle:plugin, numParams) new track = GetNativeCell(2); new rank = GetNativeCell(3); new nlen = GetNativeCell(5); - + if (nlen <= 0) return false; - + if(rank < 1) return false; - + if(GetArraySize(g_hCache[style][track]) < rank) return false; - + new nCache[RecordCache]; GetArrayArray(g_hCache[style][track], rank-1, nCache[0]); - + decl String:buffer[nlen]; FormatEx(buffer, nlen, "%s", nCache[Date]); if (SetNativeString(4, buffer, nlen, true) == SP_ERROR_NONE) return true; - + return false; } @@ -1971,16 +1964,16 @@ public Native_GetFinishCount(Handle:plugin, numParams) new style = GetNativeCell(1); new track = GetNativeCell(2); new rank = GetNativeCell(3); - + if(rank < 1) return false; - + if(GetArraySize(g_hCache[style][track]) < rank) return false; - + new nCache[RecordCache]; GetArrayArray(g_hCache[style][track], rank-1, nCache[0]); - + return nCache[FinishCount]; } @@ -1990,27 +1983,27 @@ public Native_GetRecordTimeInfo(Handle:plugin, numParams) new track = GetNativeCell(2); new rank = GetNativeCell(3); new nlen = GetNativeCell(6); - + if (nlen <= 0) return false; - + if(rank < 1) return false; - + if(GetArraySize(g_hCache[style][track]) < rank) return false; - + new nCache[RecordCache]; GetArrayArray(g_hCache[style][track], rank-1, nCache[0]); - + SetNativeCellRef(4, nCache[Time]); - + decl String:buffer[nlen]; FormatEx(buffer, nlen, "%s", nCache[TimeString]); - + if (SetNativeString(5, buffer, nlen, true) == SP_ERROR_NONE) return true; - + return false; } @@ -2019,16 +2012,16 @@ public Native_GetRecordSpeedInfo(Handle:plugin, numParams) new style = GetNativeCell(1); new track = GetNativeCell(2); new rank = GetNativeCell(3); - + if(rank < 1) return false; - + if(GetArraySize(g_hCache[style][track]) < rank) return false; - + new nCache[RecordCache]; GetArrayArray(g_hCache[style][track], rank-1, nCache[0]); - + SetNativeCellRef(4, nCache[AvgSpeed]); SetNativeCellRef(5, nCache[MaxSpeed]); SetNativeCellRef(6, nCache[FinishSpeed]); @@ -2041,16 +2034,16 @@ public Native_GetRecordStrafeJumpInfo(Handle:plugin, numParams) new style = GetNativeCell(1); new track = GetNativeCell(2); new rank = GetNativeCell(3); - + if(rank < 1) return false; - + if(GetArraySize(g_hCache[style][track]) < rank) return false; - + new nCache[RecordCache]; GetArrayArray(g_hCache[style][track], rank-1, nCache[0]); - + SetNativeCellRef(4, nCache[Strafes]); SetNativeCellRef(5, nCache[StrafeAcc]); SetNativeCellRef(6, nCache[Jumps]); @@ -2064,25 +2057,25 @@ public Native_GetReplayFileName(Handle:plugin, numParams) new style = GetNativeCell(1); new track = GetNativeCell(2); new rank = GetNativeCell(3); - new nlen = GetNativeCell(5); - + new nlen = GetNativeCell(5); + if (nlen <= 0) return false; - + if(rank < 1) return false; - + if(GetArraySize(g_hCache[style][track]) < rank) return false; - + new nCache[RecordCache]; GetArrayArray(g_hCache[style][track], rank-1, nCache[0]); - + decl String:buffer[nlen]; FormatEx(buffer, nlen, "%s", nCache[ReplayFile]); if (SetNativeString(4, buffer, nlen, true) == SP_ERROR_NONE) return true; - + return false; } @@ -2091,32 +2084,32 @@ public Native_GetReplayPath(Handle:plugin, numParams) new style = GetNativeCell(1); new track = GetNativeCell(2); new rank = GetNativeCell(3); - new nlen = GetNativeCell(5); - + new nlen = GetNativeCell(5); + if (nlen <= 0) return false; - + if(rank < 1) return false; - + if(GetArraySize(g_hCache[style][track]) < rank) return false; - + new nCache[RecordCache]; GetArrayArray(g_hCache[style][track], rank-1, nCache[0]); - + if(nCache[Time] <= 0.0) return false; - + decl String:path[256]; Format(path, sizeof(path), "addons/sourcemod/data/botmimic/%d_%d/%s/%s/%s.rec", style, track, g_currentMap, nCache[Auth], nCache[ReplayFile]); ReplaceString(path, sizeof(path), ":", "_", true); - + decl String:buffer[nlen]; FormatEx(buffer, nlen, "%s", path); if (SetNativeString(4, buffer, nlen, true) == SP_ERROR_NONE) return true; - + return false; } @@ -2127,24 +2120,24 @@ public Native_GetCustom1(Handle:plugin, numParams) new track = GetNativeCell(2); new rank = GetNativeCell(3); new nlen = GetNativeCell(5); - + if (nlen <= 0) return false; - + if(rank < 1) return false; - + if(GetArraySize(g_hCache[style][track]) < rank) return false; - + new nCache[RecordCache]; GetArrayArray(g_hCache[style][track], rank-1, nCache[0]); - + decl String:buffer[nlen]; FormatEx(buffer, nlen, "%s", nCache[Custom1]); if (SetNativeString(4, buffer, nlen, true) == SP_ERROR_NONE) return true; - + return false; } @@ -2154,24 +2147,24 @@ public Native_GetCustom2(Handle:plugin, numParams) new track = GetNativeCell(2); new rank = GetNativeCell(3); new nlen = GetNativeCell(5); - + if (nlen <= 0) return false; - + if(rank < 1) return false; - + if(GetArraySize(g_hCache[style][track]) < rank) return false; - + new nCache[RecordCache]; GetArrayArray(g_hCache[style][track], rank-1, nCache[0]); - + decl String:buffer[nlen]; FormatEx(buffer, nlen, "%s", nCache[Custom2]); if (SetNativeString(4, buffer, nlen, true) == SP_ERROR_NONE) return true; - + return false; } @@ -2182,31 +2175,31 @@ public Native_GetCustom3(Handle:plugin, numParams) new track = GetNativeCell(2); new rank = GetNativeCell(3); new nlen = GetNativeCell(5); - + if (nlen <= 0) return false; - + if(rank < 1) return false; - + if(GetArraySize(g_hCache[style][track]) < rank) return false; - + new nCache[RecordCache]; GetArrayArray(g_hCache[style][track], rank-1, nCache[0]); - + decl String:buffer[nlen]; FormatEx(buffer, nlen, "%s", nCache[Custom3]); if (SetNativeString(4, buffer, nlen, true) == SP_ERROR_NONE) return true; - + return false; } CacheReset() { nCacheTemplate[Ignored] = false; //Just to get rid of a warning, it's just a template - + // Init world record cache for (new style = 0; style < MAX_STYLES; style++) { @@ -2215,7 +2208,7 @@ CacheReset() if(g_hCache[style][track] != INVALID_HANDLE) ClearArray(g_hCache[style][track]); else g_hCache[style][track] = CreateArray(sizeof(nCacheTemplate)); - + g_cacheLoaded[style][track] = false; } } @@ -2226,6 +2219,113 @@ CacheResetSingle(track, style) if(g_hCache[style][track] != INVALID_HANDLE) ClearArray(g_hCache[style][track]); else g_hCache[style][track] = CreateArray(sizeof(nCacheTemplate)); - + g_cacheLoaded[style][track] = false; } + +/* Bypass refresh cache on new record */ + +public OnTimerRecord(client, track, style, Float:time, Float:lasttime, currentrank, newrank) +{ + if(!Timer_IsStyleRanked(style)) + return; + + if(newrank <= 0) + return; + + decl String:buffer[16]; + new Float:wrtime; + Timer_GetRecordTimeInfo(style, track, 1, wrtime, buffer, 16); + + new bool:NewPersonalRecord = false; + new bool:NewWorldRecord = false; + new bool:FirstRecord = false; + + if(currentrank <= 0) + FirstRecord = true; + if(wrtime == 0.0 || time < wrtime) + NewWorldRecord = true; + if(lasttime == 0.0 || time < lasttime) + NewPersonalRecord = true; + + // Nothing improved? + if(!FirstRecord && !NewWorldRecord && !NewPersonalRecord) + { + // Just increase finishcount + new nOldCache[RecordCache]; + GetArrayArray(g_hCache[style][track], currentrank-1, nOldCache[0]); + nOldCache[FinishCount]++; + SetArrayArray(g_hCache[style][track], currentrank-1, nOldCache[0]); + } + else + { + // Build cache entry + new nNewCache[RecordCache]; + new fpsmax; + new bool:enabled; + nNewCache[Ignored] = false; + Timer_GetClientTimer(client, enabled, time, nNewCache[Jumps], fpsmax); + nNewCache[Id] = -1; // Unknown/Fresh + GetClientAuthString(client, nNewCache[Auth], 32); + nNewCache[Time] = time; + Timer_SecondsToTime(time, nNewCache[TimeString], 16, 2); + nNewCache[Style] = style; + GetClientName(client, nNewCache[Name], 32); + FormatTime(nNewCache[Date], 32, "%X", GetTime()); + + // Determine finishcount + if(FirstRecord) + { + nNewCache[FinishCount] = 1; + } + else + { + // Get old record for finishcount + for (new i = 0; i < GetArraySize(g_hCache[style][track]); i++) + { + new nCache[RecordCache]; + GetArrayArray(g_hCache[style][track], i, nCache[0]); + + if (StrEqual(nCache[Auth], nNewCache[Auth])) + { + nNewCache[FinishCount] = nCache[FinishCount]+1; + } + } + } + + // Continue + nNewCache[CurrentRank] = newrank; + Timer_GetJumpAccuracy(client, nNewCache[JumpAcc]); + Timer_GetCurrentSpeed(client, nNewCache[FinishSpeed]); + Timer_GetMaxSpeed(client, nNewCache[MaxSpeed]); + Timer_GetAvgSpeed(client, nNewCache[AvgSpeed]); + + if(g_timerStrafes) + { + nNewCache[Strafes] = Timer_GetStrafeCount(client); + nNewCache[StrafeAcc] = 100.0-(100.0*(float(Timer_GetBoostedStrafeCount(client))/float(Timer_GetStrafeCount(client)))); + } + + // He has already a record? Remove it + if(currentrank > 0) + RemoveFromArray(g_hCache[style][track], currentrank-1); + + // New worldrecord with existing records + if(newrank == 1 && GetArraySize(g_hCache[style][track]) > 0) + { + ShiftArrayUp(g_hCache[style][track], newrank-1); + SetArrayArray(g_hCache[style][track], newrank-1, nNewCache[0]); + } + // Not last rank, so shift and set + else if(newrank <= GetArraySize(g_hCache[style][track])) + { + ShiftArrayUp(g_hCache[style][track], newrank-1); + SetArrayArray(g_hCache[style][track], newrank-1, nNewCache[0]); + } + // First reord on this track or last place + else PushArrayArray(g_hCache[style][track], nNewCache[0]); + + if(newrank == 1) + CollectBestCache(track, style); + } +} diff --git a/gameserver/addons/sourcemod/scripting/timer-worldrecord_latest.sp b/gameserver/addons/sourcemod/scripting/timer-worldrecord_latest.sp index 5485d47..c733074 100644 --- a/gameserver/addons/sourcemod/scripting/timer-worldrecord_latest.sp +++ b/gameserver/addons/sourcemod/scripting/timer-worldrecord_latest.sp @@ -30,7 +30,7 @@ new Handle:g_hSQL = INVALID_HANDLE; new g_latestRecords[3][LATEST_LIMIT][Record]; new g_RecordCount[3]; -public Plugin:myinfo = +public Plugin:myinfo = { name = "[Timer] Worldrecord - Latest WRs", author = "Zipcore", @@ -44,12 +44,12 @@ public OnPluginStart() RegConsoleCmd("sm_latest", Cmd_LatestChoose); RegConsoleCmd("sm_rr", Cmd_LatestChoose); RegConsoleCmd("sm_recent", Cmd_LatestChoose); - + if (g_hSQL == INVALID_HANDLE) { ConnectSQL(); } - + LoadPhysics(); LoadTimerSettings(); } @@ -61,7 +61,7 @@ public OnMapStart() ConnectSQL(); } else LoadLatestRecords(); - + LoadPhysics(); LoadTimerSettings(); } @@ -82,7 +82,7 @@ public OnTimerSqlStop() ConnectSQL() { g_hSQL = Handle:Timer_SqlGetConnection(); - + if (g_hSQL == INVALID_HANDLE) CreateTimer(0.1, Timer_SQLReconnect, _ , TIMER_FLAG_NO_MAPCHANGE); else LoadLatestRecords(); @@ -102,13 +102,13 @@ public OnTimerRecord(client, track, mode, Float:time, Float:lasttime, currentran LoadLatestRecords() { decl String:sQuery[1024]; - + FormatEx(sQuery, sizeof(sQuery), "SELECT `map`, `track`, `style`, `auth`, `name`, `time`, `rank`, `date` FROM `round` ORDER BY `date` DESC LIMIT %d", LATEST_LIMIT); SQL_TQuery(g_hSQL, LoadLatestRecordsCallback, sQuery, RECORD_ANY, DBPrio_Low); - + FormatEx(sQuery, sizeof(sQuery), "SELECT `map`, `track`, `style`, `auth`, `name`, `time`, `rank`, `date` FROM `round` WHERE `rank` <= 10 ORDER BY `date` DESC LIMIT %d", LATEST_LIMIT); SQL_TQuery(g_hSQL, LoadLatestRecordsCallback, sQuery, RECORD_TOP, DBPrio_Low); - + FormatEx(sQuery, sizeof(sQuery), "SELECT `map`, `track`, `style`, `auth`, `name`, `time`, `rank`, `date` FROM `round` WHERE `rank` = 1 ORDER BY `date` DESC LIMIT %d", LATEST_LIMIT); SQL_TQuery(g_hSQL, LoadLatestRecordsCallback, sQuery, RECORD_WORLD, DBPrio_Low); } @@ -132,14 +132,14 @@ public LoadLatestRecordsCallback(Handle:owner, Handle:hndl, const String:error[] g_latestRecords[recordtype][recordCounter][RecordTime] = SQL_FetchFloat(hndl, 5); g_latestRecords[recordtype][recordCounter][RecordRank] = SQL_FetchInt(hndl, 6); SQL_FetchString(hndl, 7, g_latestRecords[recordtype][recordCounter][RecordDate], 32); - + recordCounter++; if (recordCounter == LATEST_LIMIT) { break; } } - + g_RecordCount[recordtype] = recordCounter; } @@ -148,13 +148,13 @@ public Action:Cmd_LatestChoose(client, args) if (client) { new Handle:menu = CreateMenu(Handle_LatestChoose); - + SetMenuTitle(menu, "Select filter for latest records"); - + AddMenuItem(menu, "any", "Any"); AddMenuItem(menu, "top", "Top10"); AddMenuItem(menu, "world", "World"); - + DisplayMenu(menu, client, MENU_TIME_FOREVER); } @@ -192,7 +192,7 @@ public Handle_LatestChoose(Handle:menu, MenuAction:action, client, itemNum) Menu_Latest(client, type) { new Handle:menu = INVALID_HANDLE; - + if(type == RECORD_TOP) { menu = CreateMenu(Handle_LatestTop); @@ -218,24 +218,24 @@ Menu_Latest(client, type) decl String:buffer[512]; Format(buffer, sizeof(buffer), "[#%d] %s", i+1, sTime); - - if(g_latestRecords[type][i][RecordTrack] == TRACK_BONUS) - Format(buffer, sizeof(buffer), "%s [B]", buffer); - + + if(g_latestRecords[type][i][RecordTrack] >= TRACK_BONUS) + Format(buffer, sizeof(buffer), "%s [B%d]", buffer, g_latestRecords[type][i][RecordTrack]); + Format(buffer, sizeof(buffer), "%s - %s", buffer, g_latestRecords[type][i][RecordName]); - + decl String:sInfo[3]; Format(sInfo, sizeof(sInfo), "%d", i); AddMenuItem(menu, sInfo, buffer); } - + if (g_RecordCount[type] == 0) { decl String:buffer[512]; Format(buffer, sizeof(buffer), "No records available!"); AddMenuItem(menu, "", buffer, ITEMDRAW_DISABLED); } - + SetMenuExitButton(menu, true); DisplayMenu(menu, client, 20); } @@ -251,32 +251,32 @@ public Handle_Latest(Handle:menu, MenuAction:action, client, itemNum) if(found) { new Handle:menu2 = CreateMenu(Handle_LatestChoose); - + SetMenuTitle(menu2, "Details"); - + new String:buffer[512]; - + Format(buffer, sizeof(buffer), "Map: %s", g_latestRecords[RECORD_ANY][id][RecordMap]); - if(g_latestRecords[RECORD_ANY][id][RecordTrack] == TRACK_BONUS) Format(buffer, sizeof(buffer), "%s [Bonus]", buffer); + if(g_latestRecords[RECORD_WORLD][id][RecordTrack] >= TRACK_BONUS) Format(buffer, sizeof(buffer), "%s [Bonus%d]", buffer, g_latestRecords[RECORD_WORLD][id][RecordTrack]); AddMenuItem(menu2, "any", buffer); - + if(g_Settings[MultimodeEnable]) { Format(buffer, sizeof(buffer), "Style: %s", g_Physics[g_latestRecords[RECORD_ANY][id][RecordStyle]][StyleName]); AddMenuItem(menu2, "any", buffer); } - + Format(buffer, sizeof(buffer), "Name: %s [%s]", g_latestRecords[RECORD_ANY][id][RecordName], g_latestRecords[RECORD_ANY][id][RecordAuth]); AddMenuItem(menu2, "any", buffer); - + decl String:sTime[128]; Timer_SecondsToTime(g_latestRecords[RECORD_ANY][id][RecordTime], sTime, sizeof(sTime), 2); Format(buffer, sizeof(buffer), "Time: %s (#%d)", sTime, g_latestRecords[RECORD_ANY][id][RecordRank]); AddMenuItem(menu2, "any", buffer); - + Format(buffer, sizeof(buffer), "Date: %s", g_latestRecords[RECORD_ANY][id][RecordDate]); AddMenuItem(menu2, "any", buffer); - + DisplayMenu(menu2, client, MENU_TIME_FOREVER); } } @@ -292,32 +292,32 @@ public Handle_LatestTop(Handle:menu, MenuAction:action, client, itemNum) if(found) { new Handle:menu2 = CreateMenu(Handle_LatestChoose); - + SetMenuTitle(menu2, "Details"); - + new String:buffer[512]; - + Format(buffer, sizeof(buffer), "Map: %s", g_latestRecords[RECORD_TOP][id][RecordMap]); - if(g_latestRecords[RECORD_TOP][id][RecordTrack] == TRACK_BONUS) Format(buffer, sizeof(buffer), "%s [Bonus]", buffer); + if(g_latestRecords[RECORD_WORLD][id][RecordTrack] >= TRACK_BONUS) Format(buffer, sizeof(buffer), "%s [Bonus%d]", buffer, g_latestRecords[RECORD_WORLD][id][RecordTrack]); AddMenuItem(menu2, "top", buffer); - + if(g_Settings[MultimodeEnable]) { Format(buffer, sizeof(buffer), "Style: %s", g_Physics[g_latestRecords[RECORD_TOP][id][RecordStyle]][StyleName]); AddMenuItem(menu2, "top", buffer); } - + Format(buffer, sizeof(buffer), "Name: %s [%s]", g_latestRecords[RECORD_TOP][id][RecordName], g_latestRecords[RECORD_TOP][id][RecordAuth]); AddMenuItem(menu2, "top", buffer); - + decl String:sTime[128]; Timer_SecondsToTime(g_latestRecords[RECORD_TOP][id][RecordTime], sTime, sizeof(sTime), 2); Format(buffer, sizeof(buffer), "Time: %s (#%d)", sTime, g_latestRecords[RECORD_TOP][id][RecordRank]); AddMenuItem(menu2, "top", buffer); - + Format(buffer, sizeof(buffer), "Date: %s", g_latestRecords[RECORD_TOP][id][RecordDate]); AddMenuItem(menu2, "top", buffer); - + DisplayMenu(menu2, client, MENU_TIME_FOREVER); } } @@ -333,32 +333,32 @@ public Handle_LatestWorld(Handle:menu, MenuAction:action, client, itemNum) if(found) { new Handle:menu2 = CreateMenu(Handle_LatestChoose); - + SetMenuTitle(menu2, "Details"); - + new String:buffer[512]; - + Format(buffer, sizeof(buffer), "Map: %s", g_latestRecords[RECORD_WORLD][id][RecordMap]); - if(g_latestRecords[RECORD_WORLD][id][RecordTrack] == TRACK_BONUS) Format(buffer, sizeof(buffer), "%s [Bonus]", buffer); + if(g_latestRecords[RECORD_WORLD][id][RecordTrack] >= TRACK_BONUS) Format(buffer, sizeof(buffer), "%s [Bonus%d]", buffer, g_latestRecords[RECORD_WORLD][id][RecordTrack]); AddMenuItem(menu2, "world", buffer); - + if(g_Settings[MultimodeEnable]) { Format(buffer, sizeof(buffer), "Style: %s", g_Physics[g_latestRecords[RECORD_WORLD][id][RecordStyle]][StyleName]); AddMenuItem(menu2, "world", buffer); } - + Format(buffer, sizeof(buffer), "Name: %s [%s]", g_latestRecords[RECORD_WORLD][id][RecordName], g_latestRecords[RECORD_WORLD][id][RecordAuth]); AddMenuItem(menu2, "world", buffer); - + decl String:sTime[128]; Timer_SecondsToTime(g_latestRecords[RECORD_ANY][id][RecordTime], sTime, sizeof(sTime), 2); Format(buffer, sizeof(buffer), "Time: %s", sTime, g_latestRecords[RECORD_WORLD][id][RecordRank]); AddMenuItem(menu2, "world", buffer); - + Format(buffer, sizeof(buffer), "Date: %s", g_latestRecords[RECORD_WORLD][id][RecordDate]); AddMenuItem(menu2, "world", buffer); - + DisplayMenu(menu2, client, MENU_TIME_FOREVER); } } diff --git a/gameserver/addons/sourcemod/scripting/timer-worldrecord_maptop.sp b/gameserver/addons/sourcemod/scripting/timer-worldrecord_maptop.sp index e478fb7..edfa23e 100644 --- a/gameserver/addons/sourcemod/scripting/timer-worldrecord_maptop.sp +++ b/gameserver/addons/sourcemod/scripting/timer-worldrecord_maptop.sp @@ -9,7 +9,7 @@ #define MAPTOP_LIMIT 100 -public Plugin:myinfo = +public Plugin:myinfo = { name = "[Timer] Worldrecord - MapTop", author = "Zipcore, Credits: Das D", @@ -28,11 +28,10 @@ public OnPluginStart() { RegConsoleCmd("sm_mtop", Cmd_MapTop_Record, "Displays Top of a given map"); RegConsoleCmd("sm_mbtop", Cmd_MapBonusTop_Record, "Displays BonusTop of a given map"); - RegConsoleCmd("sm_mstop", Cmd_MapShortTop_Record, "Displays ShortTop of a given map"); LoadPhysics(); LoadTimerSettings(); - + if (g_hSQL == INVALID_HANDLE) { ConnectSQL(); @@ -43,7 +42,7 @@ public OnMapStart() { LoadPhysics(); LoadTimerSettings(); - + if (g_hSQL == INVALID_HANDLE) { ConnectSQL(); @@ -66,7 +65,7 @@ public OnTimerSqlStop() ConnectSQL() { g_hSQL = Handle:Timer_SqlGetConnection(); - + if (g_hSQL == INVALID_HANDLE) CreateTimer(0.1, Timer_SQLReconnect, _ , TIMER_FLAG_NO_MAPCHANGE); } @@ -91,7 +90,7 @@ public Action:Cmd_MapTop_Record(client, args) { decl String:sMapName[64]; GetCmdArg(1, sMapName, sizeof(sMapName)); - + if(g_Settings[MultimodeEnable]) TopStylePanel(client, sMapName); else SQL_TopPanel(client, sMapName, g_StyleDefault, TRACK_NORMAL); } @@ -101,8 +100,8 @@ public Action:Cmd_MapTop_Record(client, args) GetCmdArg(1, sMapName, sizeof(sMapName)); decl String:sStyle[64]; GetCmdArg(2, sStyle, sizeof(sStyle)); - - for(new i = 0; i < MAX_STYLES-1; i++) + + for(new i = 0; i < MAX_STYLES-1; i++) { if(!g_Physics[i][StyleEnable]) continue; @@ -110,7 +109,7 @@ public Action:Cmd_MapTop_Record(client, args) continue; if(StrEqual(g_Physics[i][StyleQuickCommand], "")) continue; - + if(StrEqual(g_Physics[i][StyleQuickCommand], sStyle)) { SQL_TopPanel(client, sMapName, i, TRACK_NORMAL); @@ -118,7 +117,7 @@ public Action:Cmd_MapTop_Record(client, args) } } } - + return Plugin_Handled; } @@ -129,21 +128,21 @@ TopStylePanel(client, String:sMapName[64]) new Handle:menu = CreateMenu(MenuHandler_TopStylePanel); SetMenuTitle(menu, "Select Style", client); - + SetMenuExitButton(menu, true); - for(new i = 0; i < MAX_STYLES-1; i++) + for(new i = 0; i < MAX_STYLES-1; i++) { if(!g_Physics[i][StyleEnable]) continue; if(g_Physics[i][StyleCategory] != MCategory_Ranked) continue; - + new String:buffer[8]; IntToString(i, buffer, sizeof(buffer)); - + AddMenuItem(menu, buffer, g_Physics[i][StyleName]); - } + } Format(g_SelectedMap[client], 64, sMapName); DisplayMenu(menu, client, MENU_TIME_FOREVER); @@ -152,15 +151,15 @@ TopStylePanel(client, String:sMapName[64]) public MenuHandler_TopStylePanel(Handle:menu, MenuAction:action, client, itemNum) { - if (action == MenuAction_End) + if (action == MenuAction_End) { CloseHandle(menu); } - else if (action == MenuAction_Select) + else if (action == MenuAction_Select) { - decl String:info[8]; + decl String:info[8]; GetMenuItem(menu, itemNum, info, sizeof(info)); - + SQL_TopPanel(client, g_SelectedMap[client], StringToInt(info), TRACK_NORMAL); } } @@ -179,7 +178,7 @@ public Action:Cmd_MapBonusTop_Record(client, args) { decl String:sMapName[64]; GetCmdArg(1, sMapName, sizeof(sMapName)); - + if(g_Settings[MultimodeEnable]) BonusTopStylePanel(client, sMapName); else SQL_TopPanel(client, sMapName, g_StyleDefault, TRACK_BONUS); } @@ -189,8 +188,8 @@ public Action:Cmd_MapBonusTop_Record(client, args) GetCmdArg(1, sMapName, sizeof(sMapName)); decl String:sStyle[64]; GetCmdArg(2, sStyle, sizeof(sStyle)); - - for(new i = 0; i < MAX_STYLES-1; i++) + + for(new i = 0; i < MAX_STYLES-1; i++) { if(!g_Physics[i][StyleEnable]) continue; @@ -198,7 +197,7 @@ public Action:Cmd_MapBonusTop_Record(client, args) continue; if(StrEqual(g_Physics[i][StyleQuickCommand], "")) continue; - + if(StrEqual(g_Physics[i][StyleQuickCommand], sStyle)) { SQL_TopPanel(client, sMapName, i, TRACK_BONUS); @@ -206,7 +205,7 @@ public Action:Cmd_MapBonusTop_Record(client, args) } } } - + return Plugin_Handled; } @@ -217,21 +216,21 @@ BonusTopStylePanel(client, String:sMapName[64]) new Handle:menu = CreateMenu(MenuHandler_BonusTopStylePanel); SetMenuTitle(menu, "Select Style", client); - + SetMenuExitButton(menu, true); - for(new i = 0; i < MAX_STYLES-1; i++) + for(new i = 0; i < MAX_STYLES-1; i++) { if(!g_Physics[i][StyleEnable]) continue; if(g_Physics[i][StyleCategory] != MCategory_Ranked) continue; - + new String:buffer[8]; IntToString(i, buffer, sizeof(buffer)); - + AddMenuItem(menu, buffer, g_Physics[i][StyleName]); - } + } Format(g_SelectedMap[client], 64, sMapName); DisplayMenu(menu, client, MENU_TIME_FOREVER); @@ -240,126 +239,38 @@ BonusTopStylePanel(client, String:sMapName[64]) public MenuHandler_BonusTopStylePanel(Handle:menu, MenuAction:action, client, itemNum) { - if (action == MenuAction_End) + if (action == MenuAction_End) { CloseHandle(menu); } - else if (action == MenuAction_Select) + else if (action == MenuAction_Select) { - decl String:info[8]; + decl String:info[8]; GetMenuItem(menu, itemNum, info, sizeof(info)); - - SQL_TopPanel(client, g_SelectedMap[client], StringToInt(info), TRACK_BONUS); - } -} - -/* Map Top Short */ - -public Action:Cmd_MapShortTop_Record(client, args) -{ - if(args < 1) - { - if(g_Settings[MultimodeEnable]) ReplyToCommand(client, "[SM] Usage: sm_sbtop