diff --git a/scripting/HnsMatchSystem.sma b/scripting/HnsMatchSystem.sma index c897e0b..e621c61 100644 --- a/scripting/HnsMatchSystem.sma +++ b/scripting/HnsMatchSystem.sma @@ -11,7 +11,7 @@ public plugin_precache() { } public plugin_init() { - register_plugin("Hide'n'Seek Match System", "1.0.9.4", "??"); // Спасибо: Cultura, Garey, Medusa, Ruffman, Conor + register_plugin("Hide'n'Seek Match System", "1.1.0", "??"); // Спасибо: Cultura, Garey, Medusa, Ruffman, Conor get_mapname(g_eMatchInfo[e_mMapName], charsmax(g_eMatchInfo[e_mMapName])); @@ -44,6 +44,7 @@ public plugin_init() { g_MsgSync = CreateHudSyncObj(); g_tPlayerInfo = TrieCreate(); + g_bFreezePeriod = true; register_dictionary("mixsystem.txt"); } @@ -142,6 +143,8 @@ public plugin_end() { public client_putinserver(id) { g_bOnOff[id] = false; + statsGetArray(id); + TrieGetArray(g_tPlayerInfo, getUserKey(id), g_ePlayerInfo[id], PlayerInfo_s); if (g_iCurrentMode == e_mMatch || g_iCurrentMode == e_mPaused) { if (g_ePlayerInfo[id][e_plrRetryGameStops] < g_iGameStops) { @@ -157,6 +160,7 @@ public client_putinserver(id) { public client_disconnected(id) { g_bHooked[id] = false; + statsSetArray(id); } public is_hooked(id) { @@ -237,6 +241,7 @@ public taskPrepareMode(mode) { } } restartRound(); + addStats(); } restartRound(Float:delay = 0.5) { @@ -271,8 +276,9 @@ stock loadMapCFG() { } ResetPlayerRoundData(id) { + resetStats(id); if (getUserTeam(id) == TEAM_TERRORIST) - g_ePlayerInfo[id][e_plrSurviveTime] -= g_eRoundInfo[id][e_rndSurviveTime]; + g_ePlayerInfo[id][e_plrSurviveTime] -= g_eRoundInfo[id][e_flSurviveTime]; } fnConvertTime(Float:time, convert_time[], len, bool:with_intpart = true) { diff --git a/scripting/include/hns-match/globals.inc b/scripting/include/hns-match/globals.inc index d1db44a..fcfd7ad 100644 --- a/scripting/include/hns-match/globals.inc +++ b/scripting/include/hns-match/globals.inc @@ -37,7 +37,13 @@ new g_ePlayerInfo[MAX_PLAYERS + 1][PlayerInfo_s]; enum _:RoundInfo_s { - Float:e_rndSurviveTime + Float:e_flSurviveTime, + Float:e_flDmg, + Float:e_flRunDistance, + Float:e_flFlashedTime, + Float:e_flHideTime, + e_iFound, + e_iStabs }; new g_eRoundInfo[MAX_PLAYERS + 1][RoundInfo_s]; @@ -88,7 +94,7 @@ new bool:g_bSpec[MAX_PLAYERS + 1]; new bool:g_bPlayersListLoaded; new bool:g_bLastFlash[MAX_PLAYERS + 1]; new bool:g_bOnOff[33]; - +new bool:g_bFreezePeriod = false; new Float:g_flRoundTime; new Float:g_flSidesTime[2]; diff --git a/scripting/include/hns-match/hook.inc b/scripting/include/hns-match/hook.inc index a9022d2..398f522 100644 --- a/scripting/include/hns-match/hook.inc +++ b/scripting/include/hns-match/hook.inc @@ -9,7 +9,9 @@ stock hook_init() { RegisterHookChain(RG_CBasePlayer_ResetMaxSpeed, "rgResetMaxSpeed", false); RegisterHookChain(RG_CSGameRules_RestartRound, "rgRestartRound", false); RegisterHookChain(RG_CSGameRules_OnRoundFreezeEnd, "rgOnRoundFreezeEnd", true); + RegisterHookChain(RG_CSGameRules_FlPlayerFallDamage, "rgFlPlayerFallDamage", true); RegisterHookChain(RG_CBasePlayer_Spawn, "rgPlayerSpawn", true); + RegisterHookChain(RG_CBasePlayer_TakeDamage, "rgTakeDamage", true); RegisterHookChain(RH_SV_DropClient, "rgDropClient", true); RegisterHookChain(RG_PlayerBlind, "rgPlayerBlind", false); RegisterHookChain(RG_CBasePlayer_MakeBomber, "rgPlayerMakeBomber", false); @@ -17,6 +19,12 @@ stock hook_init() { } public rgRoundEnd(WinStatus:status, ScenarioEventEndRound:event, Float:tmDelay) { + if (g_iCurrentMode == e_mMatch) { + if (!g_bFreezePeriod) { + statsApply(); + } + } + if (event == ROUND_TARGET_SAVED || event == ROUND_HOSTAGE_NOT_RESCUED) { SetHookChainArg(1, ATYPE_INTEGER, WINSTATUS_TERRORISTS); SetHookChainArg(2, ATYPE_INTEGER, ROUND_TERRORISTS_ESCAPED); @@ -116,6 +124,7 @@ public rgResetMaxSpeed(id) { public rgRestartRound() { remove_task(); + g_bFreezePeriod = true; if (g_bGameStarted) cmdShowTimers(0); @@ -159,6 +168,7 @@ public taskDestroyBreakables() { } public rgOnRoundFreezeEnd() { + g_bFreezePeriod = false; if (g_iCurrentMode != e_mMatch) return; @@ -167,10 +177,17 @@ public rgOnRoundFreezeEnd() { set_task(g_eCvars[e_cSemiclip] ? 3.0 : 5.0, "taskCheckAfk"); set_task(1.0, "task_ShowPlayerInfo", .flags = "b"); + set_task(2.5, "task_MainThink", .flags = "b"); set_task(0.25, "taskRoundEnd", .flags = "b"); } +public rgFlPlayerFallDamage(id) { + if (g_iCurrentMode == e_mMatch) { + statsDmg(id); + } +} + public taskRoundEnd() { if (g_bSurvival) { new iPlayers[32], count; @@ -188,7 +205,7 @@ public taskRoundEnd() { continue; g_ePlayerInfo[id][e_plrSurviveTime] += 0.25; - g_eRoundInfo[id][e_rndSurviveTime] += 0.25; + g_eRoundInfo[id][e_flSurviveTime] += 0.25; } if (g_flSidesTime[g_iCurrentSW] >= get_pcvar_float(g_eCvars[e_cCapTime]) * 60.0) { @@ -221,6 +238,7 @@ public taskRoundEnd() { } public rgPlayerSpawn(id) { + lastOrigin(id); if (!is_user_alive(id)) return; @@ -237,12 +255,20 @@ public rgPlayerSpawn(id) { setUserRole(id); } +public rgTakeDamage(victim, inflictor, attacker, Float:damage) { + if (g_iCurrentMode == e_mMatch) { + if (is_user_connected(attacker) && 1 <= attacker <= MAX_PLAYERS && getUserTeam(victim) != getUserTeam(attacker)) { + statsStabs(attacker); + } + } +} + public rgDropClient(const id, bool:crash) { if (!is_entity(id)) return; if ((getUserTeam(id) == TEAM_TERRORIST || getUserTeam(id) == TEAM_CT) && (g_iCurrentMode == e_mMatch || g_iCurrentMode == e_mPaused)) { - g_ePlayerInfo[id][e_plrRetryTime] = g_eRoundInfo[id][e_rndSurviveTime]; + g_ePlayerInfo[id][e_plrRetryTime] = g_eRoundInfo[id][e_flSurviveTime]; g_ePlayerInfo[id][e_plrRetryGameStops] = g_iGameStops; client_print_color(0, print_team_blue, "%L", 0, "PLR_DISC", prefix, id); @@ -251,6 +277,11 @@ public rgDropClient(const id, bool:crash) { } public rgPlayerBlind(const index, const inflictor, const attacker, const Float:fadeTime, const Float:fadeHold, const alpha, Float:color[3]) { + if (g_iCurrentMode == e_mMatch) { + if (getUserTeam(index) != getUserTeam(attacker)) + statsFlashedTime(attacker, fadeHold); + } + if (getUserTeam(index) == TEAM_TERRORIST || getUserTeam(index) == TEAM_SPECTATOR) return HC_SUPERCEDE; diff --git a/scripting/include/hns-match/showinfo.inc b/scripting/include/hns-match/showinfo.inc index 5872ca9..f77bc21 100644 --- a/scripting/include/hns-match/showinfo.inc +++ b/scripting/include/hns-match/showinfo.inc @@ -4,6 +4,121 @@ #define _showinfo_included +new Float:flLastOrigin[MAX_PLAYERS + 1][3]; +new bool:bHiding[MAX_PLAYERS + 1]; +new iStats[MAX_PLAYERS + 1][RoundInfo_s]; + +stock statsDmg(id) { + new Float:flDamage = GetHookChainReturn(ATYPE_FLOAT); + g_eRoundInfo[id][e_flDmg] += flDamage; +} + +stock statsFlashedTime(attacker, Float:fadeHold) { + g_eRoundInfo[attacker][e_flFlashedTime] += fadeHold; +} + +stock statsStabs(attacker) { + g_eRoundInfo[attacker][e_iStabs]++; +} + +stock lastOrigin(id) { + get_entvar(id, var_origin, flLastOrigin[id]); +} + +public task_MainThink() { + if(g_iCurrentMode != e_mMatch) + return; + + if (g_bFreezePeriod) + return; + + new tt_players[32], tt_num; + get_players(tt_players, tt_num, "ae", "TERRORIST"); + new ct_players[32], ct_num; + get_players(ct_players, ct_num, "ae", "CT"); + for (new i = 0; i < tt_num; i++) { + new tt = tt_players[i]; + new Float:origin[3]; + get_entvar(tt, var_origin, origin); + g_eRoundInfo[tt][e_flRunDistance] += get_distance_f(origin, flLastOrigin[tt]); + flLastOrigin[tt] = origin; + new bool:found = false; + for (new j = 0; j < ct_num; j++) { + new ct = ct_players[j]; + if (fm_is_ent_visible(ct, tt) && fm_is_in_viewcone(ct, origin)) { + if (bHiding[tt]) { + g_eRoundInfo[ct][e_iFound]++; + } + found = true; + bHiding[tt] = false; + break; + } + } + if (!found) + bHiding[tt] = true; + + if (bHiding[tt]) { + g_eRoundInfo[tt][e_flHideTime] += 2.5; + } + } +} + +statsGetArray(id) { + TrieGetArray(g_tPlayerInfo, getUserKey(id), iStats[id], RoundInfo_s); +} + +statsSetArray(id) { + TrieSetArray(g_tPlayerInfo, getUserKey(id), iStats[id], RoundInfo_s); +} + +statsApply() { + apply_stats(); +} + +addStats() { + for (new i = 1; i <= MaxClients; i++) { + arrayset(iStats[i], 0, RoundInfo_s); + } + + for(new i; i < 10; i++) { + g_iBestAuth[i] = ""; + } +} + +resetStats(id) { + arrayset(g_eRoundInfo[id], 0, RoundInfo_s); +} + +public apply_stats() { + new tt_players[32], tt_num; + get_players(tt_players, tt_num, "ce", "TERRORIST"); + new ct_players[32], ct_num; + get_players(ct_players, ct_num, "ce", "CT"); + for (new i = 0; i < tt_num; i++) { + new id = tt_players[i]; + iStats[id][e_flSurviveTime] = g_ePlayerInfo[id][e_plrSurviveTime]; + iStats[id][e_flDmg] += g_eRoundInfo[id][e_flDmg]; + iStats[id][e_flRunDistance] += g_eRoundInfo[id][e_flRunDistance]; + iStats[id][e_flFlashedTime] += g_eRoundInfo[id][e_flFlashedTime]; + iStats[id][e_flHideTime] += g_eRoundInfo[id][e_flHideTime]; + iStats[id][e_iFound] += g_eRoundInfo[id][e_iFound]; + iStats[id][e_iStabs] += g_eRoundInfo[id][e_iStabs]; + arrayset(g_eRoundInfo[id], 0, RoundInfo_s); + } + + for (new i = 0; i < ct_num; i++) { + new id = ct_players[i]; + iStats[id][e_flSurviveTime] = g_ePlayerInfo[id][e_plrSurviveTime]; + iStats[id][e_flDmg] += g_eRoundInfo[id][e_flDmg]; + iStats[id][e_flRunDistance] += g_eRoundInfo[id][e_flRunDistance]; + iStats[id][e_flFlashedTime] += g_eRoundInfo[id][e_flFlashedTime]; + iStats[id][e_flHideTime] += g_eRoundInfo[id][e_flHideTime]; + iStats[id][e_iFound] += g_eRoundInfo[id][e_iFound]; + iStats[id][e_iStabs] += g_eRoundInfo[id][e_iStabs]; + arrayset(g_eRoundInfo[id], 0, RoundInfo_s); + } +} + public task_ShowPlayerInfo() { if(g_iCurrentMode != e_mMatch) return; @@ -17,7 +132,6 @@ public task_ShowPlayerInfo() { if(is_user_alive(iPlayer)) { if(g_iCurrentMode == e_mMatch) { new szTime[24]; - fnConvertTime(g_ePlayerInfo[iPlayer][e_plrSurviveTime], szTime, charsmax(szTime), false); set_hudmessage( .red = 100, .green = 100, .blue = 100, .x = 0.01, .y = 0.20, .holdtime = 1.0); ShowSyncHudMsg(iPlayer, g_MsgSync, "Survive time: %s", szTime); @@ -33,11 +147,32 @@ public task_ShowPlayerInfo() { if(get_entvar(iPlayer, var_iuser2) == id) { new szTime[24], szBuffer[64]; - + new szTimeFlash[24], szBuffer2[64]; + if(g_iCurrentMode == e_mMatch) { fnConvertTime(g_ePlayerInfo[id][e_plrSurviveTime], szTime, charsmax(szTime), false); formatex(szBuffer, charsmax(szBuffer), "Survive time: %s", szTime); + + fnConvertTime(iStats[iPlayer][e_flFlashedTime], szTimeFlash, charsmax(szTimeFlash), false); + formatex(szBuffer2, charsmax(szBuffer2), "Damaged: %.0fHP^n\ + Flashed: %s^n\ + Found TT: %d^n\ + Stabs: %d^n\ + Run: %.1fK", + iStats[iPlayer][e_flDmg], + szTimeFlash, + iStats[iPlayer][e_iFound], + iStats[iPlayer][e_iStabs], + iStats[iPlayer][e_flRunDistance] / 1000); } + + set_hudmessage(.red = 100, .green = 100, .blue = 100, .x = 0.01, .y = 0.20, .holdtime = 1.0); + ShowSyncHudMsg(iPlayer, g_MsgSync, "Игрок: %n^n\ + %s^n\ + %s", + id, + g_iCurrentMode == e_mMatch ? szBuffer : "", + g_iCurrentMode == e_mMatch ? szBuffer2 : ""); } } } @@ -45,6 +180,7 @@ public task_ShowPlayerInfo() { public ShowTop(player) { if (!player) { + apply_stats(); new Float:flBestTime[10]; new iPlayers[MAX_PLAYERS], iNum; get_players(iPlayers, iNum, "c"); @@ -127,18 +263,28 @@ public ShowTop(player) { \ Player\ Survive time\ + Damaged\ + Hide time\ + Flashed\ + Found TT\ + Stabs\ + Run\ \ \ "); new szSurvTime[24]; + new szTimeFlash[24]; + new szHideTime[24]; for (new i = 0; i < 10; i++) { new id = find_player_ex(FindPlayer_MatchAuthId, g_iBestAuth[i]); if (!is_user_connected(id)) continue; - fnConvertTime(g_ePlayerInfo[id][e_plrSurviveTime], szSurvTime, 23); - iLen += formatex(szMotd[iLen], charsmax(szMotd) - iLen, "%n%s", id, szSurvTime); + fnConvertTime(iStats[id][e_plrSurviveTime], szSurvTime, charsmax(szSurvTime), false); + fnConvertTime(iStats[id][e_flFlashedTime], szTimeFlash, charsmax(szTimeFlash), false); + fnConvertTime(iStats[id][e_flHideTime], szHideTime, charsmax(szHideTime), false); + iLen += formatex(szMotd[iLen], charsmax(szMotd) - iLen, "%n%s%.0f%s%s%d%d%.1fK", id, szSurvTime, iStats[id][e_flDmg],szHideTime, szTimeFlash, iStats[id][e_iFound], iStats[id][e_iStabs], iStats[id][e_flRunDistance] / 1000); } iLen += formatex(szMotd[iLen], charsmax(szMotd) - iLen, "\ \ @@ -146,5 +292,5 @@ public ShowTop(player) { \ "); show_motd(player, szMotd); - //log_to_file("motd.txt", szMotd); + log_to_file("motd.txt", szMotd); }