#include <amxmodx>  
#include <amxmisc>
#include <engine>
#include <zombieplague>
 
new ctfrags = 0
new tfrags = 0
new g_round = 0
new hud_rgb
new hud_x
new hud_y
new hud_efct
new g_Count
new g_HudText
new g_maxplayers
 
// Hudmessage tag
new const hud_tag[] = "Jelenlegi mod: "
 
// Name for each Hudmessage Mode
new const mode_names[][] =
{
    "Varakozas az uj modra...", // No mode Started
    "Normal fertozeses",        // Normal Infection, single round
    "Nemesis mod",          // Nemesis Mode (zombie boss)
    "Tulelo mod",       // Survivor Mode (human boss)
    "Raj mod",          // Swarm round (no infections)
    "Tobbszoros fertozeses mod",        // Multiple Infection (like single round, but, more than 1 zombie)
    "Pestis mod",           // Plague round (nemesis & zombies vs. survivors & humans)
    "Ismeretlen mod"        // An unofficial mode (edited/created/modified by user)
}
 
// RGB Colors for each Hudmessage Mode
// See here some RGB Colors: http://web.njit.edu/~kevin/rgb.txt.html
new const rgb_hud_colors[sizeof(mode_names)][3] =
{
//  R   G   B
    {255,   255,    255},       // No mode Started
    {0,     255,    0},         // Normal Infection, single round
    {255,   0,  0},     // Nemesis Mode (zombie boss)
    {0,     0,  255},       // Survivor Mode (human boss)
    {255,   255,    0},     // Swarm round (no infections)
    {0,     255,    0},     // Multiple Infection (like single round, but, more than 1 zombie)
    {255,   0,  0},     // Plague round (nemesis & zombies vs. survivors & humans)
    {255,   255,    255}        // An unofficial mode (edited/created/modified by user)
}
 
// X Hudmessage Position ( --- )
const Float:HUD_MODE_X = 0.65
 
// Y Hudmessage Position ( ||| )
const Float:HUD_MODE_Y = 0.2
 
// Time at which the Hudmessage is displayed. (when user is puted into the Server)
const Float:START_TIME = 3.0
 
/*================================================================================
 Customization ends here! Yes, that's it. Editing anything beyond
 here is not officially supported. Proceed at your own risk...
=================================================================================*/
 
// Variables
new g_SyncHud, g_Mode
 
// Cvar pointers
new cvar_enable, cvar_central
 
 
public hud(){ 
    
    new ctime[64], cdate[64], map[33], nextmap[32]
    new red, green, blue, id
    new a = get_timeleft()
    
    get_cvar_string("amx_nextmap", nextmap, 31)
    get_hud_color(red, green, blue)
    get_mapname(map,32)
    get_time("%H:%M:%S", ctime, 63)
    get_time("%Y.%m.%d", cdate, 63)
    
    set_hudmessage(red,green,blue,get_pcvar_float(hud_x),get_pcvar_float(hud_y), get_pcvar_num(hud_efct), 1.0, 1.0)
    ShowSyncHudMsg(id, g_HudText, "Ido: %s | Datum: %s^nCT Fragek: %d | T Fragek: %d^nJelenlegi Map: %s | Kov. Map: %s^nMapbol Vissz. Ido: %d:%02d^nKor: %i | Jatekosok: %i/%d", ctime, cdate, ctfrags, tfrags, map, nextmap, (a / 60), (a % 60), g_round, g_Count, g_maxplayers) 
    return PLUGIN_CONTINUE 
} 
 
public plugin_init() 
{ 
    register_plugin("Szerver Info v2","2.0","[*CS1.6-T3AM*]")
    
        // Round Start Event
    register_event("HLTV", "event_RoundStart", "a", "1=0", "2=0")
    
    // Enable Cvar
    cvar_enable = register_cvar("zp_display_mode", "1")
    
    // Server Cvar
    register_cvar("zp_addon_dtcm", "v0.1.6 by meTaLiCroSS", FCVAR_SERVER|FCVAR_SPONLY)
    
    // Variables
    g_SyncHud = CreateHudSyncObj()
    
    // Getting "zp_on" cvar
    if(cvar_exists("zp_on"))
        cvar_central = get_cvar_pointer("zp_on")
    
    // If Zombie Plague is not running (bugfix)
    if(!get_pcvar_num(cvar_central))
        pause("a") 
    
    g_maxplayers = get_maxplayers()
    g_HudText = CreateHudSyncObj()
    register_event("DeathMsg", "halal", "a")
    register_logevent("round_first", 2, "0=World triggered", "1&Restart_Round_")
    register_logevent("round_first", 2, "0=World triggered", "1=Game_Commencing")
    register_event("HLTV", "event_newround", "a", "1=0", "2=0")
    set_task(1.0, "hud",0,"",0,"b") 
    hud_rgb = register_cvar("hud_rgb", "0 255 0")
    hud_x = register_cvar("hud_x", "0.01")
    hud_y = register_cvar("hud_y", "0.18")
    hud_efct = register_cvar("hud_efct", "0")
    
    return PLUGIN_CONTINUE 
 
} 
 
public round_first()
 
    ctfrags = 0, tfrags = 0
 
     
 
public halal()
 
    {
 
            static killer
 
            killer = read_data(1);
 
            if(get_user_team(killer) == 2)
 
            ctfrags++
 
            if(get_user_team(killer) == 1)
 
            tfrags++
 
            return PLUGIN_CONTINUE
 
    }
    
public event_newround() 
{
    g_round++
}   
 
public client_putinserver(id)
{
    g_Count++
    set_task(START_TIME, "mode_hud", id, _, _, "b")
 
}
 
public client_disconnect(id)
{
    g_Count--
}   
 
get_hud_color(&r, &g, &b) {
    new color[20]
    static red[5], green[5], blue[5]
    get_pcvar_string(hud_rgb, color, charsmax(color))
    parse(color, red, charsmax(red), green, charsmax(green), blue, charsmax(blue))
    
    r = str_to_num(red)
    g = str_to_num(green)
    b = str_to_num(blue)
}
 
public event_RoundStart()
{
    // Update var (no mode started / in delay)
    g_Mode = 0
}
 
public mode_hud(id)
{
    // If the Cvar isn't enabled
    if(!get_pcvar_num(cvar_enable))
        return;
    
    // Hud Options
    set_hudmessage(rgb_hud_colors[g_Mode][0], rgb_hud_colors[g_Mode][1], rgb_hud_colors[g_Mode][2], HUD_MODE_X, HUD_MODE_Y, 0, 6.0, 12.0)
    
    // Now the hud appears
    ShowSyncHudMsg(id, g_SyncHud, "%s%s", (g_Mode == 0 ? "" : hud_tag), mode_names[g_Mode])
}
 
public zp_round_started(mode, id)
{
    // Update var with Mode num
    g_Mode = mode
    
    // An unofficial mode
    if(!(1 <= mode < (sizeof(mode_names) - 1)))
        g_Mode = sizeof(mode_names) - 1
}