#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <hamsandwich>
#include <fun>
#define MAX_PLAYERS 32
#define PLUGIN "Best Player"
#define VERSION "2.2.9"
#define AUTHOR "DUKKHAZ0R | Jack2345"
#if AMXX_VERSION_NUM < 183
#define FIX_MENU
#include <fakemeta>
const m_iMenu = 205;
#endif
const PRIMARY_WEAPONS_BIT_SUM =
(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)
const SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE)
const KEYSMENU = MENU_KEY_4|MENU_KEY_6
//АК47,М16,AWP,Deagle,Scout,Пулемет, GALIL, Армор + все гранаты.
enum _:WEAPON_DATA_SIZE
{
sz_DataName[32],
sz_DataItem[24],
i_Index,
i_DataAmmo
}
new g_szWeaponData[][WEAPON_DATA_SIZE] =
{
{ "AK47", "weapon_ak47", CSW_AK47, 90 }, //1
{ "M4A1", "weapon_m4a1", CSW_M4A1, 90 }, //2
{ "AWP", "weapon_awp", CSW_AWP, 30 }, //3
{ "SCOUT", "weapon_scout", CSW_SCOUT, 90 },
{ "M249", "weapon_m249", CSW_M249, 200 },//5
{ "GALIL", "weapon_galil", CSW_GALIL, 90 },
{ "DEAGLE", "weapon_deagle", CSW_DEAGLE, 35 }
}
new g_iBestPlayer;
new g_iRoundCounter;
new szRandomPrice;
new g_szBestPlayerName[32];
new g_iDamage[MAX_PLAYERS + 1];
new g_pCvarBestRoundAccess;
new g_pCvarBestMinPlayers;
const RESET = 0
new g_iFlag;
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
g_pCvarBestRoundAccess = register_cvar("best_player_round_access", "3");
g_pCvarBestMinPlayers = register_cvar("best_player_minplayer", "5");
g_iFlag = register_cvar("best_player_flag_not_works", "r");
register_logevent("Event_Restart_Round", 2, "0=World triggered", "1&Restart_Round_", "1=Game_Commencing");
register_logevent("Event_New_Round", 2, "1=Round_Start");
register_logevent("Event_End_Round", 2, "1=Round_End");
register_event("Damage", "Event_Take_Damage", "b", "2!0", "3=0", "4!0");
RegisterHam(Ham_Spawn, "player", "fw_HamSpawn_Post", .Post = 1);
register_menucmd(register_menuid("price_menu"), KEYSMENU, "menu_handler");
register_dictionary("best_player.txt");
new configsDir[64];
get_configsdir(configsDir, 63);
server_cmd("exec %s/best_player.cfg", configsDir);
}
public plugin_cfg()
{
new szMapPrefix[][] = {"35hp_", "1hp_", "awp_", "deathrun_"};
new szMapName[32]; get_mapname( szMapName, charsmax(szMapName));
for( new i; i < sizeof( szMapPrefix ); i++)
{
if(containi( szMapName, szMapPrefix[i] ) != -1)
{
pause("ad");
break;
}
}
}
public client_disconnect(id)
{
g_iDamage[id] = 0;
}
public client_connect(id)
{
g_iDamage[id] = 0;
}
public Event_Take_Damage(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_iDamage[pAttacker] += read_data(2);
}
public Event_New_Round()
{
g_iRoundCounter++;
Reset();
}
public Event_Restart_Round()
{
g_iRoundCounter = RESET;
}
public Event_End_Round()
{
if(g_iRoundCounter < get_pcvar_num(g_pCvarBestRoundAccess) || get_playersnum() < get_pcvar_num(g_pCvarBestMinPlayers))
return;
new players[32], pnum, id, iDamage, iBestPlayerDamage;
get_players( players, pnum, "ch" );
for(new i; i < pnum; i++)
{
id = players[i];
iDamage = g_iDamage[id];
if(!iDamage || iDamage < iBestPlayerDamage)
continue;
if( iDamage > iBestPlayerDamage )
{
g_iBestPlayer = id;
iBestPlayerDamage = iDamage;
}
}
if(g_iBestPlayer)
{
get_user_name(g_iBestPlayer, g_szBestPlayerName, charsmax(g_szBestPlayerName));
ChatColor(0, "%L", 0, "BONUS_PLAYER", g_szBestPlayerName, g_iDamage[g_iBestPlayer]);
}
}
public fw_HamSpawn_Post(id)
{
new szFlag[32]
get_cvar_string("best_player_flag_not_works", szFlag, charsmax(szFlag))
g_iFlag = read_flags(szFlag)
if(!is_user_alive(id) || get_user_flags(id) & g_iFlag || id != g_iBestPlayer)
return;
ShowMenu(id)
}
ShowMenu(id)
{
Reset();
static szMenu[512], iLen;
szRandomPrice = random_num(0, 7);
switch( szRandomPrice )
{
case 7: iLen = formatex( szMenu, charsmax(szMenu), "%L", LANG_PLAYER, "BONUS_MENU_ONE");
default: iLen = formatex( szMenu, charsmax(szMenu), "%L", LANG_PLAYER, "BONUS_MENU_TWO", g_szWeaponData[szRandomPrice][sz_DataName]);
}
iLen += formatex( szMenu[iLen], charsmax(szMenu) - iLen, "%L", LANG_PLAYER, "BONUS_MENU_THREE");
iLen += formatex( szMenu[iLen], charsmax(szMenu) - iLen, "%L", LANG_PLAYER, "BONUS_MENU_FOUR");
#if defined FIX_MENU
set_pdata_int(id, m_iMenu, 0 );
#endif
show_menu( id, KEYSMENU, szMenu, -1, "price_menu" );
return PLUGIN_HANDLED;
}
public menu_handler(id, iKey)
{
switch(iKey)
{
case 3:
{
switch( szRandomPrice )
{
case 7:
{
ChatColor(0, "%L", 0, "BONUS_CONGRATULATE", g_szBestPlayerName)
equipment(id)
return
}
case 6: drop_weapons(id, 2);
default: drop_weapons(id, 1);
}
give_item( id, g_szWeaponData[szRandomPrice][sz_DataItem]);
cs_set_user_bpammo(id, g_szWeaponData[szRandomPrice][i_Index], g_szWeaponData[szRandomPrice][i_DataAmmo]);
ChatColor(0, "%L", 0, "BONUS_CONGRATULATE_EPS", g_szBestPlayerName, g_szWeaponData[szRandomPrice][sz_DataName]);
}
case 5:
{
ChatColor(0, "%L", 0, "BONUS_REFUSED", g_szBestPlayerName);
}
}
g_iBestPlayer = RESET;
}
public equipment(id)
{
give_item( id, "weapon_hegrenade" )
give_item( id, "weapon_flashbang" )
give_item( id, "weapon_flashbang" )
give_item( id, "weapon_smokegrenade" )
cs_set_user_armor( id, 100, CS_ARMOR_VESTHELM )
}
Reset()
{
arrayset( g_iDamage, RESET, MAX_PLAYERS + 1 );
}
stock drop_weapons(id, dropwhat)
{
static weapons[32], num, i, weaponid
num = 0
get_user_weapons(id, weapons, num)
for (i = 0; i < num; i++)
{
weaponid = weapons[i]
if ((dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM)) || (dropwhat == 2 && ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM)))
{
static wname[32]
get_weaponname(weaponid, wname, sizeof wname - 1)
engclient_cmd(id, "drop", wname)
}
}
}
/* Сток цветного чата */
stock ChatColor(const id, const input[], any:...)
{
new count = 1, players[32]
static msg[191]
vformat(msg, 190, input, 3)
replace_all(msg, 190, "!g", "^4") // Зелёный
replace_all(msg, 190, "!y", "^1") // Стандартный
replace_all(msg, 190, "!t", "^3") // Цвет команды
if (id) players[0] = id; else get_players(players, count, "ch")
{
for (new i = 0; i < count; i++)
{
if (is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i])
write_byte(players[i]);
write_string(msg);
message_end();
}
}
}
}