- Ошибка
-
При вводе команды timeleft и других команд без слеша ничего не происходит, хотя сам плагин Map Manager [Modular] 3.2.1 стоит вверху списка плагинов, а чат менеджер внизу.
- ОС
- Linux
- Amx Mod X
-
1.9.0
- Билд
-
Protocol version 48
Exe version 1.1.2.7/Stdio (cstrike)
ReHLDS version: 3.13.0.788-dev
Build date: 07:36:33 Jul 12 2023 (3378)
- ReGamedll
-
ReGameDLL version: 5.21.0.546-dev
- Версия Metamod
-
Metamod-r v1.3.78, API (5:13)
- Список метамодулей
-
[ 1] Reunion RUN - reunion_mm_i386. v0.1.92d ini Start Never
[ 2] SafeNameAndChat RUN - SafeNameAndChat. v1.1 ini ANY ANY
[ 3] Rechecker RUN - rechecker_mm_i38 v2.7 ini Chlvl ANY
[ 4] AMX Mod X RUN - amxmodx_mm_i386. v1.9.0-d ini Start ANY
[ 5] WHBlocker RUN - whblocker_mm_i38 v1.5.696 ini Chlvl ANY
[ 6] Revoice RUN - revoice_mm_i386. v0.1.0.3 ini Start Never
[ 7] ReAuthCheck RUN - reauthcheck_mm_i v0.1.6 ini Start Never
[ 8] ReSRDetector RUN - resrdetector_mm_ v0.1.0 ini Chlvl ANY
[ 9] ReSemiclip RUN - resemiclip_mm_i3 v2.3.9 ini Chlvl ANY
[10] HitBox Fix RUN - hitbox_fix_mm_i3 v1.1.4 ini Start ANY
[11] MySQL RUN - mysql_amxx_i386. v1.9.0-d pl4 ANY ANY
[12] Admins Kit RUN - adminskit_amxx_i v2.1.0 pl4 ANY ANY
[13] ReAPI RUN - reapi_amxx_i386. v5.21.0. pl4 ANY Never
[14] FakeMeta RUN - fakemeta_amxx_i3 v1.9.0-d pl4 ANY ANY
[15] Engine RUN - engine_amxx_i386 v1.9.0-d pl4 ANY ANY
[16] CStrike RUN - cstrike_amxx_i38 v1.9.0-d pl4 ANY ANY
[17] Fun RUN - fun_amxx_i386.so v1.9.0-d pl4 ANY ANY
[18] Ham Sandwich RUN - hamsandwich_amxx v1.9.0-d pl4 ANY ANY
[19] ReAimDetector RUN - reaimdetector_am v0.2.2 pl4 ANY Never
[20] CSX RUN - csx_amxx_i386.so v1.9.0-d pl4 ANY ANY
[21] SxGeo RUN - sxgeo_amxx_i386. v2.2 pl4 ANY Never
- Список плагинов
-
[ 1] FreshBans 1.4.0b kanagava fresh_bans.amxx running
[ 2] Admin Base 1.9.0-dev+ AMXX Dev Team admin.amxx running
[ 3] Map Manager: Core 3.2.1 Mistrick map_manager_cor running
[ 4] Temp menu 6.3 Sanya@ (Skype: a menup.amxx debug
[ 5] [190] Ultimate Gag 21.01.02BE SKAJIbnEJIb ultimate_gag.am running
[ 6] Server Menu 1.5.0 F@nt0M server_menu.amx running
[ 7] Top Awards 1.0 Dom1no_[KZ] top_awards.amxx debug
[ 8] Molotov Cocktail Spawn 1.3 mx?! molotov_cocktai running
[ 9] Molotov Cocktail API 2.14 CHEL74 + mx?! molotov_cocktai running
[ 10] [ReAPI] Parachute 1.1 ReHLDS Team & me parachute_lite. debug
[ 11] FreshBans 1.4.6b kanagava fresh_bans_146- running
[ 12] Mode 2x2 2.5re s1lent mode.amxx running
[ 13] Knife kill 1.0.0 MurLemur knife_kill_soun running
[ 14] ReAimDetector API 0.2.2 ReHLDS Team reaimdetector.a running
[ 15] ScreenMaker 1.1 neygomon screen_maker.am running
[ 16] [RE] Talisman 1.4 BiZaJe talisman.amxx running
[ 17] [190] Block Reconnect 20.06.06 ShaTalKiN Block_Reconnect running
[ 18] Team Leader 0.5b b0t. Amx_TeamLeader. running
[ 19] Admin Commands 1.9.0-dev+ AMXX Dev Team admincmd.amxx running
[ 20] Slots Reservation 1.9.0-dev+ AMXX Dev Team adminslots.amxx running
[ 21] Commands Menu 1.9.0-dev+ AMXX Dev Team cmdmenu.amxx running
[ 22] Players Menu 1.7 neugomon players_menu.am running
[ 23] Maps Menu 1.4.1 neugomon mapsmenu.amxx running
[ 24] Plugin Menu 1.9.0-dev+ AMXX Dev Team pluginmenu.amxx running
[ 25] Admin Chat 1.9.0-dev+ AMXX Dev Team adminchat.amxx running
[ 26] Anti Flood 1.9.0-dev+ AMXX Dev Team antiflood.amxx running
[ 27] Scrolling Message 1.9.0-dev+ AMXX Dev Team scrollmsg.amxx running
[ 28] Info. Messages 1.9.0-dev+ AMXX Dev Team imessage.amxx running
[ 29] Admin Votes 1.9.0-dev+ AMXX Dev Team adminvote.amxx running
[ 30] Pause Plugins 1.9.0-dev+ AMXX Dev Team pausecfg.amxx running
[ 31] Stats Configuration 1.9.0-dev+ AMXX Dev Team statscfg.amxx running
[ 32] Restrict Weapons 1.9.0-dev+ AMXX Dev Team restmenu.amxx running
[ 33] Rank Menu 1.1 h1k3 rankmenu.amxx running
[ 34] CSStatsX SQL 0.7.4+2 serfreeman1337 csstatsx_sql.am running
[ 35] AES: StatsX 0.5.9 [REA serfreeman1337/s aes_statsx_cstr running
[ 36] Revive/Mined Die Playe 2.3.9 Emma Jule revive_teammate running
[ 37] [ReAPI] Healthnade 0.0.12f DEV-CS.RU Commun reapi_healthnad running
[ 38] ResetScore 1.0 Leo_[BH] Resetscore.amxx running
[ 39] Damager 0.0.5 steelzzz damager.amxx running
[ 40] Team menu 1.1 NobodyInTeam teammenu.amxx running
[ 41] Vote Knife or Default 0.0.1 brody vote_knife_or_d running
[ 42] Say me and Say hp 1.4 neygomon sayme.amxx running
[ 43] Advanced Kill Assists 1.3c Xelson next21_kill_ass running
[ 44] [ReAPI] No Team Flash 0.0.3 Vaqtincha no_team_flash.a running
[ 45] Multiple Game Names 1.0 mforce gamenamechange. running
[ 46] Connect Info 1.0 Hypa_[KZ] connect_info.am running
[ 47] Block grande info 1.0 neygomon BlockGrenadeInf running
[ 48] Demo Recorder 2.4.1 F@nt0M demo_recorder.a running
[ 49] Lite VoteBan 1.4 neygomon lite_voteban.am running
[ 50] AFK Control ReNew 1.2(a) neygomon afk_control.amx running
[ 51] Sound CSO 1.2 TBONTB Sound_CSO.amxx debug
[ 52] Block Radio Commands 1.0 d3m37r4 block_radiocmd. running
[ 53] BOMB REAL TIMER 6.1 Vaqtincha | Flym bomb_real_timer running
[ 54] [190] Snipers RBS 20.06.06 SKAJIbnEJIb snipers_rbs.amx running
[ 55] [ReAPI] Best player of 1.1.2 F@nt0M best_player_of_ running
[ 56] Killer ScreenFade 0.0.5 Vaqtincha reapi_killer_sc running
[ 57] Frags Counter 1.0 CHEL74 frags_counter.a running
[ 58] [190] Ultimate Flags 22.11.15 SKAJIbnEJIb ultimate_flags. running
[ 59] Adverts 1.0 pUzzlik adverts_message running
[ 60] Spec Money Save 0.2 F@nt0M spec_money_save running
[ 61] SF Bets 0.1.5 serfreeman1337 sf_bets.amxx running
[ 62] Top Bomber 0.1.1 Albertio top_bomber.amxx running
[ 63] CT Bomb Cracker 0.5 Vaqtincha ct_bomb_cracker running
[ 64] Ping Checker 26.0.1 RC1 h1k3 ping_checker.am running
[ 65] Team Balance Control 1.3.9 gyxoBka TeamBalanceCont running
[ 66] Recoil Control 1.5 OT recoil_control. running
[ 67] ASP 1.0.2 iPlague autospawnpoints running
[ 68] Lucky Defuser 1.0.2 iPlague lucky_defuser.a running
[ 69] First Person Death 1.0 Numb first_person_de running
[ 70] SlayNoobs 1.0 neygomon slay_noobs.amxx running
[ 71] Custom Models 1.3.2 neugomon custom_models.a running
[ 72] Team Grenade Trail 1.2 Numb team_grenade_tr running
[ 73] Style C4 Timer 3.1 OciXCrom crx_c4timer.amx running
[ 74] Lite Translit 2.8 neygomon LT_juvinium.amx debug
[ 75] [RE] Talisman Health 1.0 BiZaJe talisman_health running
[ 76] [RE] Talisman Glow Pla 1.0 BiZaJe talisman_glow.a running
[ 77] [RE] Talisman HUD 1.0 BiZaJe talisman_hud.am running
[ 78] [RE] Talisman Sound 1.0 BiZaJe talisman_sound. running
[ 79] Advanced Experience Sy 0.5.9 [REA serfreeman1337/s aes_main.amxx running
[ 80] Accuracy Fix 3.0 Numb accuracy_fix.am running
[ 81] AES: CStrike Addon 0.5.9 [REA serfreeman1337/s aes_exp_cstrike running
[ 82] AES: Informer 0.5.9 [REA serfreeman1337/s aes_informer_sx debug
[ 83] AES: Admin Tools 0.5.9 [REA serfreeman1337/s aes_exp_editor. running
[ 84] AES: Bonus System 0.5.9 Vega serfreeman1337/s aes_bonus_syste running
[ 85] AES: Bonus CSTRIKE 0.5.9.1 [R serfreeman1337/s aes_bonus_cstri running
[ 86] Map Manager: Scheduler 0.2.1 Mistrick map_manager_sch running
[ 87] Map Manager: Rtv 0.1.5 Mistrick map_manager_rtv running
[ 88] Map Manager: Nominatio 0.3.5 Mistrick map_manager_nom debug
[ 89] Map Manager: BlockList 0.0.4 Mistrick map_manager_blo running
[ 90] Map Manager: Online so 0.0.4 Mistrick map_manager_onl running
[ 91] Map Manager: Effects 0.1.3 Mistrick map_manager_eff running
[ 92] Map Manager: Informer 0.0.5 Mistrick map_manager_inf running
[ 93] Map Manager: Sounds 0.0.3 Mistrick map_manager_sou running
[ 94] Map Manager: Advanced 0.1.0 Mistrick map_manager_adv running
[ 95] Map Manager: Priority 0.0.2 Mistrick map_manager_pri running
[ 96] Map Manager: Online ch 1.0.3 Sergey Shorokhov map_manager_onl running
- Автор плагина
- Mistrick
- Версия плагина
- 3.2.1
- Исходный код
-
#include <amxmodx>
#include <map_manager_consts>
#include <map_manager_stocks>
#if AMXX_VERSION_NUM < 183
#include <colorchat>
#endif
#define PLUGIN "Map Manager: Core"
#define VERSION "3.2.1"
#define AUTHOR "Mistrick"
#pragma semicolon 1
//-----------------------------------------------------//
// Consts
//-----------------------------------------------------//
#define MAX_VOTELIST_SIZE 9
new const FILE_MAPS[] = "maps.ini";
//-----------------------------------------------------//
#define get_num(%0) get_pcvar_num(g_pCvars[%0])
const NOT_VOTED = -1;
enum (+=100) {
TASK_PREPARE_VOTE = 100,
TASK_VOTE_TIME
};
enum Forwards {
MAPLIST_LOADED,
MAPLIST_UNLOADED,
CAN_BE_IN_VOTELIST,
CAN_BE_EXTENDED,
PREPARE_VOTELIST,
VOTE_STARTED,
VOTE_CANCELED,
ANALYSIS_OF_RESULTS,
VOTE_FINISHED,
COUNTDOWN,
DISPLAYED_ITEM_NAME
};
enum Cvars {
PREFIX,
VOTELIST_SIZE,
SHOW_RESULT_TYPE,
SHOW_SELECTS,
SHOW_PERCENT,
RANDOM_NUMS,
PREPARE_TIME,
VOTE_TIME,
VOTE_ITEM_OFFSET,
ONLY_EXTERNAL_VOTE_ITEMS,
EARLY_FINISH_VOTE
};
new g_pCvars[Cvars];
new g_iOffset;
new g_iVoteItems;
new g_sVoteList[MAX_VOTELIST_SIZE + 1][MAPNAME_LENGTH];
new g_iVotes[MAX_VOTELIST_SIZE + 1];
new g_iTotalVotes;
new g_iVoted[33];
new g_hForwards[Forwards];
new Array:g_aMapsList = Invalid_Array;
new bool:g_bBlockLoad = false;
new g_iShowType;
new g_iShowPercent;
new g_bShowSelects;
new g_iTimer;
new g_bCanExtend;
new g_iExternalMaxItems;
new g_iCurMap;
new g_iRandomNums[MAX_VOTELIST_SIZE + 1];
new bool:g_bBlockShowVote = false;
new g_iVoteType;
new bool:g_bVoteStarted;
new bool:g_bVoteFinished;
new g_sCurMap[MAPNAME_LENGTH];
new g_sPrefix[48];
new g_sDisplayedItemName[MAX_VOTELIST_SIZE + 1][MAPNAME_LENGTH * 2];
new g_iPlayersNum;
enum _:CustomItemStruct {
CI_Name[64],
CI_Handler,
bool:CI_AddBlank,
bool:CI_AddNumber
}
new Array:g_aCustomItems;
new g_sCustomItemsMenu[MAX_VOTELIST_SIZE][128];
new g_iCustomItemsKeys;
new g_iCustomItemsHandlers[MAX_VOTELIST_SIZE];
new g_iCustomItemsIndex[MAX_VOTELIST_SIZE];
new bool:g_bCustomItemSkipNum[MAX_VOTELIST_SIZE];
public plugin_init()
{
register_plugin(PLUGIN, VERSION + VERSION_HASH, AUTHOR);
register_cvar("mapm_version", VERSION, FCVAR_SERVER | FCVAR_SPONLY);
g_pCvars[PREFIX] = register_cvar("mapm_prefix", "^4[MapManager]");
g_pCvars[VOTELIST_SIZE] = register_cvar("mapm_votelist_size", "5");
g_pCvars[SHOW_RESULT_TYPE] = register_cvar("mapm_show_result_type", "1"); //0 - disable, 1 - menu, 2 - hud
g_pCvars[SHOW_SELECTS] = register_cvar("mapm_show_selects", "1"); // 0 - disable, 1 - all
g_pCvars[SHOW_PERCENT] = register_cvar("mapm_show_percent", "1"); // 0 - disable, 1 - always, 2 - after vote
g_pCvars[RANDOM_NUMS] = register_cvar("mapm_random_nums", "0"); // 0 - disable, 1 - enable
g_pCvars[PREPARE_TIME] = register_cvar("mapm_prepare_time", "5"); // seconds
g_pCvars[VOTE_TIME] = register_cvar("mapm_vote_time", "10"); // seconds
g_pCvars[VOTE_ITEM_OFFSET] = register_cvar("mapm_vote_item_offset", "0");
g_pCvars[ONLY_EXTERNAL_VOTE_ITEMS] = register_cvar("mapm_only_external_vote_items", "0");
g_pCvars[EARLY_FINISH_VOTE] = register_cvar("mapm_early_finish_vote", "0");
g_hForwards[MAPLIST_LOADED] = CreateMultiForward("mapm_maplist_loaded", ET_IGNORE, FP_CELL, FP_STRING);
g_hForwards[MAPLIST_UNLOADED] = CreateMultiForward("mapm_maplist_unloaded", ET_IGNORE);
g_hForwards[PREPARE_VOTELIST] = CreateMultiForward("mapm_prepare_votelist", ET_IGNORE, FP_CELL);
g_hForwards[VOTE_STARTED] = CreateMultiForward("mapm_vote_started", ET_IGNORE, FP_CELL);
g_hForwards[VOTE_CANCELED] = CreateMultiForward("mapm_vote_canceled", ET_IGNORE, FP_CELL);
g_hForwards[ANALYSIS_OF_RESULTS] = CreateMultiForward("mapm_analysis_of_results", ET_CONTINUE, FP_CELL, FP_CELL);
g_hForwards[VOTE_FINISHED] = CreateMultiForward("mapm_vote_finished", ET_IGNORE, FP_STRING, FP_CELL, FP_CELL);
g_hForwards[CAN_BE_IN_VOTELIST] = CreateMultiForward("mapm_can_be_in_votelist", ET_CONTINUE, FP_STRING, FP_CELL, FP_CELL);
g_hForwards[CAN_BE_EXTENDED] = CreateMultiForward("mapm_can_be_extended", ET_CONTINUE, FP_CELL);
g_hForwards[COUNTDOWN] = CreateMultiForward("mapm_countdown", ET_IGNORE, FP_CELL, FP_CELL);
g_hForwards[DISPLAYED_ITEM_NAME] = CreateMultiForward("mapm_displayed_item_name", ET_CONTINUE, FP_CELL, FP_CELL, FP_STRING);
register_menucmd(register_menuid("VoteMenu"), 1023, "votemenu_handler");
register_dictionary("mapmanager.txt");
}
public plugin_natives()
{
register_library("map_manager_core");
g_aMapsList = ArrayCreate(MapStruct, 1);
get_mapname(g_sCurMap, charsmax(g_sCurMap));
g_aCustomItems = ArrayCreate(CustomItemStruct, 1);
register_native("mapm_load_maplist", "native_load_maplist");
register_native("mapm_load_maplist_to_array", "native_load_maplist_to_array");
register_native("mapm_block_load_maplist", "native_block_load_maplist");
register_native("mapm_add_map_to_list", "native_add_map_to_list");
register_native("mapm_get_map_index", "native_get_map_index");
register_native("mapm_get_prefix", "native_get_prefix");
register_native("mapm_set_vote_finished", "native_set_vote_finished");
register_native("mapm_start_vote", "native_start_vote");
register_native("mapm_stop_vote", "native_stop_vote");
register_native("mapm_block_show_vote", "native_block_show_vote");
register_native("mapm_get_votelist_size", "native_get_votelist_size");
register_native("mapm_set_votelist_max_items", "native_set_votelist_max_items");
register_native("mapm_push_map_to_votelist", "native_push_map_to_votelist");
register_native("mapm_get_count_maps_in_vote", "native_get_count_maps_in_vote");
register_native("mapm_get_voteitem_info", "native_get_voteitem_info");
register_native("mapm_get_vote_type", "native_get_vote_type");
register_native("mapm_add_vote_to_item", "native_add_vote_to_item");
register_native("mapm_set_displayed_name", "native_set_displayed_name");
register_native("mapm_add_custom_item", "native_add_custom_item");
register_native("is_vote_started", "native_is_vote_started");
register_native("is_vote_finished", "native_is_vote_finished");
}
public native_load_maplist(plugin, params)
{
enum {
arg_filename = 1,
arg_clearlist,
arg_silent
};
if(get_param(arg_clearlist)) {
if(g_aMapsList == Invalid_Array) {
set_fail_state("Clear empty Array. Don't use this navite before core load maplist.");
return;
}
ArrayClear(g_aMapsList);
new ret;
ExecuteForward(g_hForwards[MAPLIST_UNLOADED], ret);
}
new filename[256];
get_string(arg_filename, filename, charsmax(filename));
load_maplist(g_aMapsList, filename, bool:get_param(arg_silent));
}
public native_load_maplist_to_array(plugin, params)
{
enum {
arg_array = 1,
arg_filename
};
new filename[256];
get_string(arg_filename, filename, charsmax(filename));
return load_maplist(Array:get_param(arg_array), filename, true);
}
public native_block_load_maplist(plugin, params)
{
g_bBlockLoad = true;
}
public native_add_map_to_list(plugin, params)
{
enum {
arg_name = 1,
arg_minplayers,
arg_maxplayers,
arg_priority
};
new map_info[MapStruct];
get_string(arg_name, map_info[Map], charsmax(map_info[Map]));
if(!valid_map(map_info[Map]) || get_map_index(g_aMapsList, map_info[Map]) != INVALID_MAP_INDEX) {
return 0;
}
map_info[MinPlayers] = get_param(arg_minplayers);
map_info[MaxPlayers] = get_param(arg_maxplayers);
new priority = clamp(get_param(arg_priority), 0, 100);
map_info[MapPriority] = priority ? priority : 100;
ArrayPushArray(g_aMapsList, map_info);
return 1;
}
public native_get_map_index(plugin, params)
{
enum { arg_map = 1 };
new map[MAPNAME_LENGTH]; get_string(arg_map, map, charsmax(map));
return get_map_index(g_aMapsList, map);
}
public native_get_prefix(plugin, params)
{
enum {
arg_prefix = 1,
arg_len
};
set_string(arg_prefix, g_sPrefix, get_param(arg_len));
}
public native_set_vote_finished(plugin, params)
{
enum { arg_value = 1 };
g_bVoteFinished = bool:get_param(arg_value);
}
public native_start_vote(plugin, params)
{
enum { arg_type = 1 };
return prepare_vote(get_param(arg_type));
}
public native_stop_vote(plugin, params)
{
stop_vote();
}
public native_block_show_vote(plugin, params)
{
g_bBlockShowVote = true;
}
public native_get_votelist_size(plugin, params)
{
if(g_iExternalMaxItems) {
return g_iExternalMaxItems;
}
return min(min(get_num(VOTELIST_SIZE), MAX_VOTELIST_SIZE), ArraySize(g_aMapsList));
}
public native_set_votelist_max_items(plugin, params)
{
enum { arg_value = 1 };
g_iExternalMaxItems = get_param(arg_value);
}
public native_push_map_to_votelist(plugin, params)
{
enum {
arg_map = 1,
arg_type,
arg_ignore_check
};
if(g_iExternalMaxItems && g_iVoteItems >= g_iExternalMaxItems) {
return PUSH_CANCELED;
}
if(g_iVoteItems >= min(min(get_num(VOTELIST_SIZE), MAX_VOTELIST_SIZE), ArraySize(g_aMapsList))) {
return PUSH_CANCELED;
}
new map[MAPNAME_LENGTH]; get_string(arg_map, map, charsmax(map));
new ignore_checks = get_param(arg_ignore_check);
if(!(ignore_checks & CHECK_IGNORE_VALID_MAP) && !is_map_valid(map)) {
return PUSH_CANCELED;
}
if(is_map_in_vote(map)) {
return PUSH_BLOCKED;
}
if(!(ignore_checks & CHECK_IGNORE_MAP_ALLOWED) && !is_map_allowed(map, get_param(arg_type), get_map_index(g_aMapsList, map))) {
return PUSH_BLOCKED;
}
copy(g_sVoteList[g_iVoteItems], charsmax(g_sVoteList[]), map);
g_iVoteItems++;
return PUSH_SUCCESS;
}
public native_get_count_maps_in_vote(plugin, params)
{
return g_iVoteItems + g_bCanExtend;
}
public native_get_voteitem_info(plugin, params)
{
enum {
arg_item = 1,
arg_map,
arg_len
};
new item = get_param(arg_item);
if(item < 0 || item >= g_iVoteItems + g_bCanExtend) {
return 0;
}
set_string(arg_map, g_sVoteList[item], get_param(arg_len));
return g_iVotes[item];
}
public native_get_vote_type(plugin, params)
{
return g_iVoteType;
}
public native_add_vote_to_item(plugin, params)
{
enum {
arg_item = 1,
arg_value
};
new item = get_param(arg_item);
if(item < 0 || item >= g_iVoteItems + g_bCanExtend) {
return 0;
}
new value = get_param(arg_value);
add_item_votes(item, value);
return 1;
}
public native_set_displayed_name(plugin, params)
{
enum {
arg_item = 1,
arg_displayed_name
}
new item = get_param(arg_item);
if(item < 0 || item >= g_iVoteItems + g_bCanExtend) {
return 0;
}
get_string(arg_displayed_name, g_sDisplayedItemName[item], charsmax(g_sDisplayedItemName[]));
return 0;
}
public native_add_custom_item(plugin, params)
{
enum {
arg_name = 1,
arg_handler,
arg_add_blank,
arg_add_number
}
new custom_item[CustomItemStruct];
new handler[32];
get_string(arg_name, custom_item[CI_Name], charsmax(custom_item[CI_Name]));
get_string(arg_handler, handler, charsmax(handler));
custom_item[CI_AddBlank] = bool:get_param(arg_add_blank);
custom_item[CI_AddNumber] = bool:get_param(arg_add_number);
if(custom_item[CI_AddNumber]) {
custom_item[CI_Handler] = CreateOneForward(plugin, handler, FP_CELL, FP_CELL);
if(custom_item[CI_Handler] == -1) {
return -1;
}
}
return ArrayPushArray(g_aCustomItems, custom_item);
}
public native_is_vote_started(plugin, params)
{
return g_bVoteStarted;
}
public native_is_vote_finished(plugin, params)
{
return g_bVoteFinished;
}
//-----------------------------------------------------//
// Maplist stuff
//-----------------------------------------------------//
public plugin_cfg()
{
new configsdir[256]; get_localinfo("amxx_configsdir", configsdir, charsmax(configsdir));
server_cmd("exec %s/map_manager.cfg", configsdir);
server_exec();
get_pcvar_string(g_pCvars[PREFIX], g_sPrefix, charsmax(g_sPrefix));
replace_color_tag(g_sPrefix, charsmax(g_sPrefix));
// add forward for change file?
if(!g_bBlockLoad) {
load_maplist(g_aMapsList, FILE_MAPS);
}
}
load_maplist(Array:array, const file[], bool:silent = false)
{
new file_path[256]; get_localinfo("amxx_configsdir", file_path, charsmax(file_path));
format(file_path, charsmax(file_path), "%s/%s", file_path, file);
if(!file_exists(file_path)) {
if(!silent) {
new error[192]; formatex(error, charsmax(error), "File doesn't exist ^"%s^".", file_path);
set_fail_state(error);
}
return 0;
}
new f = fopen(file_path, "rt");
if(!f) {
if(!silent) {
set_fail_state("Can't read maps file.");
}
return 0;
}
new map_info[MapStruct], text[48], map[MAPNAME_LENGTH], next_map[MAPNAME_LENGTH], min[3], max[3], priority[4], bool:found_nextmap;
while(!feof(f)) {
fgets(f, text, charsmax(text));
parse(text, map, charsmax(map), min, charsmax(min), max, charsmax(max), priority, charsmax(priority));
if(!map[0] || map[0] == ';' || !valid_map(map) || get_map_index(array, map) != INVALID_MAP_INDEX) continue;
if(!next_map[0]) {
copy(next_map, charsmax(next_map), map);
}
map_info[Map] = map;
map_info[MinPlayers] = str_to_num(min);
map_info[MaxPlayers] = str_to_num(max) == 0 ? 32 : str_to_num(max);
map_info[MapPriority] = str_to_num(priority) == 0 ? 100 : str_to_num(priority);
ArrayPushArray(array, map_info);
min = ""; max = ""; priority = "";
if(equali(map, g_sCurMap)) {
found_nextmap = true;
continue;
}
if(found_nextmap) {
found_nextmap = false;
copy(next_map, charsmax(next_map), map);
}
}
fclose(f);
if(!ArraySize(array)) {
if(!silent) {
new error[192]; formatex(error, charsmax(error), "Nothing loaded from ^"%s^".", file_path);
set_fail_state(error);
}
return 0;
}
if(!silent) {
new ret;
ExecuteForward(g_hForwards[MAPLIST_LOADED], ret, array, next_map);
}
return 1;
}
//-----------------------------------------------------//
// Vote stuff
//-----------------------------------------------------//
prepare_vote(type)
{
if(g_bVoteStarted) {
return 0;
}
g_bVoteStarted = true;
g_bVoteFinished = false;
g_iVoteType = type;
g_iVoteItems = 0;
g_iTotalVotes = 0;
arrayset(g_iVoted, NOT_VOTED, sizeof(g_iVoted));
arrayset(g_iVotes, 0, sizeof(g_iVotes));
new array_size = ArraySize(g_aMapsList);
new is_current_map_in_array = get_map_index(g_aMapsList, g_sCurMap) != INVALID_MAP_INDEX;
new vote_max_items = min(min(get_num(VOTELIST_SIZE), MAX_VOTELIST_SIZE), array_size - is_current_map_in_array);
new ret;
ExecuteForward(g_hForwards[PREPARE_VOTELIST], ret, type);
if(g_iExternalMaxItems) {
vote_max_items = g_iExternalMaxItems;
g_iExternalMaxItems = 0;
}
if(!get_num(ONLY_EXTERNAL_VOTE_ITEMS) && g_iVoteItems < vote_max_items) {
new map_info[MapStruct];
for(new random_map; g_iVoteItems < vote_max_items; g_iVoteItems++) {
do {
random_map = random_num(0, array_size - 1);
ArrayGetArray(g_aMapsList, random_map, map_info);
} while(is_map_in_vote(map_info[Map]) || !is_map_allowed(map_info[Map], PUSH_BY_CORE, random_map) || equali(map_info[Map], g_sCurMap));
copy(g_sVoteList[g_iVoteItems], charsmax(g_sVoteList[]), map_info[Map]);
}
}
if(!g_iVoteItems) {
log_amx("Started vote with ZERO items. Check your maps list!");
}
ExecuteForward(g_hForwards[CAN_BE_EXTENDED], ret, type);
g_bCanExtend = !ret;
if(g_bCanExtend) {
copy(g_sVoteList[g_iVoteItems], charsmax(g_sVoteList[]), g_sCurMap);
}
g_iCurMap = -1;
for(new i; i < g_iVoteItems + g_bCanExtend; i++) {
if(equali(g_sCurMap, g_sVoteList[i])) {
g_iCurMap = i;
break;
}
}
// custom items
new c_items_count = custom_items_builder();
new max_custom_items = MAX_VOTELIST_SIZE - (g_iVoteItems + g_bCanExtend);
if(c_items_count >= max_custom_items) {
log_amx("Check your settings. You have more custom items than can add to vote.");
}
if(get_num(RANDOM_NUMS)) {
arrayset(g_iRandomNums, -1, sizeof(g_iRandomNums));
for(new i; i < g_iVoteItems + g_bCanExtend; i++) {
do {
g_iRandomNums[i] = random_num(0, g_iVoteItems + g_bCanExtend - 1);
} while(in_array(i, g_iRandomNums[i]));
}
} else {
for(new i; i < g_iVoteItems + g_bCanExtend; i++) {
g_iRandomNums[i] = i;
}
}
g_iOffset = get_num(VOTE_ITEM_OFFSET);
if(g_iOffset + g_iVoteItems + g_bCanExtend >= MAX_VOTELIST_SIZE + 1) {
g_iOffset = MAX_VOTELIST_SIZE + 1 - g_iVoteItems - g_bCanExtend;
}
for(new i; i < MAX_VOTELIST_SIZE; i++) {
g_sDisplayedItemName[i][0] = '^0';
}
for(new i; i < g_iVoteItems + g_bCanExtend; i++) {
ExecuteForward(g_hForwards[DISPLAYED_ITEM_NAME], ret, type, i, g_sVoteList[i]);
}
g_iTimer = get_num(PREPARE_TIME) + 1;
countdown(TASK_PREPARE_VOTE);
return 1;
}
custom_items_builder()
{
new len = 0, item = 0;
new custom_item[CustomItemStruct];
new ci_size = ArraySize(g_aCustomItems);
g_iCustomItemsKeys = 0;
arrayset(g_bCustomItemSkipNum, false, sizeof(g_bCustomItemSkipNum));
arrayset(g_iCustomItemsIndex, 0, sizeof(g_iCustomItemsIndex));
for(new i; i < ci_size; i++) {
ArrayGetArray(g_aCustomItems, i, custom_item);
len = 0;
if(custom_item[CI_AddBlank]) {
len += formatex(g_sCustomItemsMenu[i][len], charsmax(g_sCustomItemsMenu[]) - len, "^n");
}
if(custom_item[CI_AddNumber]) {
len += formatex(g_sCustomItemsMenu[i][len], charsmax(g_sCustomItemsMenu[]) - len, "\r%%d. ");
g_iCustomItemsKeys |= (1 << item);
g_iCustomItemsHandlers[item] = custom_item[CI_Handler];
g_iCustomItemsIndex[item] = i;
item++;
} else {
g_bCustomItemSkipNum[i] = true;
}
len += formatex(g_sCustomItemsMenu[i][len], charsmax(g_sCustomItemsMenu[]) - len, "\w%s^n", custom_item[CI_Name]);
}
return item;
}
is_map_allowed(map[], type, index)
{
new ret;
ExecuteForward(g_hForwards[CAN_BE_IN_VOTELIST], ret, map, type, index);
return ret == MAP_ALLOWED;
}
in_array(index, num)
{
for(new i; i < index; i++) {
if(num == g_iRandomNums[i]) {
return true;
}
}
return false;
}
get_original_num(num)
{
for(new i; i < g_iVoteItems + g_bCanExtend; i++) {
if(g_iRandomNums[i] == num) {
return i;
}
}
return 0;
}
public countdown(taskid)
{
if(--g_iTimer > 0) {
if(taskid == TASK_VOTE_TIME && !g_bBlockShowVote) {
new dont_show_result = get_num(SHOW_RESULT_TYPE) == SHOW_DISABLED;
g_iShowType = get_num(SHOW_RESULT_TYPE);
g_iShowPercent = get_num(SHOW_PERCENT);
g_bShowSelects = get_num(SHOW_SELECTS);
new players[32]; get_players(players, g_iPlayersNum, "ch");
for(new i, id; i < g_iPlayersNum; i++) {
id = players[i];
if(!dont_show_result || g_iVoted[id] == NOT_VOTED) {
show_votemenu(id);
}
}
}
new type = COUNTDOWN_UNKNOWN;
switch(taskid) {
case TASK_PREPARE_VOTE: type = COUNTDOWN_PREPARE;
case TASK_VOTE_TIME: type = COUNTDOWN_VOTETIME;
}
new ret;
ExecuteForward(g_hForwards[COUNTDOWN], ret, type, g_iTimer);
set_task(1.0, "countdown", taskid);
} else {
if(taskid == TASK_PREPARE_VOTE) {
start_vote();
} else if(taskid == TASK_VOTE_TIME) {
show_menu(0, 0, "^n", 1);
finish_vote();
}
}
}
start_vote()
{
// server_print("--start vote--");
new ret;
ExecuteForward(g_hForwards[VOTE_STARTED], ret, g_iVoteType);
// TODO: add preview for N seconds
g_iTimer = get_num(VOTE_TIME) + 1;
countdown(TASK_VOTE_TIME);
}
public show_votemenu(id)
{
static menu[512];
new len, keys, percent, item;
len = formatex(menu, charsmax(menu), "\y%L:^n^n", id, g_iVoted[id] != NOT_VOTED ? "MAPM_MENU_VOTE_RESULTS" : "MAPM_MENU_CHOOSE_MAP");
for(item = 0; item < g_iVoteItems + g_bCanExtend; item++) {
len += formatex(menu[len], charsmax(menu) - len, "%s", (item == g_iVoteItems) ? "^n" : "");
if(g_iVoted[id] == NOT_VOTED) {
len += formatex(menu[len], charsmax(menu) - len, "\r%d.\w %s",
(g_iRandomNums[item] + 1 + g_iOffset == 10 ? 0 : g_iRandomNums[item] + 1 + g_iOffset),
(g_sDisplayedItemName[item][0]) ? g_sDisplayedItemName[item] : g_sVoteList[item]);
keys |= (1 << (g_iRandomNums[item] + g_iOffset));
} else {
len += formatex(menu[len], charsmax(menu) - len, "%s%s", (g_iRandomNums[item] + g_iOffset == g_iVoted[id]) ? "\r" : "\d",
(g_sDisplayedItemName[item][0]) ? g_sDisplayedItemName[item] : g_sVoteList[item]);
}
if(g_iShowPercent == PERCENT_ALWAYS || g_iVoted[id] != NOT_VOTED && g_iShowPercent == PERCENT_AFTER_VOTE) {
percent = g_iTotalVotes ? floatround(g_iVotes[item] * 100.0 / g_iTotalVotes) : 0;
len += formatex(menu[len], charsmax(menu) - len, "\d[\r%d%%\d]", percent);
}
if(item == g_iCurMap) {
len += formatex(menu[len], charsmax(menu) - len, "\y[%L]", id, "MAPM_MENU_EXTEND");
}
len += formatex(menu[len], charsmax(menu) - len, "^n");
}
// custom items
for(new i, skip, ci_size = ArraySize(g_aCustomItems); i < ci_size; i++) {
if(g_bCustomItemSkipNum[i]) {
skip++;
}
len += formatex(menu[len], charsmax(menu) - len, g_sCustomItemsMenu[i], item + i + 1 - skip);
}
keys |= g_iCustomItemsKeys << item;
len += formatex(menu[len], charsmax(menu) - len, "^n\d%L \r%d\d %L", id, "MAPM_MENU_LEFT", g_iTimer, id, "MAPM_SECONDS");
if(!keys) keys = (1 << 9);
if(g_iVoted[id] != NOT_VOTED && g_iShowType == SHOW_HUD) {
while(replace(menu, charsmax(menu), "\r", "")){}
while(replace(menu, charsmax(menu), "\d", "")){}
while(replace(menu, charsmax(menu), "\w", "")){}
while(replace(menu, charsmax(menu), "\y", "")){}
set_hudmessage(0, 55, 255, 0.02, -1.0, 0, 6.0, 1.0, 0.1, 0.2, 4);
show_hudmessage(id, "%s", menu);
} else {
show_menu(id, keys, menu, -1, "VoteMenu");
}
}
public votemenu_handler(id, key)
{
// custom items
if(g_iCustomItemsIndex[0] && key >= g_iVoteItems + g_bCanExtend) {
new item = key - (g_iVoteItems + g_bCanExtend);
new ci_handler = g_iCustomItemsHandlers[item];
new ret;
ExecuteForward(ci_handler, ret, id, g_iCustomItemsIndex[item]);
show_votemenu(id);
return PLUGIN_HANDLED;
}
if(g_iVoted[id] != NOT_VOTED) {
show_votemenu(id);
return PLUGIN_HANDLED;
}
new original = get_original_num(key - g_iOffset);
add_item_votes(original, 1);
g_iVoted[id] = key;
// TODO: add forward if someone want add more votes for admin, etc.
if(g_bShowSelects) {
new name[32]; get_user_name(id, name, charsmax(name));
if(original == g_iCurMap) {
client_print_color(0, id, "%s^3 %L", g_sPrefix, LANG_PLAYER, "MAPM_CHOSE_EXTEND", name);
} else {
client_print_color(0, id, "%s^3 %L", g_sPrefix, LANG_PLAYER, "MAPM_CHOSE_MAP", name, g_sVoteList[original]);
}
}
if(g_iShowType != SHOW_DISABLED) {
show_votemenu(id);
}
return PLUGIN_HANDLED;
}
add_item_votes(item, value)
{
g_iVotes[item] += value;
g_iTotalVotes += value;
if(get_num(EARLY_FINISH_VOTE) && g_iTotalVotes == g_iPlayersNum) {
g_iTimer = 0;
client_print_color(0, print_team_default, "%s^1 %L", g_sPrefix, LANG_PLAYER, "MAPM_EARLY_FINISH_VOTE");
}
}
finish_vote()
{
g_bVoteStarted = false;
g_bBlockShowVote = false;
// vote results
// pre forward
new ret;
ExecuteForward(g_hForwards[ANALYSIS_OF_RESULTS], ret, g_iVoteType, g_iTotalVotes);
if(ret) {
if(ret == ABORT_VOTE_WITH_FORWARD) {
ExecuteForward(g_hForwards[VOTE_CANCELED], ret, g_iVoteType);
}
return;
}
g_bVoteFinished = true;
new max_vote = 0;
if(g_iTotalVotes) {
for(new i = 1; i < g_iVoteItems + 1; i++) {
if(random_num(0, 99) >= 50) {
if(g_iVotes[max_vote] < g_iVotes[i]) max_vote = i;
} else {
if(g_iVotes[max_vote] <= g_iVotes[i]) max_vote = i;
}
}
}
else {
max_vote = random_num(0, g_iVoteItems - 1);
}
// post forward
// add blocking?
ExecuteForward(g_hForwards[VOTE_FINISHED], ret, g_sVoteList[max_vote], g_iVoteType, g_iTotalVotes);
}
stop_vote()
{
if(task_exists(TASK_VOTE_TIME)) {
show_menu(0, 0, "^n", 1);
}
remove_task(TASK_PREPARE_VOTE);
remove_task(TASK_VOTE_TIME);
g_bVoteStarted = false;
g_bVoteFinished = false;
new ret;
ExecuteForward(g_hForwards[VOTE_CANCELED], ret, g_iVoteType);
}
//-----------------------------------------------------//
// Usefull func
//-----------------------------------------------------//
get_map_index(Array:array, map[])
{
for(new i = 0, map_info[MapStruct], size = ArraySize(array); i < size; i++) {
ArrayGetArray(array, i, map_info);
if(equali(map, map_info[Map])) return i;
}
return INVALID_MAP_INDEX;
}
bool:is_map_in_vote(map[])
{
for(new i; i < g_iVoteItems; i++) {
if(equali(map, g_sVoteList[i])) {
return true;
}
}
return false;
}
Сегодня решил сменить плагин с Map Manager 2.5.61 на Map Manager [Modular] 3.2.1, ибо функционал больше и обновляется хотя бы, и теперь столкнулся с проблемами которые я описал выше.
В этой теме было размещено решение! Перейти к решению.