Autobalance NordicWarrior

Статус
В этой теме нельзя размещать новые ответы.
Сообщения
321
Реакции
73
Помог
11 раз(а)
Ошибка
L 03/01/2021 - 09:09:34: Client index 6 is invalid
L 03/01/2021 - 09:09:34: [AMXX] Displaying debug trace (plugin "AutoBalance.amxx", version "1.0.0")
L 03/01/2021 - 09:09:34: [AMXX] Run time error 10: native error (native "vformat")
L 03/01/2021 - 09:09:34: [AMXX] [0] AutoBalance.sma::ClientPrintToAllExcludeOne (line 373)
L 03/01/2021 - 09:09:34: [AMXX] [1] AutoBalance.sma::ShowHud (line 296)
ОС
Linux
Amx Mod X
1.9.0.5271
Билд
3.8.0.704-dev
ReGamedll
5.19.0.486-dev
Версия Metamod
1.3.0.128
Список метамодулей
[ 1] SafeNameAndChat  RUN   -    SafeNameAndChat.so          v1.1             ini  ANY   ANY  
[ 2] VoiceTranscoder RUN - VoiceTranscoder.so v2017RC5 ini ANY ANY
[ 3] Reunion RUN - reunion_mm_i386.so v0.1.0.92c ini Start Never
[ 4] ReAuthCheck RUN - reauthcheck_mm_i386.so v0.1.6 ini Start Never
[ 5] ReSemiclip RUN - resemiclip_mm_i386.so v2.3.9 ini Chlvl ANY
[ 6] Rechecker RUN - rechecker_mm_i386.so v2.5 ini Chlvl ANY
[ 7] WHBlocker RUN - whblocker_mm_i386.so v1.5.697 ini Chlvl ANY
[ 8] AMX Mod X RUN - amxmodx_mm_i386.so v1.9.0.5271 ini Start ANY
[ 9] MySQL RUN - mysql_amxx_i386.so v1.9.0.5271 pl8 ANY ANY
[10] hackdetector RUN - hackdetector_amxx_i386.so v0.15.328.lite pl8 ANY ANY
[11] Fun RUN - fun_amxx_i386.so v1.9.0.5271 pl8 ANY ANY
[12] Engine RUN - engine_amxx_i386.so v1.9.0.5271 pl8 ANY ANY
[13] FakeMeta RUN - fakemeta_amxx_i386.so v1.9.0.5271 pl8 ANY ANY
[14] GeoIP RUN - geoip_amxx_i386.so v1.9.0.5271 pl8 ANY ANY
[15] CStrike RUN - cstrike_amxx_i386.so v1.9.0.5271 pl8 ANY ANY
[16] Ham Sandwich RUN - hamsandwich_amxx_i386.so v1.9.0.5271 pl8 ANY ANY
[17] gRIP RUN - grip_amxx_i386.so v0.1.5 Beta pl8 ANY ANY
[18] ReAPI RUN - reapi_amxx_i386.so v5.18.0.203-dev pl8 ANY Never
[19] ReAimDetector RUN - reaimdetector_amxx_i386.so v0.2.2 pl8 ANY Never
19 plugins, 19 running
Список плагинов
[  1] FreshBans               1.4.3b      kanagava          fresh_bans_143_  running  
[ 2] Admin Loader 3.5 neygomon admin_loader_3. running
[ 3] ReAimDetector API 0.2.2 ReHLDS Team reaimdetector.a running
[ 4] Lite Admin ESP 1.0 neygomon admin_esp.amxx running
[ 5] Advanced Rechecker 0.4 F@nt0M rechecker.amxx running
[ 6] Advanced Gag 1.9.0 neygomon amx_gag.amxx running
[ 7] Chat Checker 0.1a Subb98 chat_checker.am running
[ 8] Chat Logger 2.1a Jim chat_logger.amx running
[ 9] Reset Score 0.0.2f wopox1337 ResetScore.amxx running
[ 10] Spray Block 1.0 maFFyoZZyk Spray_Block.amx running
[ 11] Server Menu 1.5.0 F@nt0M server_menu.amx debug
[ 12] Knife Models 3.1.1 OciXCrom crx_knife_model running
[ 13] Auto AWP 1.1 OciXCrom crx_auto_awp.am running
[ 14] AWP Models 2.1.4 OciXCrom crx_awp_models. running
16:39:17 [ 15] Equip Remover 1.1 OciXCrom crx_equipremove running
[ 16] MOTD Commands 1.3 OciXCrom crx_motdcommand running
[ 17] OciXCrom's Rank System 3.9 OciXCrom crx_ranksystem. debug
[ 18] Chat Manager 4.5.1 OciXCrom crx_chatmanager running
[ 19] AES: StatsX 0.5+1 serfreeman1337 aes_statsx_cstr running
[ 20] CSStatsX SQL 0.7.4+2 serfreeman1337 csstatsx_sql.am running
[ 21] AFK Control 1.4.1 [NoR neygomon afk_control.amx running
[ 22] Advert Messages 1.22 neygomon adverts.amxx running
[ 23] [ReAPI] AdminFreeLook 1.0 ReHLDS Team adminfreelook.a running
[ 24] Lite Vampire + Fade 1.3 neygomon lite_vampire.am running
[ 25] Advanced Client Checke 0.3.7 Mistrick cmdchecker.amxx running
[ 26] [BG] Provider: GeoIP 0.2 mx?! bg_provider_geo running
[ 27] [BG] Provider: iphub.i 0.5 mx?! bg_provider_iph running
[ 28] Bypass Guard 1.0.1 mx?! bypass_guard.am running
[ 29] Ping Checker 26.0.1 RC1 h1k3 ping_checker.am running
16:39:17 [ 30] DM AutoBalance 1.0.0 Nordic Warrior AutoBalance.amx debug
[ 31] Demo Recorder 2.4.1 F@nt0M demo_recorder.a running
[ 32] [ReAPI] Advanced Team 0.1.0 Vaqtincha AdvancedTeamCho running
[ 33] DopBan 3.0.5b kanagava dop_ban305_183. running
[ 34] Refill Weapon On Kill 0.3 Vaqtincha refill_weapon_o running
[ 35] AntiFlood Change Name 28.11.2018 sergrib block_change_na running
[ 36] Invisible Spectator 1.0 ReHLDS Team invisible_spect running
[ 37] BhopHack Detector 0.1 Mistrick bhophack_detect running
[ 38] Show timeleft for CSDM 1.0 neygomon timer.amxx running
[ 39] Maps Menu 1.9.0.5249 AMXX Dev Team mapsmenu.amxx running
[ 40] Walls Creator 1.1 d3m37r4 walls_creator.a running
[ 41] Slots Reservation 1.9.0.5249 AMXX Dev Team adminslots.amxx running
[ 42] Anti Flood 1.9.0.5249 AMXX Dev Team antiflood.amxx running
[ 43] Admin Commands 1.9.0.5249 AMXX Dev Team admincmd.amxx running
[ 44] Players Menu 1.9.0.5249 AMXX Dev Team plmenu.amxx running
16:39:17 [ 45] Admin Chat 1.9.0.5249 AMXX Dev Team adminchat.amxx running
[ 46] Stats Configuration 1.9.0.5249 AMXX Dev Team statscfg.amxx running
[ 47] CS Stats Logging 1.9.0.5249 AMXX Dev Team stats_logging.a running
[ 48] Map Manager: Core 3.0.9 Mistrick map_manager_cor running
[ 49] Map Manager: Scheduler 0.1.6 Mistrick map_manager_sch running
[ 50] Map Manager: Rtv 0.1.1 Mistrick map_manager_rtv running
[ 51] Map Manager: Nominatio 0.1.3 Mistrick map_manager_nom running
[ 52] Map Manager: BlockList 0.0.3 Mistrick map_manager_blo running
[ 53] Map Manager: Effects 0.0.10 Mistrick map_manager_eff running
[ 54] Map Manager: Informer 0.0.5 Mistrick map_manager_inf running
54 plugins, 54 running
Автор плагина
NordicWarrior
Версия плагина
1.0.0
Исходный код
/*  *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *
* *
* Plugin: Automatic team balance for DM servers *
* *
* Official plugin support: https://dev-cs.ru/threads/8029/ *
* Official repository: https://github.com/Nord1cWarr1or/AutoBalance *
* Contacts of the author: Telegram: @NordicWarrior *
* *
* * * * * * * * * * * * * * * * * * * *
* *
* Плагин: Автоматический баланс команд для DM сереров *
* *
* Официальная поддержка плагина: https://dev-cs.ru/threads/8029/ *
* Официальный репозиторий: https://github.com/Nord1cWarr1or/AutoBalance *
* Связь с автором: Telegram: @NordicWarrior *
* *
* * * * * * * * * * * * * * * * * * * */

#include <amxmodx>
#include <amxmisc>
#include <reapi>
#include <xs>
#include <screenfade_util>

new const PLUGIN_VERSION[] = "1.0.0";

#if !defined MAX_MAPNAME_LENGTH
#define MAX_MAPNAME_LENGTH 64
#endif

#define GetCvarDesc(%0) fmt("%L", LANG_SERVER, %0)

#define GetBit(%1,%2) (%1 & (1 << (%2 & 31)))
#define SetBit(%1,%2) %1 |= (1 << (%2 & 31))
#define ClrBit(%1,%2) %1 &= ~(1 << (%2 & 31))

//#define DEBUG

#define AUTO_CFG // Comment out if you don't want the plugin config to be created automatically in "configs/plugins"

enum _:Cvars
{
MAX_DIFF,
MODE,
Float:TIME_TO_PREPARE,
ADMIN_FLAG[2],
BOTS,
ADMIN_MODE,
MAX_DIFF_ADMINS,
SKIP_SUICIDE,
SKIP_DISCONNECT
};

new g_pCvar[Cvars];

new TeamName:g_iNewPlayerTeam[MAX_PLAYERS + 1];

new g_iBlueColor[3] = { 0, 0, 255 };
new g_iRedColor[3] = { 255, 0, 0 };

const TASKID__BALANCE_PLAYER = 991;
const TASKID__SHOW_HUD = 992;

new g_bitIsUserConnected;

new g_iPlayersInTeam[TeamName][MAX_PLAYERS], g_iCountPlayersInTeam[TeamName];
new g_iAdminsInTeam[TeamName][MAX_PLAYERS], g_iCountAdminsInTeam[TeamName];

new g_iFwdBalancePlayerPre, g_iFwdBalancePlayerPost;

public plugin_init()
{
register_plugin("DM AutoBalance", PLUGIN_VERSION, "Nordic Warrior");

register_dictionary("dm_autobalance.txt");

RegisterHookChain(RG_CBasePlayer_Killed, "OnPlayerKilledPost", true);

CreateCvars();

g_iFwdBalancePlayerPre = CreateMultiForward("OnBalancePlayerPre", ET_STOP, FP_CELL);
g_iFwdBalancePlayerPost = CreateMultiForward("OnBalancePlayerPost", ET_IGNORE, FP_CELL);

#if defined AUTO_CFG
AutoExecConfig(true, "AutoBalance");
#endif

#if defined DEBUG
register_clcmd("say /ct", "CheckTeams");
#endif
}

public OnConfigsExecuted()
{
register_cvar("dmtb_NW_version", PLUGIN_VERSION, FCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED);
}

public client_putinserver(id)
{
SetBit(g_bitIsUserConnected, id);
}

public client_remove(id)
{
if(GetBit(g_bitIsUserConnected, id))
{
if(!g_pCvar[SKIP_DISCONNECT])
{
CheckTeams();
}
ClrBit(g_bitIsUserConnected, id);
}
}

public OnPlayerKilledPost(iVictim, iKiller)
{
if(!GetBit(g_bitIsUserConnected, iKiller) || (g_pCvar[SKIP_SUICIDE] && iKiller == iVictim))
return;

#if defined DEBUG
log_amx("Player <%n> killed", iVictim);
#endif

CheckTeams();
}

public CheckTeams()
{
if(task_exists(TASKID__BALANCE_PLAYER))
return PLUGIN_HANDLED;

ArraysZeroing();

new iPlayers[MAX_PLAYERS], iPlayersNum;

get_players_ex(iPlayers, iPlayersNum, g_pCvar[BOTS] ? GetPlayers_ExcludeHLTV : (GetPlayers_ExcludeBots | GetPlayers_ExcludeHLTV));

new TeamName:iTeam;
new iPlayer;

for(new i; i < iPlayersNum; i++)
{
iPlayer = iPlayers[i];

iTeam = get_member(iPlayer, m_iTeam);

g_iPlayersInTeam[iTeam][g_iCountPlayersInTeam[iTeam]++] = iPlayer;

if(has_flag(iPlayer, g_pCvar[ADMIN_FLAG]) && g_pCvar[ADMIN_MODE] == 2)
{
g_iAdminsInTeam[iTeam][g_iCountAdminsInTeam[iTeam]++] = iPlayer;
}
}

#if defined DEBUG
log_amx("TE = %i, CT = %i", g_iCountPlayersInTeam[TEAM_TERRORIST], g_iCountPlayersInTeam[TEAM_CT]);

if(g_pCvar[ADMIN_MODE] == 2)
{
log_amx("ADM TE = %i, ADM CT = %i", g_iCountAdminsInTeam[TEAM_TERRORIST], g_iCountAdminsInTeam[TEAM_CT]);
}
#endif

if(xs_abs(g_iCountPlayersInTeam[TEAM_TERRORIST] - g_iCountPlayersInTeam[TEAM_CT]) > g_pCvar[MAX_DIFF])
{
new iTeamPlayersForBalance = xs_sign(g_iCountPlayersInTeam[TEAM_TERRORIST] - g_iCountPlayersInTeam[TEAM_CT]);

if(g_pCvar[ADMIN_MODE] == 2 && xs_abs(g_iCountAdminsInTeam[TEAM_TERRORIST] - g_iCountAdminsInTeam[TEAM_CT]) > g_pCvar[MAX_DIFF_ADMINS])
{
new iTeamAdminsForBalance = xs_sign(g_iCountAdminsInTeam[TEAM_TERRORIST] - g_iCountAdminsInTeam[TEAM_CT]);

GetPlayerForBalance(iTeamAdminsForBalance, true);
return PLUGIN_HANDLED;
}
GetPlayerForBalance(iTeamPlayersForBalance);
}
else if(g_pCvar[ADMIN_MODE] == 2 && xs_abs(g_iCountAdminsInTeam[TEAM_TERRORIST] - g_iCountAdminsInTeam[TEAM_CT]) > g_pCvar[MAX_DIFF_ADMINS])
{
new iTeamAdminsForBalance = xs_sign(g_iCountAdminsInTeam[TEAM_TERRORIST] - g_iCountAdminsInTeam[TEAM_CT]);

GetPlayerForBalance(iTeamAdminsForBalance, true);
}
return PLUGIN_HANDLED;
}

GetPlayerForBalance(const iTeamToBalance, bool:bAdmins = false)
{
new iRandomPlayer;

if(iTeamToBalance == 1)
{
if(!bAdmins)
{
iRandomPlayer = g_iPlayersInTeam[TEAM_TERRORIST][random(g_iCountPlayersInTeam[TEAM_TERRORIST])];
}
else
{
iRandomPlayer = g_iAdminsInTeam[TEAM_TERRORIST][random(g_iCountAdminsInTeam[TEAM_TERRORIST])];
}
g_iNewPlayerTeam[iRandomPlayer] = TEAM_CT;
}
else
{
if(!bAdmins)
{
iRandomPlayer = g_iPlayersInTeam[TEAM_CT][random(g_iCountPlayersInTeam[TEAM_CT])];
}
else
{
iRandomPlayer = g_iAdminsInTeam[TEAM_CT][random(g_iCountAdminsInTeam[TEAM_CT])];
}
g_iNewPlayerTeam[iRandomPlayer] = TEAM_TERRORIST;
}

#if defined DEBUG
log_amx("Balanced player: <%n>, ID: %i", iRandomPlayer, iRandomPlayer);
#endif

if(!bAdmins && has_flag(iRandomPlayer, g_pCvar[ADMIN_FLAG]) && g_pCvar[ADMIN_MODE] != 0)
{
#if defined DEBUG
log_amx("Player <%n> has immunity", iRandomPlayer);
#endif

RequestFrame("CheckTeams");
return PLUGIN_HANDLED;
}

NotifyAndBalancePlayer(iRandomPlayer);
return PLUGIN_HANDLED;
}

NotifyAndBalancePlayer(const id)
{
new iData[1]; iData[0] = id;

set_task(g_pCvar[TIME_TO_PREPARE], "BalancePlayer", TASKID__BALANCE_PLAYER, iData, sizeof iData);

set_dhudmessage(255, 255, 255, -1.0, 0.42, 0, 0.0, 3.0, 0.1, 0.1);
show_dhudmessage(id, "%l", "DMTB_DHUD_WILL_BALANCED", g_pCvar[TIME_TO_PREPARE]);
}

public BalancePlayer(iData[])
{
new id = iData[0];

if(!GetBit(g_bitIsUserConnected, id))
return PLUGIN_HANDLED;

new TeamName:iTeam = get_member(id, m_iTeam);

if(iTeam == TEAM_SPECTATOR || iTeam == g_iNewPlayerTeam[id])
{
RequestFrame("CheckTeams");
return PLUGIN_HANDLED;
}

new iReturn;
ExecuteForward(g_iFwdBalancePlayerPre, iReturn, id);

if(iReturn == PLUGIN_HANDLED)
return PLUGIN_HANDLED;

if(user_has_weapon(id, CSW_C4))
rg_drop_items_by_slot(id, C4_SLOT);

rg_switch_team(id);

switch(g_pCvar[MODE])
{
case 0:
{
user_silentkill(id);
rg_round_respawn(id);
}
case 1: rg_round_respawn(id);
}

UTIL_ScreenFade(id, g_iNewPlayerTeam[id] == TEAM_CT ? g_iBlueColor : g_iRedColor, 0.5, 2.5, 100);

set_task(0.1, "ShowHud", TASKID__SHOW_HUD + id);

ExecuteForward(g_iFwdBalancePlayerPost, iReturn, id);

RequestFrame("CheckTeams");
return PLUGIN_CONTINUE;
}

public ShowHud(id)
{
id -= TASKID__SHOW_HUD;

set_dhudmessage(255, 255, 255, -1.0, 0.42, 0, 0.0, 3.0, 0.1, 0.1);
show_dhudmessage(id, "%l", g_iNewPlayerTeam[id] == TEAM_CT ? "DMTB_DHUD_BALANCED_CT" : "DMTB_DHUD_BALANCED_TE");

ClientPrintToAllExcludeOne(id, id, "%l", g_iNewPlayerTeam[id] == TEAM_CT ? "DMTB_CHAT_BALANCED_CT" : "DMTB_CHAT_BALANCED_TE", id);
}

ArraysZeroing()
{
arrayset(g_iPlayersInTeam[any:0][0], 0, sizeof g_iPlayersInTeam * sizeof g_iPlayersInTeam[]);
arrayset(g_iCountPlayersInTeam[any:0], 0, sizeof g_iCountPlayersInTeam);
arrayset(g_iAdminsInTeam[any:0][0], 0, sizeof g_iAdminsInTeam * sizeof g_iAdminsInTeam[]);
arrayset(g_iCountAdminsInTeam[any:0], 0, sizeof g_iCountAdminsInTeam);
}

public CreateCvars()
{
bind_pcvar_num(create_cvar("dmtb_max_diff", "1",
.description = GetCvarDesc("DMTB_CVAR_MAX_DIFF"),
.has_min = true, .min_val = 1.0),
g_pCvar[MAX_DIFF]);

bind_pcvar_num(create_cvar("dmtb_mode", "1",
.description = GetCvarDesc("DMTB_CVAR_MODE"),
.has_min = true, .min_val = 0.0,
.has_max = true, .max_val = 1.0),
g_pCvar[MODE]);

bind_pcvar_float(create_cvar("dmtb_time", "3.0",
.description = GetCvarDesc("DMTB_CVAR_TIME"),
.has_min = true, .min_val = 1.0),
g_pCvar[TIME_TO_PREPARE]);

bind_pcvar_string(create_cvar("dmtb_admin_flag", "a",
.description = GetCvarDesc("DMTB_CVAR_ADMIN_FLAG")),
g_pCvar[ADMIN_FLAG], charsmax(g_pCvar[ADMIN_FLAG]));

bind_pcvar_num(create_cvar("dmtb_bots", "0",
.description = GetCvarDesc("DMTB_CVAR_BOTS"),
.has_min = true, .min_val = 0.0,
.has_max = true, .max_val = 1.0),
g_pCvar[BOTS]);

bind_pcvar_num(create_cvar("dmtb_admin_mode", "1",
.description = GetCvarDesc("DMTB_CVAR_ADMIN_MODE"),
.has_min = true, .min_val = 0.0,
.has_max = true, .max_val = 2.0),
g_pCvar[ADMIN_MODE]);

bind_pcvar_num(create_cvar("dmtb_max_diff_admins", "1",
.description = GetCvarDesc("DMTB_CVAR_MAX_DIFF_ADMINS"),
.has_min = true, .min_val = 1.0),
g_pCvar[MAX_DIFF_ADMINS]);

bind_pcvar_num(create_cvar("dmtb_skip_suicide", "1",
.description = GetCvarDesc("DMTB_CVAR_SKIP_SUICIDE"),
.has_min = true, .min_val = 0.0,
.has_max = true, .max_val = 1.0),
g_pCvar[SKIP_SUICIDE]);

bind_pcvar_num(create_cvar("dmtb_skip_disconnect", "0",
.description = GetCvarDesc("DMTB_CVAR_SKIP_DISCONNECT"),
.has_min = true, .min_val = 0.0,
.has_max = true, .max_val = 1.0),
g_pCvar[SKIP_DISCONNECT]);
}

stock ClientPrintToAllExcludeOne(const iExcludePlayer, const iSender, const szMessage[], any:...)
{
new szText[192];

new iPlayers[MAX_PLAYERS], iNumPlayers;
get_players(iPlayers, iNumPlayers, "ch");

for(new i; i < iNumPlayers; i++)
{
new iPlayer = iPlayers[i];

if(iPlayer != iExcludePlayer)
{
SetGlobalTransTarget(iPlayer);
vformat(szText, charsmax(szText), szMessage, 4);
client_print_color(iPlayer, iSender, szText);
}
}
}
Добрый день, как исправить эту ошибку?
 
В этой теме было размещено решение! Перейти к решению.
Сообщения
1,304
Реакции
2,303
Помог
57 раз(а)
Если я ничего не путаю, то проблема вызвана тем, что id в ShowHud() уже отключился от сервера.
Nordic Warrior чини давай, мы не для того за интернет платим, чтоб ты нам тут баги устраивал!
 
Сообщения
3,593
Реакции
1,576
Помог
141 раз(а)
BlackSignature, да, спасибо, мне уже подсказали насчёт ошибки.

Angerfist, пока попробуй этот хотфикс, как появится время, обновлю ресурс нормальной реализацией.
 

Вложения

Статус
В этой теме нельзя размещать новые ответы.

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу