#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <zombieplague>
#include <byu_money>

new gCvar[3]

public plugin_init() 
{
	register_plugin("[ZP] Addon: Rewards", "1.0", "Slimes")

	RegisterHam(Ham_Killed,"player","KIlled")

	gCvar[1] = register_cvar( "zm_killed_boss_money", "8500" )
	gCvar[2] = register_cvar( "zm_killed_surv_money", "8500" )

	register_dictionary("zp_rewards.txt")
}

public KIlled(victim, attacker, corpse)
{
	if(zp_get_user_nemesis(victim))
	{
		new name[32]
        
		get_user_name(attacker, name, 31)

		ChatColor(0, "%L",0,"KILLED_BOSS", name)

		zp_cs_set_user_money(attacker, zp_cs_get_user_money(attacker)+get_pcvar_num(gCvar[1]))
	}
	else
	if(zp_get_user_survivor(victim))
	{
		new name[32]
        
		get_user_name(attacker, name, 31)

		ChatColor(0, "%L",0,"KILLED_SURVIVOR", name)

		zp_cs_set_user_money(attacker, zp_cs_get_user_money(attacker)+get_pcvar_num(gCvar[2]))
	}
}

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, "!team", "^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();
			}
		}
	}
} 