PHP Code:
#include <amxmodx>
#include <zp50_core>
#include <zp50_class_nemesis>
#include <hamsandwich>
#include <cs_ham_bots_api>se
#include <dhudmessage>
new cvar_ct, cvar_nem, cvar_nightpowerz_enable, cvar_daypowerh_enable, cvar_multiplier
new g_time, Float:begin_time, bool:g_is_night, bool:g_is_day
new const TIME[][]= {
"Morning",
"Noon",
"Evening",
"Night"
}
public plugin_init()
{
register_plugin("[ZP] Addon: Day-Night System", "1.2", "Catastrophe")
register_event("HLTV","event_newround","a","1=0","2=0")
RegisterHam(Ham_TakeDamage, "player", "fw_damage")
RegisterHamBots(Ham_TakeDamage, "fw_damage")
cvar_ct = register_cvar("zp_dns_change_time","15.0")
cvar_nem = register_cvar("zp_dns_nem_night","1")
cvar_nightpowerz_enable = register_cvar("zp_dns_night_zombie_power","1")
cvar_daypowerh_enable = register_cvar("zp_dns_day_human_power","0")
cvar_multiplier = register_cvar("zp_dns_power_multiplier", "2.0")
}
public plugin_precache()
{
precache_sound("zombie_plague/werewolf1.wav")
}
public client_putinserver(id)
{
set_task(1.0, "checkhudmessage", id+672)
}
public client_disconnect(id)
{
remove_task(id+672)
}
public event_newround()
{
g_is_night = false
g_is_day = true
remove_task
begin_time = get_gametime()
server_cmd("zp_lighting i")
set_task(get_pcvar_float(cvar_ct), "cm1")
g_time = 0
}
public cm1()
{
server_cmd("zp_lighting l")
set_task(get_pcvar_float(cvar_ct), "cm2")
g_time = 0
}
public cm2()
{
server_cmd("zp_lighting o")
set_task(get_pcvar_float(cvar_ct), "cm3")
g_time = 0
}
public cm3()
{
server_cmd("zp_lighting r")
set_task(get_pcvar_float(cvar_ct), "cm4")
g_time = 0
}
public cm4()
{
server_cmd("zp_lighting v")
set_task(get_pcvar_float(cvar_ct), "cm5")
g_time = 0
}
public cm5()
{
server_cmd("zp_lighting y")
set_task(get_pcvar_float(cvar_ct), "c0")
g_time = 0
}
public c0()
{
server_cmd("zp_lighting y")
set_task(get_pcvar_float(cvar_ct), "c1")
g_time = 1
}
public c1()
{
server_cmd("zp_lighting w")
set_task(get_pcvar_float(cvar_ct), "c2")
g_time = 1
}
public c2()
{
server_cmd("zp_lighting u")
set_task(get_pcvar_float(cvar_ct), "c3")
g_time = 1
}
public c3()
{
server_cmd("zp_lighting s")
set_task(get_pcvar_float(cvar_ct), "c4")
g_time = 1
}
public c4()
{
server_cmd("zp_lighting q")
set_task(get_pcvar_float(cvar_ct), "c5")
g_time = 2
}
public c5()
{
server_cmd("zp_lighting o")
set_task(get_pcvar_float(cvar_ct), "c6")
g_time = 2
}
public c6()
{
server_cmd("zp_lighting m")
set_task(get_pcvar_float(cvar_ct), "c7")
g_time = 2
}
public c7()
{
server_cmd("zp_lighting j")
set_task(get_pcvar_float(cvar_ct), "c8")
g_time = 2
}
public c8()
{
server_cmd("zp_lighting h")
set_task(get_pcvar_float(cvar_ct), "c9")
g_time = 2
}
public c9()
{
server_cmd("zp_lighting f")
set_task(get_pcvar_float(cvar_ct), "c10")
g_time = 2
}
public c10()
{
server_cmd("zp_lighting d")
set_task(get_pcvar_float(cvar_ct), "c11")
g_time = 2
}
public c11()
{
server_cmd("zp_lighting b")
set_task(get_pcvar_float(cvar_ct), "c12")
g_time = 2
}
public c12()
{
g_is_night = true
g_is_day = false
server_cmd("zp_lighting a")
client_cmd(0, "spk zombie_plague/werewolf1")
g_time = 3
if(get_pcvar_num(cvar_nem) == 1)
{
new id, alive_count, name[32]
alive_count = GetAliveCount()
id = GetRandomAliveZombie(random_num(1, alive_count))
get_user_name(id, name, charsmax(name))
if(!zp_class_nemesis_get(id))
{
zp_class_nemesis_set(id)
client_print(0, print_center, "The night beckons and %s evolves into a Nemesis !!", name)
}
}
else if(get_pcvar_num(cvar_nem) == 2)
{
for(new i = 1; i < get_maxplayers(); i++)
{
if(zp_core_is_zombie(i) && is_user_alive(i) && !zp_class_nemesis_get(i))
{
zp_class_nemesis_set(i)
}
}
client_print(0, print_center, "The night beckons and all the zombie become Nemesis !!")
}
}
public checkhudmessage(id)
{
id -= 672;
if( !g_is_night)
{
set_dhudmessage(0, 180, 255, 1.0, 0.001, 0, 6.0, 1.1, 0.0, 0.0, false)
show_dhudmessage( 0 , "Seconds to night: %.f ^nTime: %s",(get_pcvar_float(cvar_ct)*19) - (get_gametime() - begin_time),TIME[g_time])
}
else
{
set_dhudmessage(250, 0, 0, 1.0, 0.001, 0, 6.0, 1.1, 0.0, 0.0, false)
show_dhudmessage( 0 , "Time: %s",TIME[g_time])
}
set_task(0.1, "checkhudmessage", id+672);
}
public fw_damage(victim, inflictor, attacker, Float:damage, damagebits)
{
if(get_pcvar_num(cvar_nightpowerz_enable) == 1 && g_is_night && is_user_connected(victim) && is_user_connected(attacker) && is_user_alive(victim) && zp_core_is_zombie(attacker))
{
SetHamParamFloat(4, damage * get_pcvar_num(cvar_multiplier))
}
if(get_pcvar_num(cvar_daypowerh_enable) == 1 && g_is_day && is_user_connected(victim) && is_user_connected(attacker) && is_user_alive(victim) && !zp_core_is_zombie(attacker))
{
SetHamParamFloat(4, damage * get_pcvar_num(cvar_multiplier))
}
}
GetAliveCount()
{
new iAlive, id
for (id = 1; id <= get_maxplayers(); id++)
{
if (is_user_alive(id))
iAlive++
}
return iAlive;
}
GetRandomAliveZombie(target_index)
{
new iAlive, id
for (id = 1; id <= get_maxplayers(); id++)
{
if (is_user_alive(id) && zp_core_is_zombie(id))
iAlive++
if (iAlive == target_index)
return id;
}
return -1;
}