/** * Modified by Safety1st * 6/3/2014 * * Changes are: * • added EXCLUDE_FLAGS option; * • proposed fix to always get the prise menu; * • fix for buy menu overlapping; * • added warning sound to attract 'best player' attention; * • prise menu is shown only during 15 seconds; * • removed max money amount limiting * • fixed bug with array size for players (thanks to ExTPuMaJI) * • a few minor optimizations. */ #include <amxmodx> #include <cstrike> #include <fun> #include <hamsandwich> // customizable parameters #define MAX_PLAYERS 32 // Максимальное кол-во игроков на сервере, заменить своим (по умолчанию 32) #define MIN_PLAYERS 6 // Минимальное кол-во игроков, присутствующих на сервере, необходимое для работы плагина (по умолчанию 2) #define ROUND_NUM 3 // Порядковый номер раунда от момента начала игры, с которого плагин будет работать (по умолчанию 3) #define MIN_MONEY 200 // Минимальное кол-во призовых у.е., которое может получить игрок (по умолчанию 200) #define MAX_MONEY 5000 // Максимальное кол-во призовых у.е., которое может получить игрок (по умолчанию 5000) //#define EXCLUDE_FLAGS ADMIN_LEVEL_H // uncomment to exclude players with certain flags; by default it is flag 't' // end of customizable parameters #pragma semicolon 1 #if AMXX_VERSION_NUM < 183 #define MENU_FIX // fix for AMXX menus, more info here: https://bugs.alliedmods.net/show_bug.cgi?id=4778 #include <fakemeta> const m_iMenu = 205; // cbaseplayer offset #endif #define MENU_KEYS (MENU_KEY_1|MENU_KEY_2) #define PRIMARY_WEAPONS (1<<CSW_SCOUT|1<<CSW_XM1014|1<<CSW_MAC10|1<<CSW_AUG|1<<CSW_UMP45|1<<CSW_SG550|1<<CSW_GALIL|1<<CSW_FAMAS|1<<CSW_AWP|1<<CSW_MP5NAVY|1<<CSW_M249|1<<CSW_M3|1<<CSW_M4A1|1<<CSW_TMP|1<<CSW_G3SG1|1<<CSW_SG552|1<<CSW_AK47|1<<CSW_P90) #define SECONDARY_WEAPONS (1<<CSW_P228|1<<CSW_ELITE|1<<CSW_FIVESEVEN|1<<CSW_USP|1<<CSW_GLOCK18|1<<CSW_DEAGLE) enum _:WEAPON_DATA_SIZE { Data_Name[32], Data_Item[24], Data_Index, Data_Ammo }; new g_Data[][WEAPON_DATA_SIZE] = { {"IMI Galil", "weapon_galil", CSW_GALIL, 90}, {"GIAT FAMAS", "weapon_famas", CSW_FAMAS, 90}, {"AK-47", "weapon_ak47", CSW_AK47, 90}, {"Colt M4A1", "weapon_m4a1", CSW_M4A1, 90}, {"Steyr Scout", "weapon_scout", CSW_SCOUT, 90}, {"AI Arctic Warfare Magnum", "weapon_awp", CSW_AWP, 30}, {"FN Minimi M249 Para", "weapon_m249", CSW_M249, 200}, {"Desert Eagle", "weapon_deagle", CSW_DEAGLE, 35} }; new g_iPlayerFrags[MAX_PLAYERS + 1]; new g_iPlayerDamage[MAX_PLAYERS + 1]; new g_iPlayers[32]; new g_iPlayersNum; new g_szBestPlayerName[32]; new g_iBestPlayer; new g_iRandomPrise; new g_iRoundCounter; new g_iResetSize; public plugin_init() { register_plugin("Best Player", "0.2b", "Subb98"); register_event("HLTV", "EventNewRound", "a", "1=0", "2=0"); register_event("Damage", "EventDamage", "b", "2!0", "3=0", "4!0"); register_event("DeathMsg", "EventDeathMsg", "a", "1>0"); register_logevent( "EventNewGame", 2, "0=World triggered", "1&Restart_Round_", "1=Game_Commencing" ); register_logevent( "EventRoundStart", 2, "0=World triggered", "1=Round_Start" ); register_logevent( "EventRoundEnd", 2, "1=Round_End" ); RegisterHam( Ham_Spawn, "player", "Fwd_HamPlayerSpawn_Post", .Post = 1 ); register_menucmd(register_menuid("Prise_Menu"), MENU_KEYS, "HandleMenu"); g_iResetSize = get_maxplayers() + 1; } public plugin_cfg() { new const szDisableMapTypes[][] = {"35hp_", "ka_"}; // Типы карт, на которых плагин не будет работать new szMapname[32]; get_mapname(szMapname, charsmax(szMapname)); for(new i; i < sizeof szDisableMapTypes; i++) if(equali(szMapname, szDisableMapTypes[i], strlen(szDisableMapTypes[i]))) pause("ad"); } public EventNewRound() { g_iRoundCounter++; Reset(); } public EventNewGame() g_iRoundCounter = 0; public EventRoundStart() g_iBestPlayer = 0; public EventDamage(const id) { static pAttacker; pAttacker = get_user_attacker(id); if(is_user_connected(pAttacker) && cs_get_user_team(pAttacker) != cs_get_user_team(id) && pAttacker != id) g_iPlayerDamage[pAttacker] += read_data(2) /* DamageTake */; } public EventDeathMsg() g_iPlayerFrags[ read_data(1) /* killer */ ]++; public EventRoundEnd() { if( g_iRoundCounter < ROUND_NUM || get_playersnum() < MIN_PLAYERS ) return; new id, i, iFrags, iBestPlayerFrags, iCount; get_players(g_iPlayers, g_iPlayersNum, "ch"); // except bots & hltv for( i = 0; i < g_iPlayersNum; i++ ) { id = g_iPlayers[i]; #if defined EXCLUDE_FLAGS if( get_user_flags(id) & EXCLUDE_FLAGS ) continue; #endif iFrags = g_iPlayerFrags[id]; if( !iFrags || iFrags < iBestPlayerFrags ) continue; if( iFrags > iBestPlayerFrags ) { g_iBestPlayer = id; iBestPlayerFrags = iFrags; iCount = 0; } g_iPlayers[iCount++] = id; } // in case there are some players with the same frags count for( i = 1; i < iCount; i++ ) { id = g_iPlayers[i]; if(g_iPlayerDamage[id] > g_iPlayerDamage[g_iBestPlayer]) g_iBestPlayer = id; } if(g_iBestPlayer) { get_user_name(g_iBestPlayer, g_szBestPlayerName, charsmax(g_szBestPlayerName)); client_print(0, print_chat, "Лучшим за раунд оказался %s, он будет награждён", g_szBestPlayerName); } } public Fwd_HamPlayerSpawn_Post(id) { if( !is_user_alive(id) || id != g_iBestPlayer ) return; ShowMenu(id); static szWarnSound[] = "buttons/blip2"; client_cmd( id, "spk ^"%s^"", szWarnSound ); } Reset() { arrayset( g_iPlayerFrags, 0, g_iResetSize ); arrayset( g_iPlayerDamage, 0, g_iResetSize ); } ShowMenu(const id) { new szMenu[256], szRandomPrise[34]; g_iRandomPrise = random_num(0, 3); switch(g_iRandomPrise) { case 0: add(szRandomPrise, charsmax(szRandomPrise), "оружие"); case 1: add(szRandomPrise, charsmax(szRandomPrise), "набор гранат"); case 2: add(szRandomPrise, charsmax(szRandomPrise), "бронежилет и шлем"); case 3: add(szRandomPrise, charsmax(szRandomPrise), "деньги"); } formatex(szMenu, charsmax(szMenu), "\yВаш приз - %s^n^n1. \wВзять приз^n\y2. \wОтказаться от приза", szRandomPrise); #if defined MENU_FIX set_pdata_int( id, m_iMenu, 0 ); #endif show_menu(id, MENU_KEYS, szMenu, 15, "Prise_Menu"); } public HandleMenu(const id, const iKey) { switch(iKey) { case 0: GiveRandomPrise(id); case 1: client_print(0, print_chat, "%s отказался от приза", g_szBestPlayerName); } } GiveRandomPrise(const id) { switch(g_iRandomPrise) { case 0: GiveRandomWeapon(id); case 1: { give_item(id, "weapon_hegrenade"); give_item(id, "weapon_flashbang"); give_item(id, "weapon_smokegrenade"); cs_set_user_bpammo(id, CSW_FLASHBANG, 2); client_print(0, print_chat, "%s взял приз - набор гранат", g_szBestPlayerName); } case 2: { cs_set_user_armor(id, 100, CS_ARMOR_VESTHELM); client_print(0, print_chat, "%s взял приз - бронежилет и шлем", g_szBestPlayerName); } case 3: { new iMoney = random_num(MIN_MONEY, MAX_MONEY); cs_set_user_money(id, cs_get_user_money(id) + iMoney); client_print(0, print_chat, "%s взял приз - $%d", g_szBestPlayerName, iMoney); } } } GiveRandomWeapon(const id) { new iNum = random_num(0, charsmax(g_Data)); DropWeapon(id, iNum); give_item(id, g_Data[iNum][Data_Item]); cs_set_user_bpammo(id, g_Data[iNum][Data_Index], g_Data[iNum][Data_Ammo]); client_print(0, print_chat, "%s взял приз - %s", g_szBestPlayerName, g_Data[iNum][Data_Name]); } DropWeapon(const id, const iType) { new iWeapons[32], iWeponsNum; get_user_weapons(id, iWeapons, iWeponsNum); for(new i; i < iWeponsNum; i++) { if((iType == charsmax(g_Data) ? (SECONDARY_WEAPONS & (1<<iWeapons[i])) : (PRIMARY_WEAPONS & (1<<iWeapons[i])))) { new szWeaponName[24]; get_weaponname(iWeapons[i], szWeaponName, charsmax(szWeaponName)); engclient_cmd(id, "drop", szWeaponName); } } }
Ребят кто сможет в этот плагин, colorchat запихнуть?
Чтобы красивее смотрелось, а то так там стандартный цвет.
Заранее спасибо
Сообщение отредактировал brutjkee: 26 Июль 2014 - 14:41