PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <tfcx>
#include <fun>
#define PLUGIN "TFC Events"
#define VERSION "1.0"
#define AUTHOR "X-Script"
new tfc_rewards
new tfc_hp_gain
new tfc_ap_gain
new tfc_hp_limit
new tfc_ap_limit
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_logevent("tfc_red_capture", 3, "2=Red Capture Point")
register_logevent("tfc_blue_capture", 3, "2=Blue Capture Point")
register_event("DeathMsg", "tfc_kill_notice", "be")
tfc_rewards = register_cvar("amx_awards", "1")
tfc_hp_gain = register_cvar("amx_gainhp", "10")
tfc_ap_gain = register_cvar("amx_gainap", "20")
tfc_hp_limit = register_cvar("amx_hplimit", "100")
tfc_ap_limit = register_cvar("amx_aplimit", "100")
}
public plugin_precache()
{
precache_sound("fvox/hev_logon.wav")
precache_sound("items/itembk2.wav")
precache_sound("items/damage2.wav")
}
public client_putinserver(id)
{
if ( get_pcvar_num(tfc_rewards) == 0 )
{
return PLUGIN_HANDLED
}
new name[32]
get_user_name(id, name, 31)
client_print(id, print_chat, "Hello %s Welcome To The Server!",name)
return PLUGIN_HANDLED
}
public tfc_red_capture(id)
{
id = get_loguser_index()
if ( get_pcvar_num(tfc_rewards) == 0 )
{
return PLUGIN_HANDLED
}
if (!is_user_connected(id))
{
return PLUGIN_HANDLED
}
new name[32]
new healthlimit = get_cvar_num("amx_hplimit")
new armorlimit = get_cvar_num("amx_aplimit")
new healthadd = get_cvar_num("amx_gainhp")
new armoradd = get_cvar_num("amx_gainap")
new health = get_user_health(id)
new armor = get_user_armor(id)
get_user_name(id, name, 31)
set_hudmessage(1, 1, 200, -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15, 1)
show_hudmessage(0, "[TFC-GODS] %s has captured the RED FLAG",name)
client_cmd(id, "spk items/itembk2.wav")
client_print(id, print_chat, "[TFC-GODS] RED FLAG CAPTURED -- REWARDS: +Health, +Armor")
if (health < healthadd)
{
set_user_health(id, healthlimit + healthadd)
client_cmd(id,"spk fvox/hev_logon.wav")
}
if (health > healthlimit)
{
set_user_health(id, healthlimit)
}
if (armor < armorlimit)
{
set_user_armor(id, armorlimit + armoradd)
}
if (armor > armorlimit)
{
set_user_armor(id, armorlimit)
}
return PLUGIN_HANDLED
}
public tfc_blue_capture(id)
{
id = get_loguser_index()
if ( get_pcvar_num(tfc_rewards) == 0 )
{
return PLUGIN_HANDLED
}
if (!is_user_connected(id))
{
return PLUGIN_HANDLED
}
new name1[32]
new healthadd1 = get_cvar_num("amx_hpgain")
new armoradd1 = get_cvar_num("amx_apgain")
new healthlimit1 = get_cvar_num("amx_hplimit")
new armorlimit1 = get_cvar_num("amx_aplimit")
new health1 = get_user_health(id)
new armor1 = get_user_armor(id)
get_user_name(id, name1, 31)
set_hudmessage(200, 1, 1, -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15, 1)
show_hudmessage(0, "[TFC-GODS] %s has captured the BLUE FLAG",name1)
client_cmd(id, "spk items/itembk2.wav")
client_print(id, print_chat, "[TFC-GODS] BLUE FLAG CAPTURED -- REWARDS: +Health, +Armor")
if (health1 < healthlimit1)
{
set_user_health(id, health1 + healthadd1)
client_cmd(id,"spk fvox/hev_logon.wav")
}
if (health1 > healthlimit1)
{
set_user_health(id, healthlimit1)
}
if (armor1 < armorlimit1)
{
set_user_armor(id, armor1 + armoradd1)
}
if (armor1 > armorlimit1)
{
set_user_armor(id, armoradd1)
}
return PLUGIN_HANDLED
}
stock get_loguser_index()
{
new loguser[80], name[32]
read_logargv(0, loguser, 79)
parse_loguser(loguser, name, 31)
return get_user_index(name)
}
public tfc_kill_notice(id)
{
id = get_loguser_index()
if ( get_pcvar_num(tfc_rewards) == 0 )
{
return PLUGIN_HANDLED
}
if (!is_user_connected(id))
{
return PLUGIN_HANDLED
}
new killer = read_data(1)
set_hudmessage(40, 50, 60, -1.0, 0.30, 1, 6.0, 6.0, 0.5, 0.15, 1)
show_hudmessage(killer, "[TFC-GODS] You have killed an enemy!")
client_cmd(id, "spk items/damage2.wav")
return PLUGIN_HANDLED
}