// Copyright © 2016/2019 Vaqtincha
/********************************************
* Support forum:
* http://goldsrc.ru
*
*********************************************/
enum REWARD_DATA { szWeapon[10], iReward }
/**■■■■■■■■■■■■■■■■■■■■■■■■■■■■ CONFIG START ■■■■■■■■■■■■■■■■■■■■■■■■■■■■*/
#define HEADSHOT_BONUS 100
#define HP_BONUS 10
// #define HEADSHOT_BONUS_SHOW_HUD 0.93, 0.80
new const g_szShortWeaponNames[][REWARD_DATA] = {
// pistols:
{ "p228", 300 },
{ "usp", 350 },
{ "glock18", 350 },
{ "elite", 300 },
{ "deagle", 300 },
{ "fiveseven", 300 },
// submachine guns:
{ "mac10", 600 },
{ "tmp", 600 },
{ "mp5navy", 600 },
{ "ump45", 600 },
{ "p90", 300 },
// rifles:
{ "galil", 300 },
{ "famas", 300 },
{ "ak47", 300 },
{ "m4a1", 300 },
{ "sg552", 300 },
{ "aug", 300 },
// sniper rifles:
{ "scout", 300 },
{ "awp", 100 },
{ "g3sg1", 300 },
{ "sg550", 300 },
// shotguns & machine guns:
{ "xm1014", 900 },
{ "m3", 900 },
{ "m249", 300 },
// other:
{ "grenade", 400 },
{ "knife", 1500 }
}
/**■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ CONFIG END ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■*/
#define PL_VERSION "0.4"
#include <amxmodx>
#include <reapi>
new HookChain:g_hAddAccount, Trie:g_tWeaponRewards
new g_iReward[MAX_CLIENTS + 1]
new mp_maxmoney
public plugin_init()
{
register_plugin("Kill Rewards", PL_VERSION, "Vaqtincha")
register_concmd("kr_set_reward", "ConCmd_SetReward", ADMIN_CFG, "<weapon name> <reward>")
register_concmd("kr_rewards", "ConCmd_PrintRewards", _, "<rewards info>")
RegisterHookChain(RG_CSGameRules_DeathNotice, "CSGameRules_DeathNotice", .post = true)
DisableHookChain(g_hAddAccount = RegisterHookChain(RG_CBasePlayer_AddAccount, "CBasePlayer_AddAccount", .post = false))
g_tWeaponRewards = TrieCreate()
mp_maxmoney = get_cvar_pointer("mp_maxmoney")
for (new i = 0; i < sizeof(g_szShortWeaponNames); i++)
{
TrieSetCell(g_tWeaponRewards, g_szShortWeaponNames[i][szWeapon], g_szShortWeaponNames[i][iReward])
}
}
public plugin_end()
{
if (g_tWeaponRewards)
TrieDestroy(g_tWeaponRewards)
}
public client_putinserver(pPlayer) {
g_iReward[pPlayer] = 0
}
public ConCmd_PrintRewards(const pPlayer)
{
PrintConsole(pPlayer, "%-13.12s %-11.10s", "Weapon Name:", "Reward")
for (new iRewards, i = 0; i < sizeof(g_szShortWeaponNames); i++)
{
TrieGetCell(g_tWeaponRewards, g_szShortWeaponNames[i][szWeapon], iRewards)
PrintConsole(pPlayer, "%-13.12s %-6.5d", g_szShortWeaponNames[i][szWeapon], iRewards)
}
return PLUGIN_HANDLED
}
public ConCmd_SetReward(const pPlayer, const level)
{
if (!(get_user_flags(pPlayer) & level))
return PLUGIN_HANDLED
if (read_argc() < 3)
{
PrintConsole(pPlayer, "Usage: <weapon name> <reward>")
return PLUGIN_HANDLED
}
new szWeaponName[10], szValue[6]
if (read_argv(1, szWeaponName, charsmax(szWeaponName)) > 0 &&
read_argv(2, szValue, charsmax(szValue)) > 0
)
{
strtolower(szWeaponName)
TrieSetCell(g_tWeaponRewards, szWeaponName, str_to_num(szValue))
}
return PLUGIN_HANDLED
}
public CSGameRules_DeathNotice(const pPlayer, const pKiller, pevInflictor)
{
if (pPlayer == pKiller || !is_user_connected(pKiller) || HasMaxMoney(pKiller))
return HC_CONTINUE
if (pKiller == pevInflictor)
{
new szWeaponName[32]
pevInflictor = get_member(pKiller, m_pActiveItem)
if (!is_nullent(pevInflictor))
{
get_entvar(pevInflictor, var_classname, szWeaponName, charsmax(szWeaponName))
TrieGetCell(g_tWeaponRewards, szWeaponName[7], g_iReward[pKiller])
}
}
else if (FClassnameIs(pevInflictor, "grenade"))
{
TrieGetCell(g_tWeaponRewards, "grenade", g_iReward[pKiller])
}
if (g_iReward[pKiller] > 0)
{
#if defined HEADSHOT_BONUS
if (get_member(pPlayer, m_bHeadshotKilled))
{
g_iReward[pKiller] += HEADSHOT_BONUS
#if defined HEADSHOT_BONUS_SHOW_HUD
set_hudmessage(0, 220, 0, HEADSHOT_BONUS_SHOW_HUD, 0, 1.0, 1.0, 0.1, 1.0, -1)
show_hudmessage(pKiller, "+%d HS", HEADSHOT_BONUS)
#endif
}
#endif
#if defined HP_BONUS
i doubt code must be here :)
#endif
EnableHookChain(g_hAddAccount)
}
return HC_CONTINUE
}
public CBasePlayer_AddAccount(const pPlayer, const amount, const RewardType:type, bool:bTrackChange)
{
DisableHookChain(g_hAddAccount)
if (type == RT_ENEMY_KILLED && g_iReward[pPlayer] > 0)
{
SetHookChainArg(2, ATYPE_INTEGER, g_iReward[pPlayer])
g_iReward[pPlayer] = 0
}
return HC_CONTINUE
}
stock bool:HasMaxMoney(const pPlayer) {
return bool:(get_member(pPlayer, m_iAccount) >= get_pcvar_num(mp_maxmoney))
}
stock PrintConsole(const pPlayer, const szMessage[], any:...)
{
static szMsg[191]; vformat(szMsg, charsmax(szMsg), szMessage, 3)
pPlayer > 0 ? console_print(pPlayer, szMsg) : server_print(szMsg)
}