- #include <amxmodx>
- #include <fakemeta>
- #include <hamsandwich>
- #define PLUGIN "Bonus"
- #define VERSION "3.6"
- #define AUTHOR "allan"
-
- #include <cstrike>
-
- #define IsUserConnested(%1) (bool:(is_user_connected(%1)))
-
- #define MsgId_SayText 76
-
- #define m_iTeam 114
- #define fm_cs_get_user_team_index(%1) get_pdata_int(%1, m_iTeam)
-
- #define PREFIX_CHAT "^1[^4Bonus^1]"
-
- #define NICE_PLAYER_ARMOR 100
- // #define NICE_PLAYER_MONEY 1000
-
- new Float:g_flNiceDamage[33];
-
- new g_iMaxPlayers;
-
- public plugin_init()
- {
- RegisterHam(Ham_TakeDamage, "player", "HamHook_TakeDamagePost", true);
-
- register_logevent("LogEvent_RoundStart", 2, "0=World triggered", "1=Round_Start");
-
- g_iMaxPlayers = get_maxplayers();
- }
-
- public client_disconnect(pId)
- {
- g_flNiceDamage[pId] = 0.0;
- }
-
- public HamHook_TakeDamagePost(iVictim, iInflictor, iAttacker, Float:flDamage, bitsDamage)
- {
- #if !defined DMG_GRENADE
- #define DMG_GRENADE (1<<24)
- #endif
-
- if(!iAttacker || iAttacker > g_iMaxPlayers || iVictim == iAttacker)
- return HAM_IGNORED;
-
- if(fm_cs_get_user_team_index(iVictim) == fm_cs_get_user_team_index(iAttacker))
- return HAM_IGNORED;
-
- if(iInflictor == iAttacker || bitsDamage & DMG_GRENADE)
- {
- g_flNiceDamage[iAttacker] += flDamage;
- }
-
- return HAM_IGNORED;
- }
-
- public LogEvent_RoundStart()
- {
- set_task(1.0, "Task_GetPlayerBest");
- set_task(1.3, "Task_ResetPlayerBest")
- }
-
- public Task_GetPlayerBest()
- {
- new iPlayers[32], iPlayersNum, pPlayer;
- new Float:flpDamage, Float:iTempDamage, pId;
- get_players(iPlayers, iPlayersNum, "h");
-
- for(new i; i < iPlayersNum; i++)
- {
- pPlayer = iPlayers[i];
-
- flpDamage = g_flNiceDamage[pPlayer];
- if(flpDamage > iTempDamage)
- {
- pId = pPlayer;
- iTempDamage = flpDamage;
- }
- }
-
- if(iTempDamage)
- {
- static szName[32], szMessage[192];
- get_user_name(pId, szName, charsmax(szName));
-
- UTIL_GiveNicePlayer(pId);
-
- for(new i = 1; i <= g_iMaxPlayers; i++)
- {
- if(!IsUserConnested(i)) continue;
-
- formatex(szMessage, charsmax(szMessage), "%s !yЛучший игрок предыдущего раунда: !g%s !y- нанесенный урон: !g%d !y!", PREFIX_CHAT, szName, floatround(iTempDamage));
- UTIL_SayText(i, szMessage);
- UTIL_SayText(i, "%s !yОн получил: !g%d брони !yи !gкомплект гранат !y!", PREFIX_CHAT, NICE_PLAYER_ARMOR);
- // UTIL_SayText(i, "%s !yОн получил: !g%d$!y, !g%d брони !yи !gкомплект гранат !y!", PREFIX_CHAT, NICE_PLAYER_MONEY, NICE_PLAYER_ARMOR);
- // UTIL_SayText(i, "%s !yОн получил: !g%d$ !yи !gкомплект гранат !y!", PREFIX_CHAT, NICE_PLAYER_MONEY);
- }
- }
- }
-
- public Task_ResetPlayerBest()
- {
- for(new pId = 1; pId <= g_iMaxPlayers; pId++)
- {
- g_flNiceDamage[pId] = 0.0;
- }
- }
-
- public UTIL_GiveNicePlayer(pId)
- {
- // cs_set_user_money(pId, (cs_get_user_money(pId) + NICE_PLAYER_MONEY), 1);
- set_pev(pId, pev_armorvalue, NICE_PLAYER_ARMOR.0);
- fm_give_item(pId, "weapon_flashbang");
- fm_give_item(pId, "weapon_hegrenade");
- fm_give_item(pId, "weapon_smokegrenade");
- }
-
- stock fm_give_item(id, const szItem[])
- {
- new iEntity = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, szItem));
- if(!pev_valid(iEntity)) return 0;
- new Float:fOrigin[3];
- pev(id, pev_origin, fOrigin);
- set_pev(iEntity, pev_origin, fOrigin);
- set_pev(iEntity, pev_spawnflags, pev(iEntity, pev_spawnflags) | SF_NORESPAWN);
- dllfunc(DLLFunc_Spawn, iEntity);
- new iSolid = pev(iEntity, pev_solid);
- dllfunc(DLLFunc_Touch, iEntity, id);
- if(pev(iEntity, pev_solid) == iSolid)
- {
- engfunc(EngFunc_RemoveEntity, iEntity);
- return -1;
- }
- return iEntity;
- }
-
- stock UTIL_SayText(pId, const szMessage[], any:...)
- {
- new iPlayers[32], iCount = 1;
- new szMsg[191]; vformat(szMsg, charsmax(szMsg), szMessage, 3);
-
- replace_all(szMsg, 190, "!g", "^4");
- replace_all(szMsg, 190, "!y", "^1");
- replace_all(szMsg, 190, "!t", "^3");
-
- if(pId) iPlayers[0] = pId; else get_players(iPlayers, iCount, "ch");
- {
- for(new pId = 0; pId < iCount; pId++)
- {
- if(IsUserConnested(iPlayers[pId]))
- {
- message_begin(MSG_ONE_UNRELIABLE, MsgId_SayText, _, iPlayers[pId]);
- write_byte(iPlayers[pId]);
- write_string(szMsg);
- message_end();
- }
- }
- }
- }