файлами лучше воспользуйся, которые я в лс кидал...
Поблагодарили 0 раз Поблагодарили 0 раз
Caution666
9.1.2014, 17:58
Сообщение
Стаж: 12 лет
Сообщений: 179
Благодарностей: 3
Полезность: 22
Цитата(Esecman @ 9.1.2014, 19:20)
файлами лучше воспользуйся, которые я в лс кидал...
да я конечно воспользовался,но все также все прекрасно в первом раунде работает,как второй,так начинается
Поблагодарили 0 раз Поблагодарили 0 раз
Caution666
10.1.2014, 13:49
Сообщение
Стаж: 12 лет
Сообщений: 179
Благодарностей: 3
Полезность: 22
Что никто не поможет ?
Поблагодарили 0 раз Поблагодарили 0 раз
Esecman
10.1.2014, 14:06
Сообщение
Стаж: 12 лет
Сообщений: 945
Благодарностей: 208
Полезность: 0
Цитата(Caution666 @ 9.1.2014, 18:58)
да я конечно воспользовался,но все также все прекрасно в первом раунде работает,как второй,так начинается
ага ага.. ничего ты не скачал. омг... не хочешь платить - не плати.
Поблагодарили 0 раз Поблагодарили 0 раз
Caution666
10.1.2014, 17:07
Сообщение
Стаж: 12 лет
Сообщений: 179
Благодарностей: 3
Полезность: 22
Цитата(Esecman @ 10.1.2014, 16:06)
ага ага.. ничего ты не скачал. омг... не хочешь платить - не плати.
я серьезно все скачал,что ты мне скинул,ну ничего все также! могу показать если не веришь,и врать я не буду,обещал так обещал скинуть денежку
Поблагодарили 0 раз Поблагодарили 0 раз
Esecman
10.1.2014, 18:31
Сообщение
Стаж: 12 лет
Сообщений: 945
Благодарностей: 208
Полезность: 0
Цитата(Caution666 @ 10.1.2014, 18:07)
я серьезно все скачал,что ты мне скинул,ну ничего все также! могу показать если не веришь,и врать я не буду,обещал так обещал скинуть денежку
Оффтоп: ты на ссылки зайди-то :0 Ни одного скачивания, ты молодец :)
Поблагодарили 0 раз Поблагодарили 0 раз
leshiy
13.4.2015, 7:04
Сообщение
Стаж: 12 лет
Сообщений: 82
Благодарностей: 19
Полезность: 156
Ребята, помогите, пожалуйста, исправить ошибки. L 04/10/2015 - 00:06:52: [AMXX] Displaying debug trace (plugin "statsx_shell.amxx") L 04/10/2015 - 00:06:52: [AMXX] Run time error 4: index out of bounds L 04/10/2015 - 00:06:52: [AMXX] [0] statsx_shell.sma::colorChat (line 4068) L 04/10/2015 - 00:06:52: [AMXX] [1] statsx_shell.sma::cmdStatsMe (line 2466) L 04/10/2015 - 00:06:52: [AMXX] [2] statsx_shell.sma::end_game_stats (line 3693)
Я не шарю в скриптинге, но пытался переделать плагин, чтобы вместо /top15 работала команда /top10. Вроде бы все получилось, в игре все работает так, как я хотел. Но видимо, я не везде подправил, что нужно, и теперь в конце карты не показывается статистика. Для меня не критично, просто ошибка в логах глаза мозолит :-) . Исходник в виде текста сюда не помещается, т.к. превышает количество допустимых символов.
statsx_shell.sma
Код:
/* *================================ * Название: statsx_shell * Версия : 2.0.0 (BETA) * Код: AMX Dev Team * Доработка: MastaMan * ---------------------- * Доступные языки: RU, UA, EN * * Источник: * ================================ */ /* AMX Mod X * StatsX Plugin * * by the AMX Mod X Development Team * originally developed by OLO * * This file is part of AMX Mod X. * * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at * your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, the author gives permission to * link the code of this program with the Half-Life Game Engine ("HL * Engine") and Modified Game Libraries ("MODs") developed by Valve, * L.L.C ("Valve"). You must obey the GNU General Public License in all * respects for all of the code used other than the HL Engine and MODs * from Valve. If you modify this file, you may extend this exception * to your version of the file, but you are not obligated to do so. If * you do not wish to do so, delete this exception statement from your * version. */
// HUD statistics stop relative freeze end in seconds. // To stop before freeze end use a negative value. #define HUD_FREEZE_LIMIT_CVAR "amx_statsx_freeze" #define HUD_FREEZE_LIMIT "-2.0"
// HUD statistics minimum duration, in seconds, to trigger the display logic. #define HUD_MIN_DURATION 0.2
// Config plugin constants. #define MODE_HUD_DELAY 0 // Make a 0.01 sec delay on HUD reset process.
// You can also manualy enable or disable these options by setting them to 1 // For example: // public ShowAttackers = 1 // However amx_statscfg command is recommended
public KillerChat = 0 // displays killer hp&ap to victim console // and screen
public ShowAttackers = 0 // shows attackers public ShowVictims = 0 // shows victims public ShowKiller = 0 // shows killer public ShowTeamScore = 0 // shows team score at round end public ShowTotalStats = 0 // shows round total stats public ShowBestScore = 0 // shows rounds best scored player public ShowMostDisruptive = 0 // shows rounds most disruptive player
public EndPlayer = 0 // displays player stats at the end of map public EndTop10 = 0 // displays top10 at the end of map
public SayHP = 0 // displays information about user killer public SayStatsMe = 0 // displays user's stats and rank public SayRankStats = 0 // displays user's rank stats public SayMe = 0 // displays user's stats public SayRank = 0 // displays user's rank public SayReport = 0 // report user's weapon status to team public SayScore = 0 // displays team's map score public SayTop10 = 0 // displays first 10 players public SayStatsAll = 0 // displays all players stats and rank
public ShowStats = 1 // set client HUD-stats switched off by default public ShowDistHS = 0 // show distance and HS in attackers and // victims HUD lists public ShowFullStats = 0 // show full HUD stats (more than 78 chars)
public SpecRankInfo = 0 // displays rank info when spectating
// Killer information, save killer info at the time when player is killed. #define KILLED_KILLER_ID 0 // Killer userindex/user-ID #define KILLED_KILLER_HEALTH 1 // Killer's health #define KILLED_KILLER_ARMOUR 2 // Killer's armour #define KILLED_TEAM 3 // Killer's team #define KILLED_KILLER_STATSFIX 4 // Fix to register the last hit/kill
new g_izKilled[MAX_PLAYERS][5]
// Menu variables and configuration #define MAX_PPL_MENU_ACTIONS 2 // Number of player menu actions #define PPL_MENU_OPTIONS 7 // Number of player options per displayed menu
new g_iPluginMode = 0
new g_izUserMenuPosition[MAX_PLAYERS] = {0, ...} new g_izUserMenuAction[MAX_PLAYERS] = {0, ...} new g_izUserMenuPlayers[MAX_PLAYERS][32]
new g_izSpecMode[MAX_PLAYERS] = {0, ...}
new g_izShowStatsFlags[MAX_PLAYERS] = {0, ...} new g_izStatsSwitch[MAX_PLAYERS] = {0, ...} new Float:g_fzShowUserStatsTime[MAX_PLAYERS] = {0.0, ...} new Float:g_fShowStatsTime = 0.0 new Float:g_fFreezeTime = 0.0 new Float:g_fFreezeLimitTime = 0.0 new Float:g_fHUDDuration = 0.0
new g_iRoundEndTriggered = 0 new g_iRoundEndProcessed = 0
new Float:g_fStartGame = 0.0 new g_izTeamScore[MAX_TEAMS] = {0, ...} new g_izTeamEventScore[MAX_TEAMS] = {0, ...} new g_izTeamRndStats[MAX_TEAMS][8] new g_izTeamGameStats[MAX_TEAMS][8] new g_izUserUserID[MAX_PLAYERS] = {0, ...} new g_izUserAttackerDistance[MAX_PLAYERS] = {0, ...} new g_izUserVictimDistance[MAX_PLAYERS][MAX_PLAYERS] new g_izUserRndName[MAX_PLAYERS][MAX_NAME_LENGTH + 1] new g_izUserRndStats[MAX_PLAYERS][8] new g_izUserGameStats[MAX_PLAYERS][8]
// Common buffer to improve performance, as Small always zero-initializes all vars new g_sBuffer[MAX_BUFFER_LENGTH + 1] = "" new g_sScore[MAX_TEXT_LENGTH + 1] = "" new g_sAwardAndScore[MAX_BUFFER_LENGTH + 1] = ""
new t_sText[MAX_TEXT_LENGTH + 1] = "" new t_sName[MAX_NAME_LENGTH + 1] = "" new t_sWpn[MAX_WEAPON_LENGTH + 1] = ""
server_print(" ") server_print("########################################################################### ####") server_print("^tTitle : StatsX Shell (Ultimate StatsX)") server_print("^tVersion: %s", STATSX_SHELL_VER) server_print("^tAuthor : AMX MOD X DEV TEAM") server_print("^tEdited : MastaMan") server_print("^tSite : server_print(" ") server_print("------------------------------------------------------------------------------") server_print(" ") if(file_exists(szCfgDir)) { server_print("[%s] > Load settings from: statsx_shell.cfg", Time) } else { server_print("[%s] > Not found: statsx_shell.cfg ........................... [ERROR]", Time) server_print(" ") server_print("> Please reinstall plugin statsx_shell.amxx for ") server_print(" solve this problem or check your cfg!") server_print(" ") server_print("> Visit www.amx-server.blogspot.com for check new version and more info...") server_print(" ") server_print("########################################################################### ####")
//log_amx("Not found: statsx_shell.cfg")
return PLUGIN_CONTINUE } server_print(" ")
new szData[MAX_TEXT_LENGTH], i new bool:bERROR_MESSAGE, szERROR_MESSAGE[70] new file = fopen(szCfgDir, "rt") while(!feof(file)) { new bool:g_bERROR_MESSAGE_TYPE1 = true new bool:g_bERROR_MESSAGE_TYPE2 = true
public client_putinserver(id) { if(get_pcvar_num(pcvar_connect_message)) { set_task(2.5, "connect_message_anonce", id) } }
public connect_message_anonce(id) { new szName[32], szKey[50], szData[128], szHUDMessage[512] new szHour[5], szDay[5], szMonth[5] new izStats[8], izBody[8], szHostname[64] new iHour, iDay, iMonth new iLen = 0 new iColor_R, iColor_G, iColor_B, g_pcvarColor
// Get and format attackers header and list. get_attackers(id, sBuffer[MAX_BUFFER_LENGTH + 1]) { new izStats[8], izBody[8] new iAttacker new iFound, iLen new iMaxPlayer = get_maxplayers()
iFound = 0 sBuffer[0] = 0
// Get and format header. Add killing attacker statistics if user is dead. // Make sure shots is greater than zero or division by zero will occur. // To print a '%', 4 of them must done in a row. izStats[STATS_SHOTS] = 0 iAttacker = g_izKilled[id][KILLED_KILLER_ID]
if (iAttacker) get_user_astats(id, iAttacker, izStats, izBody)
// Get and format victims header and list get_victims(id, sBuffer[MAX_BUFFER_LENGTH + 1]) { new izStats[8], izBody[8] new iVictim new iFound, iLen new iMaxPlayer = get_maxplayers()
iFound = 0 sBuffer[0] = 0
// Get and format header. // Make sure shots is greater than zero or division by zero will occur. // To print a '%', 4 of them must done in a row. izStats[STATS_SHOTS] = 0 get_user_vstats(id, 0, izStats, izBody)
// Get and format team score. add_team_score(sBuffer[MAX_BUFFER_LENGTH + 1]) { new Float:fzMapEff[MAX_TEAMS], Float:fzMapAcc[MAX_TEAMS], Float:fzRndAcc[MAX_TEAMS]
// Calculate team stats for (new iTeam = 0; iTeam < MAX_TEAMS; iTeam++) { fzMapEff[iTeam] = effec(g_izTeamGameStats[iTeam]) fzMapAcc[iTeam] = accuracy(g_izTeamGameStats[iTeam]) fzRndAcc[iTeam] = accuracy(g_izTeamRndStats[iTeam]) }
// Get and format killed stats: hits, damage on killer. format_kill_vinfo(id, iKiller, sBuffer[MAX_BUFFER_LENGTH + 1]) { new iFound = 0 new izStats[8] new izBody[8] new iLen
// MastaMan Edition format_award(sBuffer[MAX_BUFFER_LENGTH + 1]) { new izStats[8], izBody[8], szName[3][MAX_NAME_LENGTH], id new iLen = 0 new Float:izAwardCash_Bonus[3], Float:izAwardSkil_Level[3], izCash
new lBonus[30]
format(lBonus, 29, "%L", LANG_SERVER, "MM_BONUS")
iLen = format_all_themes(sBuffer, iLen)
id = iAwardID for(new i = 0; i < 3; i++) { get_stats(id, izStats, izBody, t_sName, MAX_NAME_LENGTH) replace_all(t_sName, MAX_NAME_LENGTH, "<", "<") replace_all(t_sName, MAX_NAME_LENGTH, ">", ">")
// Show round end stats. If gametime is zero then use default duration time. show_roundend_hudstats(id, Float:fGameTime) { // Bail out if there no HUD stats should be shown // for this player or end round stats not created. if (!g_izStatsSwitch[id]) return if (!g_sAwardAndScore[0]) return
// If round end timer is zero clear round end stats. if (g_fShowStatsTime == 0.0) { ClearSyncHud(id, g_HudSync_EndRound) #if defined STATSX_DEBUG log_amx("Clear round end HUD stats for #%d", id) #endif }
// Set HUD-duration to default or remaining time. new Float:fDuration
// Show stats only if more time left than coded minimum. if (fDuration >= HUD_MIN_DURATION) { set_hudtype_endround(fDuration) ShowSyncHudMsg(id, g_HudSync_EndRound, "%s", g_sAwardAndScore) #if defined STATSX_DEBUG log_amx("Show %1.2fs round end HUD stats for #%d", fDuration, id) #endif } }
// Show round end stats. show_user_hudstats(id, Float:fGameTime) { // Bail out if there no HUD stats should be shown // for this player or user stats timer is zero. if (!g_izStatsSwitch[id]) return if (g_fzShowUserStatsTime[id] == 0.0) return
// Set HUD-duration to default or remaining time. new Float:fDuration
// Report user weapon status to team. public cmdReport(id) { if (!SayReport) { colorChat(id, CHATCOLOR_RED, "%L", id, "DISABLED_MSG") return PLUGIN_HANDLED }
new iWeapon, iClip, iAmmo, iHealth, iArmor
iWeapon = get_user_weapon(id, iClip, iAmmo)
if (iWeapon != 0) xmod_get_wpnname(iWeapon, t_sWpn, MAX_WEAPON_LENGTH)
// Player stats menu. public cmdStats(id) { if (!SayStatsAll) { colorChat(id, CHATCOLOR_RED, "%L", id, "DISABLED_MSG") return PLUGIN_HANDLED }
showStatsMenu(id, g_izUserMenuPosition[id] = 0)
return PLUGIN_CONTINUE }
//-------------------------------- // Menu //--------------------------------
public actionStatsMenu(id, key) { switch (key) { // Key '1' to '7', execute action on this option case 0..6: { new iOption, iIndex iOption = (g_izUserMenuPosition[id] * PPL_MENU_OPTIONS) + key
if (g_izUserMenuAction[id] >= MAX_PPL_MENU_ACTIONS) g_izUserMenuAction[id] = 0
showStatsMenu(id, g_izUserMenuPosition[id]) } // Key '9', select next page of options case 8: showStatsMenu(id, ++g_izUserMenuPosition[id]) // Key '10', cancel or go back to previous menu case 9: { if (g_izUserMenuPosition[id] > 0) showStatsMenu(id, --g_izUserMenuPosition[id]) } }
return PLUGIN_HANDLED }
new g_izUserMenuActionText[MAX_PPL_MENU_ACTIONS][62]
// Round start public eventStartRound() { new iTeam, id, i
if (read_data(1) >= floatround(get_cvar_float("mp_roundtime") * 60.0,floatround_floor)) {
#if defined STATSX_DEBUG log_amx("Reset round stats") #endif
// Reset game stats on game start and restart. if (g_fStartGame > 0.0 && g_fStartGame <= get_gametime()) { #if defined STATSX_DEBUG log_amx("Reset game stats") #endif
g_fStartGame = 0.0
// Clear team and game stats. for (iTeam = 0; iTeam < MAX_TEAMS; iTeam++) { g_izTeamEventScore[iTeam] = 0
for (i = 0; i < 8; i++) g_izTeamGameStats[iTeam][i] = 0 }
// Clear game stats, incl '0' that is sum of all users. for (id = 0; id < MAX_PLAYERS; id++) { for (i = 0; i < 8; i++) g_izUserGameStats[id][i] = 0 } }
// Update team score with "TeamScore" event values and // clear team round stats. for (iTeam = 0; iTeam < MAX_TEAMS; iTeam++) { g_izTeamScore[iTeam] = g_izTeamEventScore[iTeam]
for (i = 0; i < 8; i++) g_izTeamRndStats[iTeam][i] = 0 }
// Clear user round stats, incl '0' that is sum of all users. for (id = 0; id < MAX_PLAYERS; id++) { g_izUserRndName[id][0] = 0
for (i = 0; i < 8; i++) g_izUserRndStats[id][i] = 0
g_fzShowUserStatsTime[id] = 0.0 }
// Allow end round stats and reset end round triggered indicator. g_iRoundEndTriggered = 0 g_iRoundEndProcessed = 0 g_fShowStatsTime = 0.0
// Update local configuration vars with value in cvars. get_config_cvars() }
return PLUGIN_CONTINUE }
// Reset killer info on round restart. public eventResetHud(id) { new args[1] args[0] = id
public delay_resethud(args[]) { new id = args[0] new Float:fGameTime
// Show user and score round stats after HUD-reset #if defined STATSX_DEBUG log_amx("Reset HUD for #%d", id) #endif fGameTime = get_gametime() show_user_hudstats(id, fGameTime) show_roundend_hudstats(id, fGameTime)
for (new i = 0; i < MAX_PLAYERS; i++) g_izUserVictimDistance[id][i] = 0
return PLUGIN_CONTINUE }
// Save killer info on death. public client_death(killer, victim, wpnindex, hitplace, TK) { // Bail out if no killer. if (!killer) return PLUGIN_CONTINUE
if (killer != victim) { new iaVOrigin[3], iaKOrigin[3] new iDistance
// Display kill stats for the player if round // end stats was not processed. if (!g_iRoundEndProcessed) kill_stats(victim)
return PLUGIN_CONTINUE }
// Display hudmessage stats on death. // This will also update all round and game stats. // Must be called at least once per round. kill_stats(id) { // Bail out if user stats timer is non-zero, // ie function already called. if (g_fzShowUserStatsTime[id] > 0.0) { return }
new team = get_user_team(id) if (team < 1 || team > 2) { return }
// Flag kill stats displayed for this player. g_fzShowUserStatsTime[id] = get_gametime()
// Add user death stats to user round stats new izStats[8], izBody[8] new iTeam, i new iKiller
iKiller = g_izKilled[id][KILLED_KILLER_ID]
// Get user's team (if dead use the saved team) if (iKiller) iTeam = g_izKilled[id][KILLED_TEAM] - 1 else iTeam = get_user_team(id) - 1
if (get_user_rstats(id, izStats, izBody)) { // Update user's team round stats if (iTeam >= 0 && iTeam < MAX_TEAMS) { for (i = 0; i < 8; i++) { g_izTeamRndStats[iTeam][i] += izStats[i] g_izTeamGameStats[iTeam][i] += izStats[i] g_izUserRndStats[0][i] += izStats[i] g_izUserGameStats[0][i] += izStats[i] } }
// Update user's round stats if (g_izUserUserID[id] == get_user_userid(id)) { for (i = 0; i < 8; i++) { g_izUserRndStats[id][i] += izStats[i] g_izUserGameStats[id][i] += izStats[i] } } else { g_izUserUserID[id] = get_user_userid(id)
for (i = 0; i < 8; i++) { g_izUserRndStats[id][i] = izStats[i] g_izUserGameStats[id][i] = izStats[i] } }
} // endif (get_user_rstats())
// Report stats in the chat section, if player is killed. if (KillerChat && iKiller && iKiller != id) { if (format_kill_ainfo(id, iKiller, g_sBuffer)) { colorChat(id, CHATCOLOR_GREEN, "* %s", g_sBuffer) format_kill_vinfo(id, iKiller, g_sBuffer) }
public time_play_bonus() { if(!get_pcvar_num(pcvar_pt_bonus) || !get_pcvar_num(pcvar_pt)) { return PLUGIN_HANDLED }
new iCash, iTmpCash, iDay, szDay[5] new szPlayers[32], iNum, szName[32] new szKey[50], szData[128]
new iCash_1h = get_pcvar_num(pcvar_pt_bonus_1h) new iCash_2h = get_pcvar_num(pcvar_pt_bonus_2h) new iCash_3h = get_pcvar_num(pcvar_pt_bonus_3h) new iCash_4h = get_pcvar_num(pcvar_pt_bonus_4h) new iCash_5h = get_pcvar_num(pcvar_pt_bonus_5h)
public day_stat_clear() { new szDate[5], szKey[6] format_time(szDate, sizeof(szDate) - 1, "%d")
for(new i = 0; i < 24; i++) { formatex(szKey, 5, "%d-h", i) nvault_set(g_Vault , szKey , "0") }
nvault_set(g_Vault , "DAY" , szDate)
return PLUGIN_CONTINUE }
public ERTask() { // Flag round end triggered. g_iRoundEndTriggered = 1
// Display round end stats to all players. endround_stats() }
endround_stats() { // Bail out if end round stats has already been processed // or round end not triggered. if (g_iRoundEndProcessed || !g_iRoundEndTriggered) return
new iaPlayers[32], iPlayer, iPlayers, id
get_players(iaPlayers, iPlayers)
// Display attacker & victim list for all living players. // This will also update all round and game stats for all players // not killed. #if defined STATSX_DEBUG log_amx("End round stats") #endif
for (iPlayer = 0; iPlayer < iPlayers; iPlayer++) { id = iaPlayers[iPlayer]
if (g_fzShowUserStatsTime[id] == 0.0) { kill_stats(id) } }
g_sAwardAndScore[0] = 0
// Create round awards. if (ShowMostDisruptive) add_most_disruptive(g_sAwardAndScore) if (ShowBestScore) add_best_score(g_sAwardAndScore)
// Create round score. // Compensate HUD message if awards are disabled. if (ShowTeamScore || ShowTotalStats) { if (ShowMostDisruptive && ShowBestScore) add(g_sAwardAndScore, MAX_BUFFER_LENGTH, "^n^n") else if (ShowMostDisruptive || ShowBestScore) add(g_sAwardAndScore, MAX_BUFFER_LENGTH, "^n^n^n^n") else add(g_sAwardAndScore, MAX_BUFFER_LENGTH, "^n^n^n^n^n^n")
if (ShowTeamScore) add_team_score(g_sAwardAndScore)
if (ShowTotalStats) add_total_stats(g_sAwardAndScore) }
save_team_chatscore()
// Get and save round end stats time. g_fShowStatsTime = get_gametime()
// Display round end stats to all players. for (iPlayer = 0; iPlayer < iPlayers; iPlayer++) { id = iaPlayers[iPlayer] show_roundend_hudstats(id, 0.0) }
// Flag round end processed. g_iRoundEndProcessed = 1 }
/* Thanks for Damaged Soul for finding the information on how to do this.
This is code snippets I find useful.
^x01 is Yellow ^x03 is Team Color. Ie. Red (Terrorist) or blue (Counter-Terrorist) or grey (SPECTATOR or UNASSIGNED). ^x04 is Green
The colors red, grey, and blue can't be used on the same line. This is not possible at all to do.
Also there are limitation to using Red or Grey while on the TEAM CT. You would have to do for example if they were on CT.
ColorChat(0, RED, "%s, ^x01This color is yellow. ^x03This color is red. ^x04This color is green.);
You have to set the Type to RED because of certain messages that need to be sent out so a person on the team CT can be sent red colors.
Some important information. When using MSG_ALL to send color message to all clients and your going to use blue/grey/red color sending the TeamInfo Message to tempoary change the player team to achieve this. You must send that message in MSG_ALL also. If your going to only send it to one person. You need to MSG_ONE on TeamInfo and SayText. (Thanks to CheapSuit I was able to see their was an error and fix it).
*/
colorChat(id, ChatColor:color, const msg[], {Float,Sql,Result,_}:...) { new team, index, MSG_Type new bool:teamChanged = false static message[192]
switch(color) { case CHATCOLOR_NORMAL: // Normal { message[0] = 0x01; } case CHATCOLOR_GREEN: // Green { message[0] = 0x04; } default: // Grey, Red, Blue { message[0] = 0x03; } }
for (new a = 0; a < inum; a++) { pid = players[a] if(is_user_connected(pid)) return pid }
return 0 }
Поблагодарили 0 раз Поблагодарили 0 раз
leshiy
13.4.2015, 8:04
Сообщение
Стаж: 12 лет
Сообщений: 82
Благодарностей: 19
Полезность: 156
statsx_shell.sma
Код:
/* *================================ * Название: statsx_shell * Версия : 2.0.0 (BETA) * Код: AMX Dev Team * Доработка: MastaMan * ---------------------- * Доступные языки: RU, UA, EN * * Источник: http://amx-server.blogspot.com * ================================ */ /* AMX Mod X * StatsX Plugin * * by the AMX Mod X Development Team * originally developed by OLO * * This file is part of AMX Mod X. * * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at * your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, the author gives permission to * link the code of this program with the Half-Life Game Engine ("HL * Engine") and Modified Game Libraries ("MODs") developed by Valve, * L.L.C ("Valve"). You must obey the GNU General Public License in all * respects for all of the code used other than the HL Engine and MODs * from Valve. If you modify this file, you may extend this exception * to your version of the file, but you are not obligated to do so. If * you do not wish to do so, delete this exception statement from your * version. */
// HUD statistics stop relative freeze end in seconds. // To stop before freeze end use a negative value. #define HUD_FREEZE_LIMIT_CVAR "amx_statsx_freeze" #define HUD_FREEZE_LIMIT "-2.0"
// HUD statistics minimum duration, in seconds, to trigger the display logic. #define HUD_MIN_DURATION 0.2
// Config plugin constants. #define MODE_HUD_DELAY 0 // Make a 0.01 sec delay on HUD reset process.
// You can also manualy enable or disable these options by setting them to 1 // For example: // public ShowAttackers = 1 // However amx_statscfg command is recommended
public KillerChat = 0 // displays killer hp&ap to victim console // and screen
public ShowAttackers = 0 // shows attackers public ShowVictims = 0 // shows victims public ShowKiller = 0 // shows killer public ShowTeamScore = 0 // shows team score at round end public ShowTotalStats = 0 // shows round total stats public ShowBestScore = 0 // shows rounds best scored player public ShowMostDisruptive = 0 // shows rounds most disruptive player
public EndPlayer = 0 // displays player stats at the end of map public EndTop10 = 0 // displays top10 at the end of map
public SayHP = 0 // displays information about user killer public SayStatsMe = 0 // displays user's stats and rank public SayRankStats = 0 // displays user's rank stats public SayMe = 0 // displays user's stats public SayRank = 0 // displays user's rank public SayReport = 0 // report user's weapon status to team public SayScore = 0 // displays team's map score public SayTop10 = 0 // displays first 10 players public SayStatsAll = 0 // displays all players stats and rank
public ShowStats = 1 // set client HUD-stats switched off by default public ShowDistHS = 0 // show distance and HS in attackers and // victims HUD lists public ShowFullStats = 0 // show full HUD stats (more than 78 chars)
public SpecRankInfo = 0 // displays rank info when spectating
// Killer information, save killer info at the time when player is killed. #define KILLED_KILLER_ID 0 // Killer userindex/user-ID #define KILLED_KILLER_HEALTH 1 // Killer's health #define KILLED_KILLER_ARMOUR 2 // Killer's armour #define KILLED_TEAM 3 // Killer's team #define KILLED_KILLER_STATSFIX 4 // Fix to register the last hit/kill
new g_izKilled[MAX_PLAYERS][5]
// Menu variables and configuration #define MAX_PPL_MENU_ACTIONS 2 // Number of player menu actions #define PPL_MENU_OPTIONS 7 // Number of player options per displayed menu
new g_iPluginMode = 0
new g_izUserMenuPosition[MAX_PLAYERS] = {0, ...} new g_izUserMenuAction[MAX_PLAYERS] = {0, ...} new g_izUserMenuPlayers[MAX_PLAYERS][32]
new g_izSpecMode[MAX_PLAYERS] = {0, ...}
new g_izShowStatsFlags[MAX_PLAYERS] = {0, ...} new g_izStatsSwitch[MAX_PLAYERS] = {0, ...} new Float:g_fzShowUserStatsTime[MAX_PLAYERS] = {0.0, ...} new Float:g_fShowStatsTime = 0.0 new Float:g_fFreezeTime = 0.0 new Float:g_fFreezeLimitTime = 0.0 new Float:g_fHUDDuration = 0.0
new g_iRoundEndTriggered = 0 new g_iRoundEndProcessed = 0
new Float:g_fStartGame = 0.0 new g_izTeamScore[MAX_TEAMS] = {0, ...} new g_izTeamEventScore[MAX_TEAMS] = {0, ...} new g_izTeamRndStats[MAX_TEAMS][8] new g_izTeamGameStats[MAX_TEAMS][8] new g_izUserUserID[MAX_PLAYERS] = {0, ...} new g_izUserAttackerDistance[MAX_PLAYERS] = {0, ...} new g_izUserVictimDistance[MAX_PLAYERS][MAX_PLAYERS] new g_izUserRndName[MAX_PLAYERS][MAX_NAME_LENGTH + 1] new g_izUserRndStats[MAX_PLAYERS][8] new g_izUserGameStats[MAX_PLAYERS][8]
// Common buffer to improve performance, as Small always zero-initializes all vars new g_sBuffer[MAX_BUFFER_LENGTH + 1] = "" new g_sScore[MAX_TEXT_LENGTH + 1] = "" new g_sAwardAndScore[MAX_BUFFER_LENGTH + 1] = ""
new t_sText[MAX_TEXT_LENGTH + 1] = "" new t_sName[MAX_NAME_LENGTH + 1] = "" new t_sWpn[MAX_WEAPON_LENGTH + 1] = ""
server_print(" ") server_print("########################################################################### ####") server_print("^tTitle : StatsX Shell (Ultimate StatsX)") server_print("^tVersion: %s", STATSX_SHELL_VER) server_print("^tAuthor : AMX MOD X DEV TEAM") server_print("^tEdited : MastaMan") server_print("^tSite : http://amx-server.blogspot.com") server_print(" ") server_print("------------------------------------------------------------------------------") server_print(" ") if(file_exists(szCfgDir)) { server_print("[%s] > Load settings from: statsx_shell.cfg", Time) } else { server_print("[%s] > Not found: statsx_shell.cfg ........................... [ERROR]", Time) server_print(" ") server_print("> Please reinstall plugin statsx_shell.amxx for ") server_print(" solve this problem or check your cfg!") server_print(" ") server_print("> Visit www.amx-server.blogspot.com for check new version and more info...") server_print(" ") server_print("########################################################################### ####")
//log_amx("Not found: statsx_shell.cfg")
return PLUGIN_CONTINUE } server_print(" ")
new szData[MAX_TEXT_LENGTH], i new bool:bERROR_MESSAGE, szERROR_MESSAGE[70] new file = fopen(szCfgDir, "rt") while(!feof(file)) { new bool:g_bERROR_MESSAGE_TYPE1 = true new bool:g_bERROR_MESSAGE_TYPE2 = true
public client_putinserver(id) { if(get_pcvar_num(pcvar_connect_message)) { set_task(2.5, "connect_message_anonce", id) } }
public connect_message_anonce(id) { new szName[32], szKey[50], szData[128], szHUDMessage[512] new szHour[5], szDay[5], szMonth[5] new izStats[8], izBody[8], szHostname[64] new iHour, iDay, iMonth new iLen = 0 new iColor_R, iColor_G, iColor_B, g_pcvarColor
// Get and format attackers header and list. get_attackers(id, sBuffer[MAX_BUFFER_LENGTH + 1]) { new izStats[8], izBody[8] new iAttacker new iFound, iLen new iMaxPlayer = get_maxplayers()
iFound = 0 sBuffer[0] = 0
// Get and format header. Add killing attacker statistics if user is dead. // Make sure shots is greater than zero or division by zero will occur. // To print a '%', 4 of them must done in a row. izStats[STATS_SHOTS] = 0 iAttacker = g_izKilled[id][KILLED_KILLER_ID]
if (iAttacker) get_user_astats(id, iAttacker, izStats, izBody)
// Get and format victims header and list get_victims(id, sBuffer[MAX_BUFFER_LENGTH + 1]) { new izStats[8], izBody[8] new iVictim new iFound, iLen new iMaxPlayer = get_maxplayers()
iFound = 0 sBuffer[0] = 0
// Get and format header. // Make sure shots is greater than zero or division by zero will occur. // To print a '%', 4 of them must done in a row. izStats[STATS_SHOTS] = 0 get_user_vstats(id, 0, izStats, izBody)
// Get and format team score. add_team_score(sBuffer[MAX_BUFFER_LENGTH + 1]) { new Float:fzMapEff[MAX_TEAMS], Float:fzMapAcc[MAX_TEAMS], Float:fzRndAcc[MAX_TEAMS]
// Calculate team stats for (new iTeam = 0; iTeam < MAX_TEAMS; iTeam++) { fzMapEff[iTeam] = effec(g_izTeamGameStats[iTeam]) fzMapAcc[iTeam] = accuracy(g_izTeamGameStats[iTeam]) fzRndAcc[iTeam] = accuracy(g_izTeamRndStats[iTeam]) }
// Get and format killed stats: hits, damage on killer. format_kill_vinfo(id, iKiller, sBuffer[MAX_BUFFER_LENGTH + 1]) { new iFound = 0 new izStats[8] new izBody[8] new iLen
// MastaMan Edition format_award(sBuffer[MAX_BUFFER_LENGTH + 1]) { new izStats[8], izBody[8], szName[3][MAX_NAME_LENGTH], id new iLen = 0 new Float:izAwardCash_Bonus[3], Float:izAwardSkil_Level[3], izCash
new lBonus[30]
format(lBonus, 29, "%L", LANG_SERVER, "MM_BONUS")
iLen = format_all_themes(sBuffer, iLen)
id = iAwardID for(new i = 0; i < 3; i++) { get_stats(id, izStats, izBody, t_sName, MAX_NAME_LENGTH) replace_all(t_sName, MAX_NAME_LENGTH, "<", "<") replace_all(t_sName, MAX_NAME_LENGTH, ">", ">")
// Show round end stats. If gametime is zero then use default duration time. show_roundend_hudstats(id, Float:fGameTime) { // Bail out if there no HUD stats should be shown // for this player or end round stats not created. if (!g_izStatsSwitch[id]) return if (!g_sAwardAndScore[0]) return
// If round end timer is zero clear round end stats. if (g_fShowStatsTime == 0.0) { ClearSyncHud(id, g_HudSync_EndRound) #if defined STATSX_DEBUG log_amx("Clear round end HUD stats for #%d", id) #endif }
// Set HUD-duration to default or remaining time. new Float:fDuration
// Show stats only if more time left than coded minimum. if (fDuration >= HUD_MIN_DURATION) { set_hudtype_endround(fDuration) ShowSyncHudMsg(id, g_HudSync_EndRound, "%s", g_sAwardAndScore) #if defined STATSX_DEBUG log_amx("Show %1.2fs round end HUD stats for #%d", fDuration, id) #endif } }
// Show round end stats. show_user_hudstats(id, Float:fGameTime) { // Bail out if there no HUD stats should be shown // for this player or user stats timer is zero. if (!g_izStatsSwitch[id]) return if (g_fzShowUserStatsTime[id] == 0.0) return
// Set HUD-duration to default or remaining time. new Float:fDuration
// Report user weapon status to team. public cmdReport(id) { if (!SayReport) { colorChat(id, CHATCOLOR_RED, "%L", id, "DISABLED_MSG") return PLUGIN_HANDLED }
new iWeapon, iClip, iAmmo, iHealth, iArmor
iWeapon = get_user_weapon(id, iClip, iAmmo)
if (iWeapon != 0) xmod_get_wpnname(iWeapon, t_sWpn, MAX_WEAPON_LENGTH)
// Player stats menu. public cmdStats(id) { if (!SayStatsAll) { colorChat(id, CHATCOLOR_RED, "%L", id, "DISABLED_MSG") return PLUGIN_HANDLED }
showStatsMenu(id, g_izUserMenuPosition[id] = 0)
return PLUGIN_CONTINUE }
//-------------------------------- // Menu //--------------------------------
public actionStatsMenu(id, key) { switch (key) { // Key '1' to '7', execute action on this option case 0..6: { new iOption, iIndex iOption = (g_izUserMenuPosition[id] * PPL_MENU_OPTIONS) + key
if (g_izUserMenuAction[id] >= MAX_PPL_MENU_ACTIONS) g_izUserMenuAction[id] = 0
showStatsMenu(id, g_izUserMenuPosition[id]) } // Key '9', select next page of options case 8: showStatsMenu(id, ++g_izUserMenuPosition[id]) // Key '10', cancel or go back to previous menu case 9: { if (g_izUserMenuPosition[id] > 0) showStatsMenu(id, --g_izUserMenuPosition[id]) } }
return PLUGIN_HANDLED }
new g_izUserMenuActionText[MAX_PPL_MENU_ACTIONS][62]
// Round start public eventStartRound() { new iTeam, id, i
if (read_data(1) >= floatround(get_cvar_float("mp_roundtime") * 60.0,floatround_floor)) {
#if defined STATSX_DEBUG log_amx("Reset round stats") #endif
// Reset game stats on game start and restart. if (g_fStartGame > 0.0 && g_fStartGame <= get_gametime()) { #if defined STATSX_DEBUG log_amx("Reset game stats") #endif
g_fStartGame = 0.0
// Clear team and game stats. for (iTeam = 0; iTeam < MAX_TEAMS; iTeam++) { g_izTeamEventScore[iTeam] = 0
for (i = 0; i < 8; i++) g_izTeamGameStats[iTeam][i] = 0 }
// Clear game stats, incl '0' that is sum of all users. for (id = 0; id < MAX_PLAYERS; id++) { for (i = 0; i < 8; i++) g_izUserGameStats[id][i] = 0 } }
// Update team score with "TeamScore" event values and // clear team round stats. for (iTeam = 0; iTeam < MAX_TEAMS; iTeam++) { g_izTeamScore[iTeam] = g_izTeamEventScore[iTeam]
for (i = 0; i < 8; i++) g_izTeamRndStats[iTeam][i] = 0 }
// Clear user round stats, incl '0' that is sum of all users. for (id = 0; id < MAX_PLAYERS; id++) { g_izUserRndName[id][0] = 0
for (i = 0; i < 8; i++) g_izUserRndStats[id][i] = 0
g_fzShowUserStatsTime[id] = 0.0 }
// Allow end round stats and reset end round triggered indicator. g_iRoundEndTriggered = 0 g_iRoundEndProcessed = 0 g_fShowStatsTime = 0.0
// Update local configuration vars with value in cvars. get_config_cvars() }
return PLUGIN_CONTINUE }
// Reset killer info on round restart. public eventResetHud(id) { new args[1] args[0] = id
public delay_resethud(args[]) { new id = args[0] new Float:fGameTime
// Show user and score round stats after HUD-reset #if defined STATSX_DEBUG log_amx("Reset HUD for #%d", id) #endif fGameTime = get_gametime() show_user_hudstats(id, fGameTime) show_roundend_hudstats(id, fGameTime)
for (new i = 0; i < MAX_PLAYERS; i++) g_izUserVictimDistance[id][i] = 0
return PLUGIN_CONTINUE }
// Save killer info on death. public client_death(killer, victim, wpnindex, hitplace, TK) { // Bail out if no killer. if (!killer) return PLUGIN_CONTINUE
if (killer != victim) { new iaVOrigin[3], iaKOrigin[3] new iDistance
// Display kill stats for the player if round // end stats was not processed. if (!g_iRoundEndProcessed) kill_stats(victim)
return PLUGIN_CONTINUE }
// Display hudmessage stats on death. // This will also update all round and game stats. // Must be called at least once per round. kill_stats(id) { // Bail out if user stats timer is non-zero, // ie function already called. if (g_fzShowUserStatsTime[id] > 0.0) { return }
new team = get_user_team(id) if (team < 1 || team > 2) { return }
// Flag kill stats displayed for this player. g_fzShowUserStatsTime[id] = get_gametime()
// Add user death stats to user round stats new izStats[8], izBody[8] new iTeam, i new iKiller
iKiller = g_izKilled[id][KILLED_KILLER_ID]
// Get user's team (if dead use the saved team) if (iKiller) iTeam = g_izKilled[id][KILLED_TEAM] - 1 else iTeam = get_user_team(id) - 1
if (get_user_rstats(id, izStats, izBody)) { // Update user's team round stats if (iTeam >= 0 && iTeam < MAX_TEAMS) { for (i = 0; i < 8; i++) { g_izTeamRndStats[iTeam][i] += izStats[i] g_izTeamGameStats[iTeam][i] += izStats[i] g_izUserRndStats[0][i] += izStats[i] g_izUserGameStats[0][i] += izStats[i] } }
// Update user's round stats if (g_izUserUserID[id] == get_user_userid(id)) { for (i = 0; i < 8; i++) { g_izUserRndStats[id][i] += izStats[i] g_izUserGameStats[id][i] += izStats[i] } } else { g_izUserUserID[id] = get_user_userid(id)
for (i = 0; i < 8; i++) { g_izUserRndStats[id][i] = izStats[i] g_izUserGameStats[id][i] = izStats[i] } }
} // endif (get_user_rstats())
// Report stats in the chat section, if player is killed. if (KillerChat && iKiller && iKiller != id) { if (format_kill_ainfo(id, iKiller, g_sBuffer)) { colorChat(id, CHATCOLOR_GREEN, "* %s", g_sBuffer) format_kill_vinfo(id, iKiller, g_sBuffer) }
public time_play_bonus() { if(!get_pcvar_num(pcvar_pt_bonus) || !get_pcvar_num(pcvar_pt)) { return PLUGIN_HANDLED }
new iCash, iTmpCash, iDay, szDay[5] new szPlayers[32], iNum, szName[32] new szKey[50], szData[128]
new iCash_1h = get_pcvar_num(pcvar_pt_bonus_1h) new iCash_2h = get_pcvar_num(pcvar_pt_bonus_2h) new iCash_3h = get_pcvar_num(pcvar_pt_bonus_3h) new iCash_4h = get_pcvar_num(pcvar_pt_bonus_4h) new iCash_5h = get_pcvar_num(pcvar_pt_bonus_5h)
public day_stat_clear() { new szDate[5], szKey[6] format_time(szDate, sizeof(szDate) - 1, "%d")
for(new i = 0; i < 24; i++) { formatex(szKey, 5, "%d-h", i) nvault_set(g_Vault , szKey , "0") }
nvault_set(g_Vault , "DAY" , szDate)
return PLUGIN_CONTINUE }
public ERTask() { // Flag round end triggered. g_iRoundEndTriggered = 1
// Display round end stats to all players. endround_stats() }
endround_stats() { // Bail out if end round stats has already been processed // or round end not triggered. if (g_iRoundEndProcessed || !g_iRoundEndTriggered) return
new iaPlayers[32], iPlayer, iPlayers, id
get_players(iaPlayers, iPlayers)
// Display attacker & victim list for all living players. // This will also update all round and game stats for all players // not killed. #if defined STATSX_DEBUG log_amx("End round stats") #endif
for (iPlayer = 0; iPlayer < iPlayers; iPlayer++) { id = iaPlayers[iPlayer]
if (g_fzShowUserStatsTime[id] == 0.0) { kill_stats(id) } }
g_sAwardAndScore[0] = 0
// Create round awards. if (ShowMostDisruptive) add_most_disruptive(g_sAwardAndScore) if (ShowBestScore) add_best_score(g_sAwardAndScore)
// Create round score. // Compensate HUD message if awards are disabled. if (ShowTeamScore || ShowTotalStats) { if (ShowMostDisruptive && ShowBestScore) add(g_sAwardAndScore, MAX_BUFFER_LENGTH, "^n^n") else if (ShowMostDisruptive || ShowBestScore) add(g_sAwardAndScore, MAX_BUFFER_LENGTH, "^n^n^n^n") else add(g_sAwardAndScore, MAX_BUFFER_LENGTH, "^n^n^n^n^n^n")
if (ShowTeamScore) add_team_score(g_sAwardAndScore)
if (ShowTotalStats) add_total_stats(g_sAwardAndScore) }
save_team_chatscore()
// Get and save round end stats time. g_fShowStatsTime = get_gametime()
// Display round end stats to all players. for (iPlayer = 0; iPlayer < iPlayers; iPlayer++) { id = iaPlayers[iPlayer] show_roundend_hudstats(id, 0.0) }
// Flag round end processed. g_iRoundEndProcessed = 1 }
^x01 is Yellow ^x03 is Team Color. Ie. Red (Terrorist) or blue (Counter-Terrorist) or grey (SPECTATOR or UNASSIGNED). ^x04 is Green
The colors red, grey, and blue can't be used on the same line. This is not possible at all to do.
Also there are limitation to using Red or Grey while on the TEAM CT. You would have to do for example if they were on CT.
ColorChat(0, RED, "%s, ^x01This color is yellow. ^x03This color is red. ^x04This color is green.);
You have to set the Type to RED because of certain messages that need to be sent out so a person on the team CT can be sent red colors.
Some important information. When using MSG_ALL to send color message to all clients and your going to use blue/grey/red color sending the TeamInfo Message to tempoary change the player team to achieve this. You must send that message in MSG_ALL also. If your going to only send it to one person. You need to MSG_ONE on TeamInfo and SayText. (Thanks to CheapSuit I was able to see their was an error and fix it).
*/
colorChat(id, ChatColor:color, const msg[], {Float,Sql,Result,_}:...) { new team, index, MSG_Type new bool:teamChanged = false static message[192]
switch(color) { case CHATCOLOR_NORMAL: // Normal { message[0] = 0x01; } case CHATCOLOR_GREEN: // Green { message[0] = 0x04; } default: // Grey, Red, Blue { message[0] = 0x03; } }