I have combain DateTime and Zm Score and GameMods and Happyhour in one plugin but the problem when HappyHour End it will switch between "Deactivated" and "Activated" every 1 second
PHP Code:
#include <amxmodx>
#include <engine>
#include <zp50_colorchat>
#include <zombieplague>
#include <zp50_gamemodes>
#define PLUGIN "[ZP] Team win score"
#define VERSION "1.3"
#define AUTHOR "Ryokin"
#define TASK_ANOUNCE 05012015
#define TASK_UPDATE 06012014
new g_hh, cvar_hh[3]
new g_zombiescore, g_humanscore, g_NoOneWin, g_hudcolor,g_hudposition , g_hudmsg
new bool: ShowMeThisHud[ 33 ]
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_think("msg","ForwardThink")
register_event("TextMsg", "RestartRound", "a", "2&#Game_C", "2&#Game_w")
register_clcmd( "say /hud", "Say_showhud" )
register_clcmd( "say /score", "Say_showhud" )
g_NoOneWin = register_cvar( "zp_score_hud_win", "1")
g_hudcolor = register_cvar( "zp_score_hud_color", "255 125 0")
g_hudposition = register_cvar( "zp_score_hud_y_x", "-1.0 0.02")
cvar_hh[0] = register_cvar("zp_score_happy_start", "1") // 01:00 AM
cvar_hh[1] = register_cvar("zp_score_happy_end", "6") // 06:00 AM
cvar_hh[2] = register_cvar("zp_score_happy_multi", "2") // Reward x2
set_task(1.0 , "hh_update", TASK_UPDATE, _ , _, "b")
register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
g_hudmsg = CreateHudSyncObj()
new iEnt = create_entity("info_target")
entity_set_string(iEnt, EV_SZ_classname, "msg")
entity_set_float(iEnt, EV_FL_nextthink, get_gametime() + 2.0)
}
public zp_round_ended(team)
{
switch(team)
{
case WIN_ZOMBIES: g_zombiescore ++
case WIN_HUMANS: g_humanscore ++
case WIN_NO_ONE:
if (get_pcvar_num(g_NoOneWin))
g_humanscore ++
}
}
public event_round_start()
{
new h, m, start_hh = max(get_pcvar_num(cvar_hh[0]), 0), end_hh = max(get_pcvar_num(cvar_hh[1]), 0)
if(start_hh > 24) start_hh = 0;
if(end_hh > 24) end_hh = 0;
if(end_hh == start_hh)
{
set_fail_state("[Happy Hour] The time it starts and the time it stops")
return;
}
time(h, m)
}
public hh_update()
{
new h, m, start_hh = max(get_pcvar_num(cvar_hh[0]), 0), end_hh = max(get_pcvar_num(cvar_hh[1]), 0)
if(start_hh > 24) start_hh = 0;
if(end_hh > 24) end_hh = 0;
if(end_hh == start_hh)
{
set_fail_state("[Happy Hour] The time it starts and the time it stops")
return;
}
time(h, m)
if(g_hh)
{
if(start_hh < end_hh && (h <start_hh || h >= end_hh)) stop_happy()
else if(end_hh <= h < start_hh) stop_happy()
}
else
{
if(start_hh < end_hh && start_hh <= h < end_hh) start_happy()
else if(start_hh <= h || h < end_hh) start_happy()
}
}
start_happy()
{
if(!g_hh)
{
g_hh = true
set_cvar_num("zp_ammop_damage", get_cvar_num("zp_ammop_damage") * get_pcvar_num(cvar_hh[2]))
set_cvar_num("zp_ammop_human_infected", get_cvar_num("zp_ammop_human_infected") * get_pcvar_num(cvar_hh[2]))
set_cvar_num("zp_ammop_zombie_killed", get_cvar_num("zp_ammop_zombie_killed") * get_pcvar_num(cvar_hh[2]))
}
}
stop_happy()
{
if(g_hh)
{
g_hh = false
set_cvar_num("zp_ammop_damage", get_cvar_num("zp_ammop_damage") / get_pcvar_num(cvar_hh[2]))
set_cvar_num("zp_ammop_human_infected", get_cvar_num("zp_ammop_human_infected") / get_pcvar_num(cvar_hh[2]))
set_cvar_num("zp_ammop_zombie_killed", get_cvar_num("zp_ammop_zombie_killed") / get_pcvar_num(cvar_hh[2]))
}
}
public client_putinserver(id)
{
if (!is_user_bot(id))
{
// Set the custom HUD display task
set_task(1.0, "show_hud", id, _, _, "b")
}
}
/*public ForwardThink(id,iEnt)
{
Say_showhud(id,iEnt)
}*/
public Say_showhud(id,iEnt)
{
if( ShowMeThisHud[id] )
{
ShowMeThisHud[id] = false
show_hud()
set_task(1.0, "show_hud", id, _, _, "b")
}
else
{
remove_task(id)
ShowMeThisHud[id] = true
}
}
public show_hud()
{
new players[32], num
new ModeName[33]
get_players(players, num, "ah")
new szDate[32], szTime[32]
get_time("%d/%m/%Y", szDate, charsmax(szDate))
get_time("%H:%M:%S", szTime, charsmax(szTime))
for(new i; i < num; i++)
if(zp_gamemodes_get_current() == ZP_NO_GAME_MODE) return;
//static hud_red,hud_green,hud_blue, Float:hud_x, Float:hud_y
if(zp_gamemodes_get_current() == ZP_NO_GAME_MODE) return;
zp_gamemodes_get_name(zp_gamemodes_get_current(), ModeName, 32)
//-----
static hud_red,hud_green,hud_blue, Float:hud_x, Float:hud_y
hudmsgcolor(hud_red,hud_green,hud_blue)
hudmsgpos(hud_x,hud_y)
set_hudmessage(hud_red, hud_green, hud_blue, hud_x, hud_y, _, _, 1.0, _, _, 4)
ShowSyncHudMsg(0, g_hudmsg, "[HappyHour: %s]^n[%d ZOMBIES] - [%s] - [HUMANS %d]^n[%s%d] -- [%s%d]^n %s - %s", g_hh ? "Activated" : "Not Activated", fn_get_zombies(),ModeName,fn_get_humans(),g_zombiescore >= 10 ? "" : "0",g_zombiescore,g_humanscore >= 10 ? "" : "0", g_humanscore,szDate, szTime)
}
public RestartRound()
{
g_zombiescore = 0
g_humanscore = 0
}
public hudmsgcolor(&hud_red,&hud_green,&hud_blue)
{
new color[16], red[4], green[4], blue[4]
get_pcvar_string(g_hudcolor, color, 15)
parse(color, red, 3, green, 3, blue, 3)
hud_red = str_to_num(red)
hud_green = str_to_num(green)
hud_blue = str_to_num(blue)
}
public hudmsgpos(&Float:hud_x,&Float:hud_y)
{
new Position[19], PositionX[6], PositionY[6]
get_pcvar_string(g_hudposition, Position, 18)
parse(Position, PositionX, 6, PositionY, 6)
hud_x = str_to_float(PositionX)
hud_y = str_to_float(PositionY)
}
fn_get_humans()
{
static iAlive, id
iAlive = 0
for (id = 1; id <= 32; id++)
{
if (is_user_alive(id) && !zp_get_user_zombie(id))
iAlive++
}
return iAlive;
}
fn_get_zombies()
{
static iAlive, id
iAlive = 0
for (id = 1; id <= 32; id++)
{
if (is_user_alive(id) && zp_get_user_zombie(id))
iAlive++
}
return iAlive;
}