convert ze_core to 1,5v

Coding Help/Re-API Supported
Post Reply
czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 598
Joined: 7 years ago
Contact:

convert ze_core to 1,5v

#1

Post by czirimbolo » 4 years ago

Raheem, can you finally help me and covert my custom ze_core to 1,5v? I can't use 1,5v and even 1,4v. I wait couple of months

Code: Select all

#include <zombie_escape>
#include <ze_vip>

// SVIP configiration
#define HEALTH	VIP_F
#define HUMAN_INCREASE 200
#define ZOMBIE_INCREASE 5000

// Fowards
enum _:TOTAL_FORWARDS
{
    FORWARD_NONE = 0,
    FORWARD_ROUNDEND,
    FORWARD_HUMANIZED,
    FORWARD_PRE_INFECTED,
    FORWARD_INFECTED,
    FORWARD_ZOMBIE_APPEAR,
    FORWARD_ZOMBIE_RELEASE,
    FORWARD_GAME_STARTED
}
 
new g_iForwards[TOTAL_FORWARDS], g_iFwReturn, g_iTeam
 
// Tasks IDs
enum
{
    TASK_COUNTDOWN = 1100,
    TASK_COUNTDOWN2,
    TASK_SCORE_MESSAGE,
    FREEZE_ZOMBIES,
    ROUND_TIME_LEFT
}
 
// Colors (g_pCvarColors[] array indexes)
enum
{
    Red = 0,
    Green,
    Blue
}
 
// Variables
new g_iAliveHumansNum,
    g_iAliveZombiesNum,
    g_iRoundTime,
    g_iCountDown,
    g_iReleaseNotice,
    g_iMaxClients,
    g_iHumansScore,
    g_iZombiesScore,
    g_iRoundNum,
    g_iHSpeedFactor[33],
    g_iZSpeedSet[33],
    bool:g_bGameStarted,
    bool:g_bIsZombie[33],
    bool:g_bIsZombieFrozen[33],
    bool:g_bZombieFreezeTime,
    bool:g_bIsRoundEnding,
    bool:g_bHSpeedUsed[33],
    bool:g_bZSpeedUsed[33],
    bool:g_bEndCalled,
    Float:g_flReferenceTime
 
// Cvars
new g_pCvarHumanSpeedFactor,
    g_pCvarHumanGravity,
    g_pCvarHumanHealth,
    g_pCvarZombieSpeed,
    g_pCvarZombieGravity,
    g_pCvarZombieReleaseTime,
    g_pCvarFreezeTime,
    g_pCvarRoundTime,
    g_pCvarReqPlayers,
    g_pCvarZombieHealth,
    g_pCvarFirstZombiesHealth,
    g_pCvarZombieKnockback,
    g_pCvarScoreMessageType,
    g_pCvarColors[3],
    g_pCvarRoundEndDelay
   
// Dynamic
new Array:g_aChosenPlayers
 
public plugin_natives()
{
    register_native("ze_is_user_zombie", "native_ze_is_user_zombie", 1)
    register_native("ze_is_game_started", "native_ze_is_game_started", 1)
    register_native("ze_is_zombie_frozen", "native_ze_is_zombie_frozen", 1)
   
    register_native("ze_get_round_number", "native_ze_get_round_number", 1)
    register_native("ze_get_humans_number", "native_ze_get_humans_number", 1)
    register_native("ze_get_zombies_number", "native_ze_get_zombies_number", 1)
   
    register_native("ze_set_user_zombie", "native_ze_set_user_zombie", 1)
    register_native("ze_set_user_human", "native_ze_set_user_human", 1)
    register_native("ze_set_human_speed_factor", "native_ze_set_human_speed_factor", 1)
    register_native("ze_set_zombie_speed", "native_ze_set_zombie_speed", 1)
   
    register_native("ze_reset_human_speed", "native_ze_reset_human_speed", 1)
    register_native("ze_reset_zombie_speed", "native_ze_reset_zombie_speed", 1)
}
 
public plugin_init()
{
    register_plugin("[ZE] Core/Engine", ZE_VERSION, AUTHORS)
   
    // Hook Chains
    RegisterHookChain(RG_CBasePlayer_TraceAttack, "Fw_TraceAttack_Pre", 0)
    RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
    RegisterHookChain(RG_CBasePlayer_Spawn, "Fw_PlayerSpawn_Post", 1)
    RegisterHookChain(RG_CSGameRules_CheckWinConditions, "Fw_CheckMapConditions_Post", 1)
    RegisterHookChain(RG_CBasePlayer_Killed, "Fw_PlayerKilled_Post", 1)
    RegisterHookChain(RG_RoundEnd, "Event_RoundEnd_Pre", 0)
   
    // Events
    register_event("HLTV", "New_Round", "a", "1=0", "2=0")
    register_event("TextMsg", "Map_Restart", "a", "2=#Game_Commencing", "2=#Game_will_restart_in", "2=#Round_Draw")
    register_logevent("Round_Start", 2, "1=Round_Start")
    register_logevent("Round_End", 2, "1=Round_End")
   
    // Hams
    RegisterHam(Ham_Item_PreFrame, "player", "Fw_RestMaxSpeed_Post", 1)
   
    // Create Forwards (All Return Values Ignored)
    g_iForwards[FORWARD_ROUNDEND] = CreateMultiForward("ze_roundend", ET_IGNORE, FP_CELL)
    g_iForwards[FORWARD_HUMANIZED] = CreateMultiForward("ze_user_humanized", ET_IGNORE, FP_CELL)
    g_iForwards[FORWARD_PRE_INFECTED] = CreateMultiForward("ze_user_infected_pre", ET_CONTINUE, FP_CELL, FP_CELL, FP_CELL)
    g_iForwards[FORWARD_INFECTED] = CreateMultiForward("ze_user_infected", ET_IGNORE, FP_CELL, FP_CELL)
    g_iForwards[FORWARD_ZOMBIE_APPEAR] = CreateMultiForward("ze_zombie_appear", ET_IGNORE)
    g_iForwards[FORWARD_ZOMBIE_RELEASE] = CreateMultiForward("ze_zombie_release", ET_IGNORE)
    g_iForwards[FORWARD_GAME_STARTED] = CreateMultiForward("ze_game_started", ET_IGNORE)
   
    // Hud Messages
    g_iReleaseNotice = CreateHudSyncObj()
   
    // Sequential files (.txt)
    register_dictionary("zombie_escape.txt")
   
    // Humans Cvars
    g_pCvarHumanSpeedFactor = register_cvar("ze_human_speed_factor", "20.0")
    g_pCvarHumanGravity = register_cvar("ze_human_gravity", "800")
    g_pCvarHumanHealth = register_cvar("ze_human_health", "1000")
   
    // Zombie Cvars
    g_pCvarZombieSpeed = register_cvar("ze_zombie_speed", "350.0")
    g_pCvarZombieGravity = register_cvar("ze_zombie_gravity", "640")
    g_pCvarZombieHealth = register_cvar("ze_zombie_health", "10000")
    g_pCvarFirstZombiesHealth = register_cvar("ze_first_zombies_health", "20000")
    g_pCvarZombieKnockback = register_cvar("ze_zombie_knockback", "300.0")
   
    // General Cvars
    g_pCvarZombieReleaseTime = register_cvar("ze_release_time", "15")
    g_pCvarFreezeTime = register_cvar("ze_freeze_time", "20")
    g_pCvarRoundTime = register_cvar("ze_round_time", "9.0")
    g_pCvarReqPlayers = register_cvar("ze_required_players", "2")
    g_pCvarScoreMessageType = register_cvar("ze_score_message_type", "1")
    g_pCvarColors[Red] = register_cvar("ze_score_message_red", "200")
    g_pCvarColors[Green] = register_cvar("ze_score_message_green", "100")
    g_pCvarColors[Blue] = register_cvar("ze_score_message_blue", "0")
    g_pCvarRoundEndDelay = register_cvar("ze_round_end_delay", "5")
   
    // Default Values
    g_bGameStarted = false
   
    // Static Values
    g_iMaxClients = get_member_game(m_nMaxPlayers)
   
    // Check Round Time to Terminate it
    set_task(1.0, "Check_RoundTimeleft", ROUND_TIME_LEFT, _, _, "b")
   
    // Create our array to store SteamIDs in
    g_aChosenPlayers = ArrayCreate(34)
}
 
public plugin_cfg()
{
    // Get our configiration file and Execute it
    new szCfgDir[64]
    get_localinfo("amxx_configsdir", szCfgDir, charsmax(szCfgDir))
    server_cmd("exec %s/zombie_escape.cfg", szCfgDir)
   
    // Set Game Name
    new szGameName[64]
    formatex(szGameName, sizeof(szGameName), "Zombie Escape v%s", ZE_VERSION)
    set_member_game(m_GameDesc, szGameName)
   
    // Set Version
    register_cvar("ze_version", ZE_VERSION, FCVAR_SERVER|FCVAR_SPONLY)
    set_cvar_string("ze_version", ZE_VERSION)
}
 
public Fw_CheckMapConditions_Post()
{
    // Block Game Commencing
    set_member_game(m_bGameStarted, true)
   
    // Set Freeze Time
    set_member_game(m_iIntroRoundTime, get_pcvar_num(g_pCvarFreezeTime))
   
    // Set Round Time
    set_member_game(m_iRoundTime, floatround(get_pcvar_float(g_pCvarRoundTime) * 60.0))
}
 
public Fw_PlayerKilled_Post(id)
{
    g_iAliveHumansNum = GetAlivePlayersNum(CsTeams:TEAM_CT)
    g_iAliveZombiesNum = GetAlivePlayersNum(CsTeams:TEAM_TERRORIST)
   
    if (g_iAliveHumansNum == 0 && g_iAliveZombiesNum == 0)
    {
        // No Winner, All Players in one team killed Or Both teams Killed
        client_print(0, print_center, "%L", LANG_PLAYER, "NO_WINNER")
    }
}
 
public Fw_RestMaxSpeed_Post(id)
{
    if (!g_bIsZombie[id])
    {
        static Float:flMaxSpeed
        get_entvar(id, var_maxspeed, flMaxSpeed)
       
        if (flMaxSpeed != 1.0 && is_user_alive(id))
        {
            if (g_bHSpeedUsed[id])
            {
                // Set New Human Speed Factor
                set_entvar(id, var_maxspeed, flMaxSpeed + float(g_iHSpeedFactor[id]))
                return HAM_IGNORED
            }
               
            // Set Human Speed Factor, native not used
            set_entvar(id, var_maxspeed, flMaxSpeed + get_pcvar_float(g_pCvarHumanSpeedFactor))
            return HAM_IGNORED
        }
    }
   
    return HAM_SUPERCEDE
}
 
public Fw_PlayerSpawn_Post(id)
{
    if (!is_user_alive(id))
        return
   
    if (!g_bGameStarted)
    {
        // Force All player to be Humans if Game not started yet
        rg_set_user_team(id, TEAM_CT, MODEL_UNASSIGNED)
    }
    else
    {
        if (get_member_game(m_bFreezePeriod))
        {
            // Respawn Him As human if we are in freeze time (Zombie Not Chosen yet)
            Set_User_Human(id)
            g_bIsZombieFrozen[id] = false
        }
        else
        {
            if (g_bZombieFreezeTime)
            {
                // Zombie Chosen and zombies Frozen, Spawn him as zombie and Freeze Him
                Set_User_Zombie(id)
                g_bIsZombieFrozen[id] = true
                set_entvar(id, var_maxspeed, 1.0)
            }
            else
            {
                // Respawn him as normal zombie
                Set_User_Zombie(id)
                g_bIsZombieFrozen[id] = false
            }
        }
    }
}
 
public New_Round()
{
    // Remove All tasks in the New Round
    remove_task(TASK_COUNTDOWN)
    remove_task(TASK_COUNTDOWN2)
    remove_task(TASK_SCORE_MESSAGE)
    remove_task(FREEZE_ZOMBIES)
   
    // Score Message Task
    set_task(10.0, "Score_Message", TASK_SCORE_MESSAGE, _, _, "b")
   
    // 2 is Hardcoded Value, It's Fix for the countdown to work correctly
    g_iCountDown = get_member_game(m_iIntroRoundTime) - 2
   
    if (!g_bGameStarted)
    {
        // No Enough Players
        ze_colored_print(0, "%L", LANG_PLAYER, "NO_ENOUGH_PLAYERS", get_pcvar_num(g_pCvarReqPlayers))
        return // Block the execution of the blew code
    }
   
    // Game Already started, Countdown now started
    set_task(1.0, "Countdown_Start", TASK_COUNTDOWN, _, _, "b")
    ze_colored_print(0, "%L", LANG_PLAYER, "READY_TO_RUN")
    ExecuteForward(g_iForwards[FORWARD_GAME_STARTED], g_iFwReturn)
   
    g_iRoundNum++
   
    // Round Starting
    g_bIsRoundEnding = false
    g_bEndCalled = false
}
 
// Score Message Task
public Score_Message(TaskID)
{
    switch(get_pcvar_num(g_pCvarScoreMessageType))
    {
        case 0: // Disabled
        {
            return
        }
        case 1: // DHUD
        {
            set_dhudmessage(get_pcvar_num(g_pCvarColors[Red]), get_pcvar_num(g_pCvarColors[Green]), get_pcvar_num(g_pCvarColors[Blue]), -1.0, 0.01, 0, 0.0, 9.0)
            show_dhudmessage(0, "%L", LANG_PLAYER, "SCORE_MESSAGE", g_iZombiesScore, g_iHumansScore)
        }
        case 2: // HUD
        {
            set_hudmessage(get_pcvar_num(g_pCvarColors[Red]), get_pcvar_num(g_pCvarColors[Green]), get_pcvar_num(g_pCvarColors[Blue]), -1.0, 0.01, 0, 0.0, 9.0)
            show_hudmessage(0, "%L", LANG_PLAYER, "SCORE_MESSAGE", g_iZombiesScore, g_iHumansScore)
        }
    }
}
 
public Countdown_Start(TaskID)
{
    // Check if the players Disconnected and there is only one player then remove all messages, and stop tasks
    if (!g_bGameStarted)
        return
   
    if (!g_iCountDown)
    {
        Choose_Zombies()
        remove_task(TASK_COUNTDOWN) // Remove the task
        return // Block the execution of the blew code
    }
 
    g_iCountDown--
}
 
public Choose_Zombies()
{
    new iZombies, id, iAliveCount
    new iReqZombies
   
    // Get total alive players and required players
    iAliveCount  = GetAllAlivePlayersNum()
    iReqZombies = RequiredZombies()
   
    // Loop till we find req players
    while(iZombies < iReqZombies)
    {
        id = GetRandomAlive(random_num(1, iAliveCount))
       
        // If player in array (Players steamid), it means he has chosen the previous round so skip him
        if (!is_user_alive(id) || g_bIsZombie[id] || PlayerInArray(id))
            continue
 
        Set_User_Zombie(id)
		
		if (ze_get_vip_flags(id) & HEALTH)
		{
			set_entvar(id, var_health, float(get_pcvar_num(g_pCvarFirstZombiesHealth) + ZOMBIE_INCREASE))
		}
		else
		{
			set_entvar(id, var_health, get_pcvar_float(g_pCvarFirstZombiesHealth))
		}

        g_bIsZombieFrozen[id] = true
        g_bZombieFreezeTime = true
        set_entvar(id, var_maxspeed, 1.0)
        set_task(0.1, "Freeze_Zombies", FREEZE_ZOMBIES, _, _, "b") // Better than PreThink
        ExecuteForward(g_iForwards[FORWARD_ZOMBIE_APPEAR], g_iFwReturn)
        iZombies++
    }
   
    // After choose, we clear the array
    ArrayClear(g_aChosenPlayers)
   
    // Now we loop through all players and store the chosen zombies steamid so they not chosen the next round again
    // Using steamid will add reconnect support
    for(new id = 1; id <= g_iMaxClients; id++)
    {
        if(!is_user_connected(id) || !g_bIsZombie[id])
            continue
       
        new szAuthId[34];
       
        get_user_authid(id, szAuthId, charsmax(szAuthId));
       
        ArrayPushString(g_aChosenPlayers, szAuthId)
    }
   
    // 2 is Hardcoded Value, It's Fix for the countdown to work correctly
    g_iCountDown = get_pcvar_num(g_pCvarZombieReleaseTime) - 2
   
    set_task(1.0, "ReleaseZombie_CountDown", TASK_COUNTDOWN2, _, _, "b")
}
 
public ReleaseZombie_CountDown(TaskID)
{
    if (!g_iCountDown)
    {
        ReleaseZombie()
        remove_task(TASK_COUNTDOWN2)
        return
    }
   
    // Release Hud Message
    set_hudmessage(255, 255, 0, -1.0, 0.21, 1, 2.0, 2.0)
    ShowSyncHudMsg(0, g_iReleaseNotice, "%L", LANG_PLAYER, "ZOMBIE_RELEASE", g_iCountDown)
   
    g_iCountDown --
}
 
public ReleaseZombie()
{
    ExecuteForward(g_iForwards[FORWARD_ZOMBIE_RELEASE], g_iFwReturn)
   
    for(new id = 1; id <= g_iMaxClients; id++)
    {
        if (is_user_alive(id) && g_bIsZombie[id])
        {
            g_bIsZombieFrozen[id] = false
            g_bZombieFreezeTime = false
        }
    }
}
 
public Freeze_Zombies(TaskID)
{
    for(new id = 1; id <= g_iMaxClients; id++)
    {
        if(!is_user_alive(id) || !g_bIsZombie[id])
            continue
       
        if (g_bIsZombieFrozen[id])
        {
            // Zombie & Frozen, then Freeze him
            set_entvar(id, var_maxspeed, 1.0)
        }
        else
        {
            if (g_bZSpeedUsed[id])
            {
                // Zombie but Not Frozen the set his speed form .cfg
                set_entvar(id, var_maxspeed, float(g_iZSpeedSet[id]))
                continue;
            }
               
            // Zombie but Not Frozen the set his speed form .cfg
            set_entvar(id, var_maxspeed, get_pcvar_float(g_pCvarZombieSpeed))
        }
    }
}
 
public Fw_TraceAttack_Pre(iVictim, iAttacker, Float:flDamage, Float:flDirection[3], iTracehandle, bitsDamageType)
{
    if (iVictim == iAttacker || !is_user_connected(iVictim) || !is_user_connected(iAttacker))
        return HC_CONTINUE
   
    // Attacker and Victim is in same teams? Skip code blew
    if (get_member(iAttacker, m_iTeam) == get_member(iVictim, m_iTeam))
        return HC_CONTINUE
   
    // In freeze time? Skip all other plugins (Skip the real trace attack event)
    if (g_bIsZombieFrozen[iVictim] || g_bIsZombieFrozen[iAttacker])
        return HC_SUPERCEDE
   
    // Execute pre-infection forward
    ExecuteForward(g_iForwards[FORWARD_PRE_INFECTED], g_iFwReturn, iVictim, iAttacker, floatround(flDamage))
   
    if (g_iFwReturn > 0)
    {
        return HC_SUPERCEDE
    }
   
    g_iAliveHumansNum = GetAlivePlayersNum(CsTeams:TEAM_CT)
   
    if (g_bIsZombie[iAttacker])
    {
        // Death Message with Infection style [Added here because of delay in Forward use]
        SendDeathMsg(iAttacker, iVictim)
       
        Set_User_Zombie(iVictim)
       
        ExecuteForward(g_iForwards[FORWARD_INFECTED], g_iFwReturn, iVictim, iAttacker)
       
        if (g_iAliveHumansNum == 1) // Check if this is Last Human, Because of Delay i can't check if it's 0 instead of 1
        {
            // End round event called one time
            g_bEndCalled = true
           
            // Round is Ending
            g_bIsRoundEnding = true
           
            // Zombie Win, Leave text blank so we use ours from ML
            rg_round_end(get_pcvar_float(g_pCvarRoundEndDelay), WINSTATUS_TERRORISTS, ROUND_TERRORISTS_WIN, "")
           
            // Show Our Message
            client_print(0, print_center, "%L", LANG_PLAYER, "ESCAPE_FAIL")
           
            // This needed so forward work also to add +1 for Zombies
            g_iTeam = 1 // ZE_TEAM_ZOMBIE
            ExecuteForward(g_iForwards[FORWARD_ROUNDEND], g_iFwReturn, g_iTeam)
        }
    }
   
    return HC_CONTINUE
}

public Fw_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:fDamage, bitsDamageType)
{
    // Not Vaild Victim or Attacker so skip the event (Important to block out bounds errors)
    if (!is_user_connected(iVictim) || !is_user_connected(iAttacker))
        return HC_CONTINUE
   
    // Set Knockback here, So if we blocked damage in TraceAttack event player won't get knockback (Fix For Madness)
    if (g_bIsZombie[iVictim] && !g_bIsZombie[iAttacker] && get_user_weapon(iAttacker) != CSW_KNIFE)
    {
        // Remove Shock Pain
        set_member(iVictim, m_flVelocityModifier, 1.0)

        // Set Knockback
        static Float:flOrigin[3]
        get_entvar(iAttacker, var_origin, flOrigin)
        Set_Knockback(iVictim, flOrigin, get_pcvar_float(g_pCvarZombieKnockback), 2)
    }
   
    return HC_CONTINUE
}
 
public Round_End()
{
    g_iAliveZombiesNum = GetAlivePlayersNum(CsTeams:TEAM_TERRORIST)
   
    if (g_iAliveZombiesNum == 0 && g_bGameStarted)
    {
        g_iTeam = 2 // ZE_TEAM_HUMAN
        ExecuteForward(g_iForwards[FORWARD_ROUNDEND], g_iFwReturn, g_iTeam)
        client_print(0, print_center, "%L", LANG_PLAYER, "ESCAPE_SUCCESS")
        g_iHumansScore++
        g_bIsRoundEnding = true
        return // To block Execute the code blew
    }
   
    g_iTeam = 1 // ZE_TEAM_ZOMBIE
    g_iZombiesScore++
    g_bIsRoundEnding = true
   
    // If it's already called one time, don't call it again
    if (!g_bEndCalled)
    {
        ExecuteForward(g_iForwards[FORWARD_ROUNDEND], g_iFwReturn, g_iTeam)
    }
   
    client_print(0, print_center, "%L", LANG_PLAYER, "ESCAPE_FAIL")
}
 
public Event_RoundEnd_Pre(WinStatus:status, ScenarioEventEndRound:event, Float:tmDelay)
{
    // The two unhandeld cases by rg_round_end() native in our Mod
    if (event == ROUND_CTS_WIN || event == ROUND_TERRORISTS_WIN)
    {
        SetHookChainArg(3, ATYPE_FLOAT, get_pcvar_float(g_pCvarRoundEndDelay))
    }
}
 
public Round_Start()
{
    g_flReferenceTime = get_gametime()
    g_iRoundTime = get_member_game(m_iRoundTime)
}
 
public Check_RoundTimeleft()
{
    new Float:flRoundTimeLeft = (g_flReferenceTime + float(g_iRoundTime)) - get_gametime()
   
    if (floatround(flRoundTimeLeft) == 0)
    {
        // Round is Ending
        g_bIsRoundEnding = true
       
        // If Time is Out then Terminate the Round
        rg_round_end(get_pcvar_float(g_pCvarRoundEndDelay), WINSTATUS_TERRORISTS, ROUND_TERRORISTS_WIN, "")
       
        // Show our Message
        client_print(0, print_center, "%L", LANG_PLAYER, "ESCAPE_FAIL")
    }
}
 
public client_disconnected(id)
{
    // Delay Then Check Players to Terminate The round (Delay needed)
    set_task(0.1, "Check_AlivePlayers")
   
    // Reset speed for this dropped id
    g_bHSpeedUsed[id] = false
    g_bZSpeedUsed[id] = false
}
 
// This check done when player disconnect
public Check_AlivePlayers()
{
    g_iAliveZombiesNum = GetAlivePlayersNum(CsTeams:TEAM_TERRORIST)
    g_iAliveHumansNum = GetAlivePlayersNum(CsTeams:TEAM_CT)
   
    // Game Started? (There is at least 2 players Alive?)
    if (g_bGameStarted)
    {
        // We are in freeze time?
        if (get_member_game(m_bFreezePeriod))
        {
            // Humans alive number = 1 and no zombies?
            if (g_iAliveHumansNum < get_pcvar_num(g_pCvarReqPlayers))
            {
                // Game started false again
                g_bGameStarted = false
            }
        }
        else // Not freeze time?
        {
            // Variables
            new iAllZombiesNum = GetTeamPlayersNum(CsTeams:TEAM_TERRORIST),
            iAllHumansNum = GetTeamPlayersNum(CsTeams:TEAM_CT),
            iDeadZombiesNum = GetDeadPlayersNum(CsTeams:TEAM_TERRORIST),
            iDeadHumansNum = GetDeadPlayersNum(CsTeams:TEAM_CT)
   
            // Alive humans number = 1 and no zombies at all, And no dead humans?
            if (g_iAliveHumansNum < get_pcvar_num(g_pCvarReqPlayers) && iDeadHumansNum == 0 && iAllZombiesNum == 0)
            {
                // Game started is false and humans wins (Escape Success)
                g_bGameStarted = false
                rg_round_end(get_pcvar_float(g_pCvarRoundEndDelay), WINSTATUS_CTS, ROUND_CTS_WIN, "")
                client_print(0, print_center, "%L", LANG_PLAYER, "ESCAPE_SUCCESS")
            }
           
            // Alive zombies number = 1 and no humans at all, And no dead zombies?
            if (g_iAliveZombiesNum < get_pcvar_num(g_pCvarReqPlayers) && iDeadZombiesNum == 0 && iAllHumansNum == 0)
            {
                // Game started is false and zombies wins (Escape Fail)
                g_bGameStarted = false
                rg_round_end(get_pcvar_float(g_pCvarRoundEndDelay), WINSTATUS_TERRORISTS, ROUND_TERRORISTS_WIN, "")
                client_print(0, print_center, "%L", LANG_PLAYER, "ESCAPE_FAIL")
            }
           
            // Humans number more than 1 and no zombies?
            if (g_iAliveHumansNum >= get_pcvar_num(g_pCvarReqPlayers) && g_iAliveZombiesNum == 0 && !g_bIsRoundEnding)
            {
                // Then Escape success as there is no Zombies
                rg_round_end(get_pcvar_float(g_pCvarRoundEndDelay), WINSTATUS_CTS, ROUND_CTS_WIN, "")
                client_print(0, print_center, "%L", LANG_PLAYER, "ESCAPE_SUCCESS")
            }
           
            // Zombies number more than 1 and no humans?
            if (g_iAliveZombiesNum >= get_pcvar_num(g_pCvarReqPlayers) && g_iAliveHumansNum == 0 && !g_bIsRoundEnding)
            {
                // Then Escape Fail as there is no humans
                rg_round_end(get_pcvar_float(g_pCvarRoundEndDelay), WINSTATUS_TERRORISTS, ROUND_TERRORISTS_WIN, "")
                client_print(0, print_center, "%L", LANG_PLAYER, "ESCAPE_FAIL")
            }
        }
    }
}
 
public client_putinserver(id)
{
    // Add Delay and Check Conditions To start the Game (Delay needed)
    set_task(1.0, "Check_AllPlayersNumber", _, _, _, "b")
}
 
public Check_AllPlayersNumber(TaskID)
{
    if (g_bGameStarted)
    {
        // If game started remove the task and block the blew Checks
        remove_task(TaskID)
        return
    }
   
    if (GetAllAlivePlayersNum() >= get_pcvar_num(g_pCvarReqPlayers))
    {
        // Players In server == The Required so game started is true
        g_bGameStarted = true
       
        // Restart the game
        server_cmd("sv_restart 2")
       
        // Print Fake game Commencing Message
        client_print(0, print_center, "%L", LANG_PLAYER, "START_GAME")
       
        // Remove the task
        remove_task(TaskID)
    }
}
 
public Set_User_Human(id)
{
    if (!is_user_alive(id))
        return
   
    g_bIsZombie[id] = false
	
	
	if (ze_get_vip_flags(id) & HEALTH)
	{
		set_entvar(id, var_health, float(get_pcvar_num(g_pCvarHumanHealth) + HUMAN_INCREASE))
	}
	else
	{
		set_entvar(id, var_health, get_pcvar_float(g_pCvarHumanHealth))
	}
    
    set_entvar(id, var_gravity, get_pcvar_float(g_pCvarHumanGravity)/800.0)
    ExecuteForward(g_iForwards[FORWARD_HUMANIZED], g_iFwReturn, id)
   
    if (get_member(id, m_iTeam) != TEAM_CT)
        rg_set_user_team(id, TEAM_CT, MODEL_UNASSIGNED)
}
 
public Set_User_Zombie(id)
{
    if (!is_user_alive(id))
        return
   
    g_bIsZombie[id] = true
	
	if (ze_get_vip_flags(id) & HEALTH)
	{
		set_entvar(id, var_health, float(get_pcvar_num(g_pCvarZombieHealth) + ZOMBIE_INCREASE))
	}
	else
	{
		set_entvar(id, var_health, get_pcvar_float(g_pCvarZombieHealth))
	}
	
    set_entvar(id, var_gravity, get_pcvar_float(g_pCvarZombieGravity)/800.0)
    rg_remove_all_items(id)
    rg_give_item(id, "weapon_knife", GT_APPEND)
    ExecuteForward(g_iForwards[FORWARD_INFECTED], g_iFwReturn, id, 0)
   
    if (get_member(id, m_iTeam) != TEAM_TERRORIST)
        rg_set_user_team(id, TEAM_TERRORIST, MODEL_UNASSIGNED)
}
 
public Map_Restart()
{
    // Add Delay To help Rest Scores if player kill himself, and there no one else him so round draw (Delay needed)
    set_task(0.1, "Reset_Score_Message")
}
 
public Reset_Score_Message()
{
    g_iHumansScore = 0
    g_iZombiesScore = 0
    g_iRoundNum = 0
}
 
 
/*
*   Simple function to check if given player steamid in our array or not
*   This is used to save the previous users steamid so they not chosen again next round
*/
public PlayerInArray(id)
{
    new szAuthId[34], szSavedAuthId[34];
   
    get_user_authid(id, szAuthId, charsmax(szAuthId))
   
    for(new i = 0; i < ArraySize(g_aChosenPlayers); i++)
    {
        ArrayGetString(g_aChosenPlayers, i, szSavedAuthId, charsmax(szSavedAuthId))
       
        if (equal(szSavedAuthId, szAuthId))
        {
            return true;
        }
    }
   
    return false;
}
 
// Natives
public native_ze_is_user_zombie(id)
{
    if (!is_user_connected(id))
    {
        return -1;
    }
   
    return g_bIsZombie[id]
}
 
public native_ze_set_user_zombie(id)
{
    if (!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return false;
    }
   
    Set_User_Zombie(id)
    return true;
}
 
public native_ze_set_user_human(id)
{
    if (!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return false;
    }
   
    Set_User_Human(id)
    return true;
}
 
public native_ze_is_game_started()
{
    return g_bGameStarted
}
 
public native_ze_is_zombie_frozen(id)
{
    if (!is_user_connected(id) || !g_bIsZombie[id])
    {
        return -1;
    }
   
    return g_bIsZombieFrozen[id]
}
 
public native_ze_get_round_number()
{
    if (!g_bGameStarted)
    {
        return -1;
    }
   
    return g_iRoundNum
}
 
public native_ze_get_humans_number()
{
    return GetAlivePlayersNum(CsTeams:TEAM_CT)
}
 
public native_ze_get_zombies_number()
{
    return GetAlivePlayersNum(CsTeams:TEAM_TERRORIST)
}
 
public native_ze_set_human_speed_factor(id, iFactor)
{
    if (!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return false;
    }
   
    g_bHSpeedUsed[id] = true
    g_iHSpeedFactor[id] = iFactor
    ExecuteHamB(Ham_Item_PreFrame, id)
    return true;
}
 
public native_ze_reset_human_speed(id)
{
    if (!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return false;
    }
   
    g_bHSpeedUsed[id] = false
    ExecuteHamB(Ham_Item_PreFrame, id)
    return true;
}
 
public native_ze_set_zombie_speed(id, iSpeed)
{
    if (!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return false;
    }
   
    g_bZSpeedUsed[id] = true
    g_iZSpeedSet[id] = iSpeed
    return true;
}
 
public native_ze_reset_zombie_speed(id)
{
    if (!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return false;
    }
   
    g_bZSpeedUsed[id] = false
    return true;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
*/
Image

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#2

Post by Raheem » 4 years ago

Try:
    1. #include <zombie_escape>
    2. #include <ze_vip>
    3.  
    4. // SVIP configiration
    5. #define HEALTH  VIP_F
    6. #define HUMAN_INCREASE 200
    7. #define ZOMBIE_INCREASE 5000
    8.  
    9. // Fowards
    10. enum _:TOTAL_FORWARDS
    11. {
    12.     FORWARD_NONE = 0,
    13.     FORWARD_ROUNDEND,
    14.     FORWARD_HUMANIZED,
    15.     FORWARD_PRE_INFECTED,
    16.     FORWARD_INFECTED,
    17.     FORWARD_ZOMBIE_APPEAR,
    18.     FORWARD_ZOMBIE_RELEASE,
    19.     FORWARD_GAME_STARTED_PRE,
    20.     FORWARD_GAME_STARTED,
    21.     FORWARD_DISCONNECT
    22. }
    23.  
    24. new g_iForwards[TOTAL_FORWARDS], g_iFwReturn, g_iTeam
    25.  
    26. // Tasks IDs
    27. enum
    28. {
    29.     TASK_COUNTDOWN = 1100,
    30.     TASK_COUNTDOWN2,
    31.     TASK_SCORE_MESSAGE,
    32.     FREEZE_ZOMBIES,
    33.     ROUND_TIME_LEFT
    34. }
    35.  
    36. // Colors (g_pCvarColors[] array indexes)
    37. enum
    38. {
    39.     Red = 0,
    40.     Green,
    41.     Blue
    42. }
    43.  
    44. // Variables
    45. new g_iAliveHumansNum,
    46.     g_iAliveZombiesNum,
    47.     g_iRoundTime,
    48.     g_iCountDown,
    49.     g_iReleaseNotice,
    50.     g_iMaxClients,
    51.     g_iHumansScore,
    52.     g_iZombiesScore,
    53.     g_iRoundNum,
    54.     g_iHSpeedFactor[33],
    55.     g_iZSpeedSet[33],
    56.     g_iUserGravity[33],
    57.     bool:g_bGameStarted,
    58.     bool:g_bIsZombie[33],
    59.     bool:g_bIsZombieFrozen[33],
    60.     bool:g_bZombieFreezeTime,
    61.     bool:g_bIsRoundEnding,
    62.     bool:g_bHSpeedUsed[33],
    63.     bool:g_bZSpeedUsed[33],
    64.     bool:g_bEndCalled,
    65.     bool:g_bIsKnockBackUsed[33],
    66.     bool:g_bIsGravityUsed[33],
    67.     bool:g_bEnteredNotChoosed[33],
    68.     Float:g_flReferenceTime,
    69.     Float:g_flUserKnockback[33]
    70.  
    71. // Cvars
    72. new g_pCvarHumanSpeedFactor,
    73.     g_pCvarHumanGravity,
    74.     g_pCvarHumanHealth,
    75.     g_pCvarZombieSpeed,
    76.     g_pCvarZombieGravity,
    77.     g_pCvarZombieReleaseTime,
    78.     g_pCvarFreezeTime,
    79.     g_pCvarRoundTime,
    80.     g_pCvarReqPlayers,
    81.     g_pCvarZombieHealth,
    82.     g_pCvarFirstZombiesHealth,
    83.     g_pCvarZombieKnockback,
    84.     g_pCvarScoreMessageType,
    85.     g_pCvarColors[3],
    86.     g_pCvarRoundEndDelay,
    87.     g_pCvarSmartRandom
    88.    
    89. // Dynamic Arrays
    90. new Array:g_aChosenPlayers
    91.  
    92. public plugin_natives()
    93. {
    94.     register_native("ze_is_user_zombie", "native_ze_is_user_zombie", 1)
    95.     register_native("ze_is_game_started", "native_ze_is_game_started", 1)
    96.     register_native("ze_is_zombie_frozen", "native_ze_is_zombie_frozen", 1)
    97.    
    98.     register_native("ze_get_round_number", "native_ze_get_round_number", 1)
    99.     register_native("ze_get_humans_number", "native_ze_get_humans_number", 1)
    100.     register_native("ze_get_zombies_number", "native_ze_get_zombies_number", 1)
    101.    
    102.     register_native("ze_set_user_zombie", "native_ze_set_user_zombie", 1)
    103.     register_native("ze_set_user_human", "native_ze_set_user_human", 1)
    104.     register_native("ze_set_human_speed_factor", "native_ze_set_human_speed_factor", 1)
    105.     register_native("ze_set_zombie_speed", "native_ze_set_zombie_speed", 1)
    106.    
    107.     register_native("ze_reset_human_speed", "native_ze_reset_human_speed", 1)
    108.     register_native("ze_reset_zombie_speed", "native_ze_reset_zombie_speed", 1)
    109.    
    110.     register_native("ze_get_user_knockback", "native_ze_get_user_knockback", 1)
    111.     register_native("ze_set_user_knockback", "native_ze_set_user_knockback", 1)
    112.     register_native("ze_reset_user_knockback", "native_ze_reset_user_knockback", 1)
    113.    
    114.     register_native("ze_set_user_gravity", "native_ze_set_user_gravity", 1)
    115.     register_native("ze_reset_user_gravity", "native_ze_reset_user_gravity", 1)
    116. }
    117.  
    118. public plugin_init()
    119. {
    120.     register_plugin("[ZE] Core/Engine", ZE_VERSION, AUTHORS)
    121.    
    122.     // Hook Chains
    123.     RegisterHookChain(RG_CBasePlayer_TraceAttack, "Fw_TraceAttack_Pre", 0)
    124.     RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
    125.     RegisterHookChain(RG_CBasePlayer_Spawn, "Fw_PlayerSpawn_Post", 1)
    126.     RegisterHookChain(RG_CSGameRules_CheckWinConditions, "Fw_CheckMapConditions_Post", 1)
    127.     RegisterHookChain(RG_CBasePlayer_Killed, "Fw_PlayerKilled_Post", 1)
    128.     RegisterHookChain(RG_RoundEnd, "Event_RoundEnd_Pre", 0)
    129.     RegisterHookChain(RG_CBasePlayer_ResetMaxSpeed, "Fw_RestMaxSpeed_Post", 1)
    130.     RegisterHookChain(RG_HandleMenu_ChooseTeam, "Fw_HandleMenu_ChooseTeam_Post", 1)
    131.     RegisterHookChain(RG_HandleMenu_ChooseAppearance, "Fw_HandleMenu_ChoosedAppearance_Post", 1)
    132.    
    133.     // Events
    134.     register_event("HLTV", "New_Round", "a", "1=0", "2=0")
    135.     register_event("TextMsg", "Map_Restart", "a", "2=#Game_Commencing", "2=#Game_will_restart_in", "2=#Round_Draw")
    136.     register_logevent("Round_Start", 2, "1=Round_Start")
    137.     register_logevent("Round_End", 2, "1=Round_End")
    138.    
    139.     // Create Forwards
    140.     g_iForwards[FORWARD_ROUNDEND] = CreateMultiForward("ze_roundend", ET_IGNORE, FP_CELL)
    141.     g_iForwards[FORWARD_HUMANIZED] = CreateMultiForward("ze_user_humanized", ET_IGNORE, FP_CELL)
    142.     g_iForwards[FORWARD_PRE_INFECTED] = CreateMultiForward("ze_user_infected_pre", ET_CONTINUE, FP_CELL, FP_CELL, FP_CELL)
    143.     g_iForwards[FORWARD_INFECTED] = CreateMultiForward("ze_user_infected", ET_IGNORE, FP_CELL, FP_CELL)
    144.     g_iForwards[FORWARD_ZOMBIE_APPEAR] = CreateMultiForward("ze_zombie_appear", ET_IGNORE)
    145.     g_iForwards[FORWARD_ZOMBIE_RELEASE] = CreateMultiForward("ze_zombie_release", ET_IGNORE)
    146.     g_iForwards[FORWARD_GAME_STARTED_PRE] = CreateMultiForward("ze_game_started_pre", ET_CONTINUE)
    147.     g_iForwards[FORWARD_GAME_STARTED] = CreateMultiForward("ze_game_started", ET_IGNORE)
    148.     g_iForwards[FORWARD_DISCONNECT] = CreateMultiForward("ze_player_disconnect", ET_CONTINUE, FP_CELL)
    149.    
    150.     // Hud Messages
    151.     g_iReleaseNotice = CreateHudSyncObj()
    152.    
    153.     // Registering Messages
    154.     register_message(get_user_msgid("TeamScore"), "Message_Teamscore")
    155.    
    156.     // Sequential files (.txt)
    157.     register_dictionary("zombie_escape.txt")
    158.    
    159.     // Humans Cvars
    160.     g_pCvarHumanSpeedFactor = register_cvar("ze_human_speed_factor", "20.0")
    161.     g_pCvarHumanGravity = register_cvar("ze_human_gravity", "800")
    162.     g_pCvarHumanHealth = register_cvar("ze_human_health", "1000")
    163.    
    164.     // Zombie Cvars
    165.     g_pCvarZombieSpeed = register_cvar("ze_zombie_speed", "350.0")
    166.     g_pCvarZombieGravity = register_cvar("ze_zombie_gravity", "640")
    167.     g_pCvarZombieHealth = register_cvar("ze_zombie_health", "10000")
    168.     g_pCvarFirstZombiesHealth = register_cvar("ze_first_zombies_health", "20000")
    169.     g_pCvarZombieKnockback = register_cvar("ze_zombie_knockback", "300.0")
    170.    
    171.     // General Cvars
    172.     g_pCvarZombieReleaseTime = register_cvar("ze_release_time", "15")
    173.     g_pCvarFreezeTime = register_cvar("ze_freeze_time", "20")
    174.     g_pCvarRoundTime = register_cvar("ze_round_time", "9.0")
    175.     g_pCvarReqPlayers = register_cvar("ze_required_players", "2")
    176.     g_pCvarScoreMessageType = register_cvar("ze_score_message_type", "1")
    177.     g_pCvarColors[Red] = register_cvar("ze_score_message_red", "200")
    178.     g_pCvarColors[Green] = register_cvar("ze_score_message_green", "100")
    179.     g_pCvarColors[Blue] = register_cvar("ze_score_message_blue", "0")
    180.     g_pCvarRoundEndDelay = register_cvar("ze_round_end_delay", "5")
    181.     g_pCvarSmartRandom = register_cvar("ze_smart_random", "1")
    182.    
    183.     // Default Values
    184.     g_bGameStarted = false
    185.    
    186.     // Static Values
    187.     g_iMaxClients = get_member_game(m_nMaxPlayers)
    188.    
    189.     // Check Round Time to Terminate it
    190.     set_task(1.0, "Check_RoundTimeleft", ROUND_TIME_LEFT, _, _, "b")
    191. }
    192.  
    193. public plugin_cfg()
    194. {
    195.     // Get our configiration file and Execute it
    196.     new szCfgDir[64]
    197.     get_localinfo("amxx_configsdir", szCfgDir, charsmax(szCfgDir))
    198.     server_cmd("exec %s/zombie_escape.cfg", szCfgDir)
    199.    
    200.     // Set Game Name
    201.     new szGameName[64]
    202.     formatex(szGameName, sizeof(szGameName), "Zombie Escape v%s", ZE_VERSION)
    203.     set_member_game(m_GameDesc, szGameName)
    204.    
    205.     // Set Version
    206.     register_cvar("ze_version", ZE_VERSION, FCVAR_SERVER|FCVAR_SPONLY)
    207.     set_cvar_string("ze_version", ZE_VERSION)
    208.    
    209.     // Delay so cvars be loaded from zombie_escape.cfg
    210.     set_task(0.1, "DelaySmartRandom")
    211.    
    212.     // Delay some settings
    213.     set_task(0.1, "DelaySettings")
    214. }
    215.  
    216. public DelaySettings()
    217. {
    218.     // Set some cvars, not allowed to be changed from any other .cfg file (Not recommended to remove them)
    219.     new pCvarRoundTime, pCvarFreezeTime, pCvarMaxSpeed
    220.    
    221.     pCvarRoundTime = get_cvar_pointer("mp_roundtime")
    222.     pCvarFreezeTime = get_cvar_pointer("mp_freezetime")
    223.     pCvarMaxSpeed = get_cvar_pointer("sv_maxspeed")
    224.    
    225.     set_pcvar_num(pCvarRoundTime, get_pcvar_num(g_pCvarRoundTime))
    226.     set_pcvar_num(pCvarFreezeTime, get_pcvar_num(g_pCvarFreezeTime))
    227.    
    228.     // Max speed at least equal to zombies speed. Here zombies speed assumed to be higher than humans one.
    229.     if (get_pcvar_num(pCvarMaxSpeed) < get_pcvar_num(g_pCvarZombieSpeed))
    230.     {
    231.         set_pcvar_num(pCvarMaxSpeed, get_pcvar_num(g_pCvarZombieSpeed))
    232.     }
    233. }
    234.  
    235. public DelaySmartRandom()
    236. {
    237.     if (get_pcvar_num(g_pCvarSmartRandom))
    238.     {
    239.         // Create our array to store SteamIDs in
    240.         g_aChosenPlayers = ArrayCreate(34)
    241.     }
    242. }
    243.  
    244. public Fw_CheckMapConditions_Post()
    245. {
    246.     // Block Game Commencing
    247.     set_member_game(m_bGameStarted, true)
    248.    
    249.     // Set Freeze Time
    250.     set_member_game(m_iIntroRoundTime, get_pcvar_num(g_pCvarFreezeTime))
    251.    
    252.     // Set Round Time
    253.     set_member_game(m_iRoundTime, floatround(get_pcvar_float(g_pCvarRoundTime) * 60.0))
    254. }
    255.  
    256. public Fw_PlayerKilled_Post(id)
    257. {
    258.     g_iAliveHumansNum = GetAlivePlayersNum(CsTeams:TEAM_CT)
    259.     g_iAliveZombiesNum = GetAlivePlayersNum(CsTeams:TEAM_TERRORIST)
    260.    
    261.     if (g_iAliveHumansNum == 0 && g_iAliveZombiesNum == 0)
    262.     {
    263.         // No Winner, All Players in one team killed Or Both teams Killed
    264.         client_print(0, print_center, "%L", LANG_PLAYER, "NO_WINNER")
    265.     }
    266. }
    267.  
    268. public Fw_RestMaxSpeed_Post(id)
    269. {
    270.     if (!g_bIsZombie[id])
    271.     {
    272.         static Float:flMaxSpeed
    273.         get_entvar(id, var_maxspeed, flMaxSpeed)
    274.        
    275.         if (flMaxSpeed != 1.0 && is_user_alive(id))
    276.         {
    277.             if (g_bHSpeedUsed[id])
    278.             {
    279.                 // Set New Human Speed Factor
    280.                 set_entvar(id, var_maxspeed, flMaxSpeed + float(g_iHSpeedFactor[id]))
    281.                 return HC_CONTINUE
    282.             }
    283.                
    284.             // Set Human Speed Factor, native not used
    285.             set_entvar(id, var_maxspeed, flMaxSpeed + get_pcvar_float(g_pCvarHumanSpeedFactor))
    286.             return HC_CONTINUE
    287.         }
    288.     }
    289.    
    290.     return HC_SUPERCEDE
    291. }
    292.  
    293. public Fw_PlayerSpawn_Post(id)
    294. {  
    295.     if (!g_bGameStarted)
    296.     {
    297.         // Force All player to be Humans if Game not started yet
    298.         rg_set_user_team(id, TEAM_CT, MODEL_UNASSIGNED)
    299.     }
    300.     else
    301.     {
    302.         if (get_member_game(m_bFreezePeriod))
    303.         {
    304.             // Respawn Him As human if we are in freeze time (Zombie Not Chosen yet)
    305.             Set_User_Human(id)
    306.             g_bIsZombieFrozen[id] = false
    307.         }
    308.         else
    309.         {
    310.             if (g_bZombieFreezeTime)
    311.             {
    312.                 // Zombie Chosen and zombies Frozen, Spawn him as zombie and Freeze Him
    313.                 Set_User_Zombie(id)
    314.                 g_bIsZombieFrozen[id] = true
    315.                 set_entvar(id, var_maxspeed, 1.0)
    316.             }
    317.             else
    318.             {
    319.                 // Respawn him as normal zombie
    320.                 Set_User_Zombie(id)
    321.                 g_bIsZombieFrozen[id] = false
    322.             }
    323.         }
    324.     }
    325. }
    326.  
    327. public New_Round()
    328. {
    329.     if (g_bGameStarted)
    330.     {
    331.         g_iRoundNum++
    332.     }
    333.    
    334.     ExecuteForward(g_iForwards[FORWARD_GAME_STARTED_PRE], g_iFwReturn)
    335.    
    336.     if (g_iFwReturn > 0)
    337.     {
    338.         return
    339.     }
    340.    
    341.     // Remove All tasks in the New Round
    342.     remove_task(TASK_COUNTDOWN)
    343.     remove_task(TASK_COUNTDOWN2)
    344.     remove_task(TASK_SCORE_MESSAGE)
    345.     remove_task(FREEZE_ZOMBIES)
    346.    
    347.     // Score Message Task
    348.     set_task(10.0, "Score_Message", TASK_SCORE_MESSAGE, _, _, "b")
    349.    
    350.     if (g_bGameStarted)
    351.     {
    352.         if (g_iRoundNum == 1)
    353.         {
    354.             // 2 is Hardcoded Value, It's Fix for the countdown to work correctly first round
    355.             g_iCountDown = get_member_game(m_iIntroRoundTime) - 2
    356.         }
    357.         else
    358.         {
    359.             // 3 is Hardcoded Value, It's Fix for the countdown to work correctly after first round
    360.             g_iCountDown = get_member_game(m_iIntroRoundTime) - 3
    361.         }
    362.     }
    363.    
    364.     if (!g_bGameStarted)
    365.     {
    366.         // No Enough Players
    367.         ze_colored_print(0, "%L", LANG_PLAYER, "NO_ENOUGH_PLAYERS", get_pcvar_num(g_pCvarReqPlayers))
    368.         return // Block the execution of the blew code
    369.     }
    370.    
    371.     // Game Already started, Countdown now started
    372.     set_task(1.0, "Countdown_Start", TASK_COUNTDOWN, _, _, "b")
    373.     ze_colored_print(0, "%L", LANG_PLAYER, "READY_TO_RUN")
    374.     ExecuteForward(g_iForwards[FORWARD_GAME_STARTED], g_iFwReturn)
    375.    
    376.     // Round Starting
    377.     g_bIsRoundEnding = false
    378.     g_bEndCalled = false
    379. }
    380.  
    381. // Score Message Task
    382. public Score_Message(TaskID)
    383. {
    384.     switch(get_pcvar_num(g_pCvarScoreMessageType))
    385.     {
    386.         case 0: // Disabled
    387.         {
    388.             return
    389.         }
    390.         case 1: // DHUD
    391.         {
    392.             set_dhudmessage(get_pcvar_num(g_pCvarColors[Red]), get_pcvar_num(g_pCvarColors[Green]), get_pcvar_num(g_pCvarColors[Blue]), -1.0, 0.01, 0, 0.0, 9.0)
    393.             show_dhudmessage(0, "%L", LANG_PLAYER, "SCORE_MESSAGE", g_iZombiesScore, g_iHumansScore)
    394.         }
    395.         case 2: // HUD
    396.         {
    397.             set_hudmessage(get_pcvar_num(g_pCvarColors[Red]), get_pcvar_num(g_pCvarColors[Green]), get_pcvar_num(g_pCvarColors[Blue]), -1.0, 0.01, 0, 0.0, 9.0)
    398.             show_hudmessage(0, "%L", LANG_PLAYER, "SCORE_MESSAGE", g_iZombiesScore, g_iHumansScore)
    399.         }
    400.     }
    401. }
    402.  
    403. public Countdown_Start(TaskID)
    404. {
    405.     // Check if the players Disconnected and there is only one player then remove all messages, and stop tasks
    406.     if (!g_bGameStarted)
    407.         return
    408.    
    409.     if (!g_iCountDown)
    410.     {
    411.         Choose_Zombies()
    412.         remove_task(TASK_COUNTDOWN) // Remove the task
    413.         return // Block the execution of the blew code
    414.     }
    415.    
    416.     set_hudmessage(random(256), random(256), random(256), -1.0, 0.21, 0, 0.8, 0.8)
    417.     show_hudmessage(0, "%L", LANG_PLAYER, "RUN_NOTICE", g_iCountDown)
    418.  
    419.     g_iCountDown--
    420. }
    421.  
    422. public Choose_Zombies()
    423. {
    424.     new iZombies, id, iAliveCount
    425.     new iReqZombies
    426.    
    427.     // Get total alive players and required players
    428.     iAliveCount  = GetAllAlivePlayersNum()
    429.     iReqZombies = RequiredZombies()
    430.    
    431.     // Loop till we find req players
    432.     while(iZombies < iReqZombies)
    433.     {
    434.         id = GetRandomAlive(random_num(1, iAliveCount))
    435.        
    436.         if (!is_user_alive(id) || g_bIsZombie[id])
    437.             continue
    438.        
    439.         if (get_pcvar_num(g_pCvarSmartRandom))
    440.         {
    441.             // If player in the array, it means he chosen previous round so skip him this round
    442.             if (IsPlayerInArray(g_aChosenPlayers, id))
    443.                 continue
    444.         }
    445.  
    446.         Set_User_Zombie(id)
    447.        
    448.         if (ze_get_vip_flags(id) & HEALTH)
    449.         {
    450.             set_entvar(id, var_health, float(get_pcvar_num(g_pCvarFirstZombiesHealth) + ZOMBIE_INCREASE))
    451.         }
    452.         else
    453.         {
    454.             set_entvar(id, var_health, get_pcvar_float(g_pCvarFirstZombiesHealth))
    455.         }
    456.        
    457.         g_bIsZombieFrozen[id] = true
    458.         g_bZombieFreezeTime = true
    459.         set_entvar(id, var_maxspeed, 1.0)
    460.         set_task(0.1, "Freeze_Zombies", FREEZE_ZOMBIES, _, _, "b") // Better than PreThink
    461.         ExecuteForward(g_iForwards[FORWARD_ZOMBIE_APPEAR], g_iFwReturn)
    462.         iZombies++
    463.     }
    464.    
    465.     if (get_pcvar_num(g_pCvarSmartRandom))
    466.     {
    467.         // Clear the array first
    468.         ArrayClear(g_aChosenPlayers)
    469.        
    470.         new szAuthId[34]
    471.        
    472.         // Add steamid of chosen zombies, so we don't choose them next round again (using steamid means it support reconnect)
    473.         for (new id = 1; id <= g_iMaxClients; id++)
    474.         {
    475.             if(!is_user_connected(id) || !g_bIsZombie[id])
    476.                 continue
    477.            
    478.             get_user_authid(id, szAuthId, charsmax(szAuthId))
    479.            
    480.             ArrayPushString(g_aChosenPlayers, szAuthId)
    481.         }
    482.     }
    483.    
    484.     // 2 is Hardcoded Value, It's Fix for the countdown to work correctly
    485.     g_iCountDown = get_pcvar_num(g_pCvarZombieReleaseTime) - 2
    486.    
    487.     set_task(1.0, "ReleaseZombie_CountDown", TASK_COUNTDOWN2, _, _, "b")
    488. }
    489.  
    490. public ReleaseZombie_CountDown(TaskID)
    491. {
    492.     if (!g_iCountDown)
    493.     {
    494.         ReleaseZombie()
    495.         remove_task(TASK_COUNTDOWN2)
    496.         return
    497.     }
    498.    
    499.     // Release Hud Message
    500.     set_hudmessage(255, 255, 0, -1.0, 0.21, 1, 2.0, 2.0)
    501.     ShowSyncHudMsg(0, g_iReleaseNotice, "%L", LANG_PLAYER, "ZOMBIE_RELEASE", g_iCountDown)
    502.    
    503.     g_iCountDown --
    504. }
    505.  
    506. public ReleaseZombie()
    507. {
    508.     ExecuteForward(g_iForwards[FORWARD_ZOMBIE_RELEASE], g_iFwReturn)
    509.    
    510.     for(new id = 1; id <= g_iMaxClients; id++)
    511.     {
    512.         if (is_user_alive(id) && g_bIsZombie[id])
    513.         {
    514.             g_bIsZombieFrozen[id] = false
    515.             g_bZombieFreezeTime = false
    516.         }
    517.     }
    518. }
    519.  
    520. public Freeze_Zombies(TaskID)
    521. {
    522.     for(new id = 1; id <= g_iMaxClients; id++)
    523.     {
    524.         if(!is_user_alive(id) || !g_bIsZombie[id])
    525.             continue
    526.        
    527.         if (g_bIsZombieFrozen[id])
    528.         {
    529.             // Zombie & Frozen, then Freeze him
    530.             set_entvar(id, var_maxspeed, 1.0)
    531.         }
    532.         else
    533.         {
    534.             if (g_bZSpeedUsed[id])
    535.             {
    536.                 // Zombie but Not Frozen the set his speed form .cfg
    537.                 set_entvar(id, var_maxspeed, float(g_iZSpeedSet[id]))
    538.                 continue;
    539.             }
    540.                
    541.             // Zombie but Not Frozen the set his speed form .cfg
    542.             set_entvar(id, var_maxspeed, get_pcvar_float(g_pCvarZombieSpeed))
    543.         }
    544.     }
    545. }
    546.  
    547. public Fw_TraceAttack_Pre(iVictim, iAttacker, Float:flDamage, Float:flDirection[3], iTracehandle, bitsDamageType)
    548. {
    549.     if (iVictim == iAttacker || !is_user_connected(iVictim) || !is_user_connected(iAttacker))
    550.         return HC_CONTINUE
    551.    
    552.     // Attacker and Victim is in same teams? Skip code blew
    553.     if (get_member(iAttacker, m_iTeam) == get_member(iVictim, m_iTeam))
    554.         return HC_CONTINUE
    555.    
    556.     // In freeze time? Skip all other plugins (Skip the real trace attack event)
    557.     if (g_bIsZombieFrozen[iVictim] || g_bIsZombieFrozen[iAttacker])
    558.         return HC_SUPERCEDE
    559.    
    560.     // Execute pre-infection forward
    561.     ExecuteForward(g_iForwards[FORWARD_PRE_INFECTED], g_iFwReturn, iVictim, iAttacker, floatround(flDamage))
    562.    
    563.     if (g_iFwReturn > 0)
    564.     {
    565.         return HC_SUPERCEDE
    566.     }
    567.    
    568.     g_iAliveHumansNum = GetAlivePlayersNum(CsTeams:TEAM_CT)
    569.    
    570.     if (g_bIsZombie[iAttacker])
    571.     {
    572.         // Death Message with Infection style [Added here because of delay in Forward use]
    573.         SendDeathMsg(iAttacker, iVictim)
    574.        
    575.         Set_User_Zombie(iVictim)
    576.        
    577.         ExecuteForward(g_iForwards[FORWARD_INFECTED], g_iFwReturn, iVictim, iAttacker)
    578.        
    579.         if (g_iAliveHumansNum == 1) // Check if this is Last Human, Because of Delay i can't check if it's 0 instead of 1
    580.         {
    581.             // End round event called one time
    582.             g_bEndCalled = true
    583.            
    584.             // Round is Ending
    585.             g_bIsRoundEnding = true
    586.            
    587.             // Zombie Win, Leave text blank so we use ours from ML
    588.             rg_round_end(get_pcvar_float(g_pCvarRoundEndDelay), WINSTATUS_TERRORISTS, ROUND_TERRORISTS_WIN, "")
    589.            
    590.             // Show Our Message
    591.             client_print(0, print_center, "%L", LANG_PLAYER, "ESCAPE_FAIL")
    592.            
    593.             // This needed so forward work also to add +1 for Zombies
    594.             g_iTeam = ZE_TEAM_ZOMBIE
    595.             ExecuteForward(g_iForwards[FORWARD_ROUNDEND], g_iFwReturn, g_iTeam)
    596.         }
    597.     }
    598.    
    599.     return HC_CONTINUE
    600. }
    601.  
    602. public Fw_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:flDamage, bitsDamageType)
    603. {
    604.     // Not Vaild Victim or Attacker so skip the event (Important to block out bounds errors)
    605.     if (!is_user_connected(iVictim) || !is_user_connected(iAttacker))
    606.         return HC_CONTINUE
    607.    
    608.     // Set Knockback here, So if we blocked damage in TraceAttack event player won't get knockback (Fix For Madness)
    609.     if (g_bIsZombie[iVictim] && !g_bIsZombie[iAttacker])
    610.     {
    611.         // Remove Shock Pain
    612.         set_member(iVictim, m_flVelocityModifier, 1.0)
    613.        
    614.         // Set Knockback
    615.         static Float:flOrigin[3]
    616.         get_entvar(iAttacker, var_origin, flOrigin)
    617.         Set_Knockback(iVictim, flOrigin, g_bIsKnockBackUsed[iVictim] ? g_flUserKnockback[iVictim]:get_pcvar_float(g_pCvarZombieKnockback), 2)
    618.     }
    619.    
    620.     return HC_CONTINUE
    621. }
    622.  
    623. public Round_End()
    624. {
    625.     g_iAliveZombiesNum = GetAlivePlayersNum(CsTeams:TEAM_TERRORIST)
    626.    
    627.     if (g_iAliveZombiesNum == 0 && g_bGameStarted)
    628.     {
    629.         g_iTeam = ZE_TEAM_HUMAN
    630.         ExecuteForward(g_iForwards[FORWARD_ROUNDEND], g_iFwReturn, g_iTeam)
    631.         client_print(0, print_center, "%L", LANG_PLAYER, "ESCAPE_SUCCESS")
    632.         g_iHumansScore++
    633.         g_bIsRoundEnding = true
    634.         return // To block Execute the code blew
    635.     }
    636.    
    637.     g_iTeam = ZE_TEAM_ZOMBIE
    638.     g_iZombiesScore++
    639.     g_bIsRoundEnding = true
    640.    
    641.     // If it's already called one time, don't call it again
    642.     if (!g_bEndCalled)
    643.     {
    644.         ExecuteForward(g_iForwards[FORWARD_ROUNDEND], g_iFwReturn, g_iTeam)
    645.     }
    646.    
    647.     client_print(0, print_center, "%L", LANG_PLAYER, "ESCAPE_FAIL")
    648. }
    649.  
    650. public Event_RoundEnd_Pre(WinStatus:status, ScenarioEventEndRound:event, Float:tmDelay)
    651. {
    652.     // The two unhandeld cases by rg_round_end() native in our Mod
    653.     if (event == ROUND_CTS_WIN || event == ROUND_TERRORISTS_WIN)
    654.     {
    655.         SetHookChainArg(3, ATYPE_FLOAT, get_pcvar_float(g_pCvarRoundEndDelay))
    656.     }
    657. }
    658.  
    659. public Round_Start()
    660. {
    661.     g_flReferenceTime = get_gametime()
    662.     g_iRoundTime = get_member_game(m_iRoundTime)
    663. }
    664.  
    665. public Check_RoundTimeleft()
    666. {
    667.     new Float:flRoundTimeLeft = (g_flReferenceTime + float(g_iRoundTime)) - get_gametime()
    668.    
    669.     if (floatround(flRoundTimeLeft) == 0 && !g_bIsRoundEnding && !get_member_game(m_bFreezePeriod))
    670.     {
    671.         // Round is Ending
    672.         g_bIsRoundEnding = true
    673.        
    674.         // If Time is Out then Terminate the Round
    675.         rg_round_end(get_pcvar_float(g_pCvarRoundEndDelay), WINSTATUS_TERRORISTS, ROUND_TERRORISTS_WIN, "")
    676.        
    677.         // Show our Message
    678.         client_print(0, print_center, "%L", LANG_PLAYER, "ESCAPE_FAIL")
    679.     }
    680. }
    681.  
    682. public client_disconnected(id)
    683. {
    684.     // Reset speed for this dropped id
    685.     g_bHSpeedUsed[id] = false
    686.     g_bZSpeedUsed[id] = false
    687.     g_bIsKnockBackUsed[id] = false
    688.     g_bIsGravityUsed[id] = false
    689.     g_flUserKnockback[id] = 0.0
    690.     g_iUserGravity[id] = 0
    691.    
    692.     remove_task(id)
    693.    
    694.     // Execute our disconnected forward
    695.     ExecuteForward(g_iForwards[FORWARD_DISCONNECT], g_iFwReturn, id)
    696.    
    697.     if (g_iFwReturn > 0)
    698.     {
    699.         // Here return, function ended here, below won't be executed
    700.         return
    701.     }
    702.    
    703.     // Delay Then Check Players to Terminate The round (Delay needed)
    704.     set_task(0.1, "Check_AlivePlayers")
    705. }
    706.  
    707. // This check done when player disconnect
    708. public Check_AlivePlayers()
    709. {
    710.     g_iAliveZombiesNum = GetAlivePlayersNum(CsTeams:TEAM_TERRORIST)
    711.     g_iAliveHumansNum = GetAlivePlayersNum(CsTeams:TEAM_CT)
    712.    
    713.     // Game Started? (There is at least 2 players Alive?)
    714.     if (g_bGameStarted)
    715.     {
    716.         // We are in freeze time?
    717.         if (get_member_game(m_bFreezePeriod))
    718.         {
    719.             // Humans alive number = 1 and no zombies?
    720.             if (g_iAliveHumansNum < get_pcvar_num(g_pCvarReqPlayers))
    721.             {
    722.                 // Game started false again
    723.                 g_bGameStarted = false
    724.             }
    725.         }
    726.         else // Not freeze time?
    727.         {
    728.             // Variables
    729.             new iAllZombiesNum = GetTeamPlayersNum(CsTeams:TEAM_TERRORIST),
    730.             iAllHumansNum = GetTeamPlayersNum(CsTeams:TEAM_CT),
    731.             iDeadZombiesNum = GetDeadPlayersNum(CsTeams:TEAM_TERRORIST),
    732.             iDeadHumansNum = GetDeadPlayersNum(CsTeams:TEAM_CT)
    733.    
    734.             // Alive humans number = 1 and no zombies at all, And no dead humans?
    735.             if (g_iAliveHumansNum < get_pcvar_num(g_pCvarReqPlayers) && iDeadHumansNum == 0 && iAllZombiesNum == 0)
    736.             {
    737.                 // Game started is false and humans wins (Escape Success)
    738.                 g_bGameStarted = false
    739.                 rg_round_end(get_pcvar_float(g_pCvarRoundEndDelay), WINSTATUS_CTS, ROUND_CTS_WIN, "")
    740.                 client_print(0, print_center, "%L", LANG_PLAYER, "ESCAPE_SUCCESS")
    741.             }
    742.            
    743.             // Alive zombies number = 1 and no humans at all, And no dead zombies?
    744.             if (g_iAliveZombiesNum < get_pcvar_num(g_pCvarReqPlayers) && iDeadZombiesNum == 0 && iAllHumansNum == 0)
    745.             {
    746.                 // Game started is false and zombies wins (Escape Fail)
    747.                 g_bGameStarted = false
    748.                 rg_round_end(get_pcvar_float(g_pCvarRoundEndDelay), WINSTATUS_TERRORISTS, ROUND_TERRORISTS_WIN, "")
    749.                 client_print(0, print_center, "%L", LANG_PLAYER, "ESCAPE_FAIL")
    750.             }
    751.            
    752.             // Humans number more than 1 and no zombies?
    753.             if (g_iAliveHumansNum >= get_pcvar_num(g_pCvarReqPlayers) && g_iAliveZombiesNum == 0 && !g_bIsRoundEnding)
    754.             {
    755.                 // Then Escape success as there is no Zombies
    756.                 rg_round_end(get_pcvar_float(g_pCvarRoundEndDelay), WINSTATUS_CTS, ROUND_CTS_WIN, "")
    757.                 client_print(0, print_center, "%L", LANG_PLAYER, "ESCAPE_SUCCESS")
    758.             }
    759.            
    760.             // Zombies number more than 1 and no humans?
    761.             if (g_iAliveZombiesNum >= get_pcvar_num(g_pCvarReqPlayers) && g_iAliveHumansNum == 0 && !g_bIsRoundEnding)
    762.             {
    763.                 // Then Escape Fail as there is no humans
    764.                 rg_round_end(get_pcvar_float(g_pCvarRoundEndDelay), WINSTATUS_TERRORISTS, ROUND_TERRORISTS_WIN, "")
    765.                 client_print(0, print_center, "%L", LANG_PLAYER, "ESCAPE_FAIL")
    766.             }
    767.         }
    768.     }
    769. }
    770.  
    771. public client_putinserver(id)
    772. {
    773.     // Add Delay and Check Conditions To start the Game (Delay needed)
    774.     set_task(1.0, "Check_AllPlayersNumber", _, _, _, "b")
    775.    
    776.     // Check for dead terrorists - Bug fix
    777.     set_task(0.1, "CheckTerrorists", id, _, _, "b")
    778. }
    779.  
    780. public CheckTerrorists(id)
    781. {
    782.     if (g_bEnteredNotChoosed[id] && g_bGameStarted)
    783.     {
    784.         if (is_user_connected(id))
    785.         {
    786.             rg_join_team(id, TEAM_CT) // Force user to choose CT
    787.             g_bEnteredNotChoosed[id] = false
    788.         }
    789.     }
    790. }
    791.  
    792. public Fw_HandleMenu_ChoosedAppearance_Post(const index, const slot)
    793. {
    794.     g_bEnteredNotChoosed[index] = false
    795. }
    796.  
    797. public Fw_HandleMenu_ChooseTeam_Post(id, MenuChooseTeam:iSlot)
    798. {
    799.     // Fixing Dead-T restarting the round
    800.     if (iSlot == MenuChoose_T) // Choosed T, Still not choosed a player
    801.     {
    802.         g_bEnteredNotChoosed[id] = true
    803.     }
    804.    
    805.     if ((iSlot == MenuChoose_AutoSelect) && (get_member(id, m_iTeam) == TEAM_TERRORIST))
    806.     {
    807.         g_bEnteredNotChoosed[id] = true
    808.     }
    809.    
    810.     // Add Delay and Check Conditions To start the Game (Delay needed)
    811.     set_task(1.0, "Check_AllPlayersNumber", _, _, _, "b")
    812. }
    813.  
    814. public Check_AllPlayersNumber(TaskID)
    815. {
    816.     if (g_bGameStarted)
    817.     {
    818.         // If game started remove the task and block the blew Checks
    819.         remove_task(TaskID)
    820.         return
    821.     }
    822.    
    823.     if (GetAllAlivePlayersNum() >= get_pcvar_num(g_pCvarReqPlayers))
    824.     {
    825.         // Players In server == The Required so game started is true
    826.         g_bGameStarted = true
    827.        
    828.         // Restart the game
    829.         server_cmd("sv_restart 2")
    830.        
    831.         // Print Fake game Commencing Message
    832.         client_print(0, print_center, "%L", LANG_PLAYER, "START_GAME")
    833.        
    834.         // Remove the task
    835.         remove_task(TaskID)
    836.     }
    837. }
    838.  
    839. public Set_User_Human(id)
    840. {
    841.     if (!is_user_alive(id))
    842.         return
    843.    
    844.     g_bIsZombie[id] = false
    845.    
    846.     if (ze_get_vip_flags(id) & HEALTH)
    847.     {
    848.         set_entvar(id, var_health, float(get_pcvar_num(g_pCvarHumanHealth) + HUMAN_INCREASE))
    849.     }
    850.     else
    851.     {
    852.         set_entvar(id, var_health, get_pcvar_float(g_pCvarHumanHealth))
    853.     }
    854.    
    855.     set_entvar(id, var_gravity, float(g_bIsGravityUsed[id] ? g_iUserGravity[id]:get_pcvar_num(g_pCvarHumanGravity))/800.0)
    856.     ExecuteForward(g_iForwards[FORWARD_HUMANIZED], g_iFwReturn, id)
    857.    
    858.     // Reset Nightvision (Useful for antidote, so when someone use sethuman native the nightvision also reset)
    859.     Set_NightVision(id, 0, 0, 0x0000, 0, 0, 0, 0)
    860.    
    861.     if (get_member(id, m_iTeam) != TEAM_CT)
    862.         rg_set_user_team(id, TEAM_CT, MODEL_UNASSIGNED)
    863. }
    864.  
    865. public Set_User_Zombie(id)
    866. {
    867.     if (!is_user_alive(id))
    868.         return
    869.    
    870.     g_bIsZombie[id] = true
    871.    
    872.     if (ze_get_vip_flags(id) & HEALTH)
    873.     {
    874.         set_entvar(id, var_health, float(get_pcvar_num(g_pCvarZombieHealth) + ZOMBIE_INCREASE))
    875.     }
    876.     else
    877.     {
    878.         set_entvar(id, var_health, get_pcvar_float(g_pCvarZombieHealth))
    879.     }
    880.    
    881.     set_entvar(id, var_gravity, float(g_bIsGravityUsed[id] ? g_iUserGravity[id] : get_pcvar_num(g_pCvarZombieGravity))/800.0)
    882.     rg_remove_all_items(id)
    883.     rg_give_item(id, "weapon_knife", GT_APPEND)
    884.     ExecuteForward(g_iForwards[FORWARD_INFECTED], g_iFwReturn, id, 0)
    885.    
    886.     if (get_member(id, m_iTeam) != TEAM_TERRORIST)
    887.         rg_set_user_team(id, TEAM_TERRORIST, MODEL_UNASSIGNED)
    888. }
    889.  
    890. public Map_Restart()
    891. {
    892.     // Add Delay To help Rest Scores if player kill himself, and there no one else him so round draw (Delay needed)
    893.     set_task(0.1, "Reset_Score_Message")
    894. }
    895.  
    896. public Reset_Score_Message()
    897. {
    898.     g_iHumansScore = 0
    899.     g_iZombiesScore = 0
    900.     g_iRoundNum = 0
    901. }
    902.  
    903. public plugin_end()
    904. {
    905.     if (get_pcvar_num(g_pCvarSmartRandom))
    906.     {
    907.         ArrayDestroy(g_aChosenPlayers)
    908.     }
    909. }
    910.  
    911. public Message_Teamscore()
    912. {
    913.     new szTeam[2]
    914.     get_msg_arg_string(1, szTeam, charsmax(szTeam))
    915.    
    916.     switch (szTeam[0])
    917.     {
    918.         case 'C': set_msg_arg_int(2, get_msg_argtype(2), g_iHumansScore)
    919.         case 'T': set_msg_arg_int(2, get_msg_argtype(2), g_iZombiesScore)
    920.     }
    921. }
    922.  
    923. // Natives
    924. public native_ze_is_user_zombie(id)
    925. {
    926.     if (!is_user_connected(id))
    927.     {
    928.         return -1;
    929.     }
    930.    
    931.     return g_bIsZombie[id]
    932. }
    933.  
    934. public native_ze_set_user_zombie(id)
    935. {
    936.     if (!is_user_connected(id))
    937.     {
    938.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
    939.         return false;
    940.     }
    941.    
    942.     Set_User_Zombie(id)
    943.     return true;
    944. }
    945.  
    946. public native_ze_set_user_human(id)
    947. {
    948.     if (!is_user_connected(id))
    949.     {
    950.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
    951.         return false;
    952.     }
    953.    
    954.     Set_User_Human(id)
    955.     return true;
    956. }
    957.  
    958. public native_ze_is_game_started()
    959. {
    960.     return g_bGameStarted
    961. }
    962.  
    963. public native_ze_is_zombie_frozen(id)
    964. {
    965.     if (!is_user_connected(id) || !g_bIsZombie[id])
    966.     {
    967.         return -1;
    968.     }
    969.    
    970.     return g_bIsZombieFrozen[id]
    971. }
    972.  
    973. public native_ze_get_round_number()
    974. {
    975.     if (!g_bGameStarted)
    976.     {
    977.         return -1;
    978.     }
    979.    
    980.     return g_iRoundNum
    981. }
    982.  
    983. public native_ze_get_humans_number()
    984. {
    985.     return GetAlivePlayersNum(CsTeams:TEAM_CT)
    986. }
    987.  
    988. public native_ze_get_zombies_number()
    989. {
    990.     return GetAlivePlayersNum(CsTeams:TEAM_TERRORIST)
    991. }
    992.  
    993. public native_ze_set_human_speed_factor(id, iFactor)
    994. {
    995.     if (!is_user_connected(id))
    996.     {
    997.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
    998.         return false;
    999.     }
    1000.    
    1001.     g_bHSpeedUsed[id] = true
    1002.     g_iHSpeedFactor[id] = iFactor
    1003.     rg_reset_maxspeed(id)
    1004.     return true;
    1005. }
    1006.  
    1007. public native_ze_reset_human_speed(id)
    1008. {
    1009.     if (!is_user_connected(id))
    1010.     {
    1011.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
    1012.         return false;
    1013.     }
    1014.    
    1015.     g_bHSpeedUsed[id] = false
    1016.     rg_reset_maxspeed(id)
    1017.     return true;
    1018. }
    1019.  
    1020. public native_ze_set_zombie_speed(id, iSpeed)
    1021. {
    1022.     if (!is_user_connected(id))
    1023.     {
    1024.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
    1025.         return false;
    1026.     }
    1027.    
    1028.     g_bZSpeedUsed[id] = true
    1029.     g_iZSpeedSet[id] = iSpeed
    1030.     return true;
    1031. }
    1032.  
    1033. public native_ze_reset_zombie_speed(id)
    1034. {
    1035.     if (!is_user_connected(id))
    1036.     {
    1037.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
    1038.         return false;
    1039.     }
    1040.    
    1041.     g_bZSpeedUsed[id] = false
    1042.     return true;
    1043. }
    1044.  
    1045. public native_ze_get_user_knockback(id)
    1046. {
    1047.     if (!is_user_connected(id))
    1048.     {
    1049.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
    1050.         return -1
    1051.     }
    1052.  
    1053.     return floatround(g_bIsKnockBackUsed[id] ? g_flUserKnockback[id]:get_pcvar_float(g_pCvarZombieKnockback))
    1054. }
    1055.  
    1056. public native_ze_set_user_knockback(id, Float:flKnockback)
    1057. {
    1058.     if (!is_user_connected(id))
    1059.     {
    1060.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
    1061.         return false
    1062.     }
    1063.    
    1064.     g_bIsKnockBackUsed[id] = true
    1065.     g_flUserKnockback[id] = flKnockback
    1066.     return true
    1067. }
    1068.  
    1069. public native_ze_reset_user_knockback(id)
    1070. {
    1071.     if (!is_user_connected(id))
    1072.     {
    1073.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
    1074.         return false
    1075.     }
    1076.  
    1077.     g_bIsKnockBackUsed[id] = false
    1078.     g_flUserKnockback[id] = 0.0
    1079.     return true
    1080. }
    1081.  
    1082. public native_ze_set_user_gravity(id, iGravity)
    1083. {
    1084.     if (!is_user_connected(id))
    1085.     {
    1086.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
    1087.         return false
    1088.     }
    1089.    
    1090.     g_bIsGravityUsed[id] = true
    1091.     g_iUserGravity[id] = iGravity
    1092.     set_entvar(id, var_gravity, float(iGravity) / 800.0)
    1093.  
    1094.     return true
    1095. }
    1096.  
    1097. public native_ze_reset_user_gravity(id)
    1098. {
    1099.     if (!is_user_connected(id))
    1100.     {
    1101.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
    1102.         return false
    1103.     }
    1104.  
    1105.     g_bIsGravityUsed[id] = false
    1106.     set_entvar(id, var_gravity, float(g_bIsZombie[id] ? get_pcvar_num(g_pCvarZombieGravity):get_pcvar_num(g_pCvarHumanGravity)) / 800.0)
    1107.  
    1108.     return true
    1109. }
He who fails to plan is planning to fail

Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Who is online

Users browsing this forum: No registered users and 7 guests