Round End Control
Description:
- After humans escaped, it's assumed that all zombies must die and the round end. Sometimes some zombies not dead, and they delay next round. This plugin will give zombies change for x seconds to infect all humans, if they fail they will be slayed and round end.
auto_slay_delay_control 90
Time after it the zombies will be slayed.
hud_enable_autoslay 1
Enable DHUD countdown for zombies.
Code:
- /*
- * This will hook the trigger_hurt when it's activated.
- * What i know is that trigger_hurt can be activated via button or trigger_multiple
- * This method is good for maps that conatin trains..etc
- * Also we will hook which using trigger_multiple only
- *
- * If user is touching the train and this player touched trigger_multiple then the trigger_hurt will be called.
- * In fact the trigger_hurt will be called once trigger_multiple is touched by player but we will tie it with train also. Away to avoid hardcode every map.
- */
- #include "zombie_escape.inc"
- #define MIN_DAMAGE 9000
- // Add all moving entities
- new const g_szEntities[][] =
- {
- "func_tracktrain",
- "func_vehicle"
- }
- new Float:g_flLastTouched[33], bool:g_bCalled, g_iTriggerHurtForward, g_szMapName[32]
- public plugin_init()
- {
- register_plugin("Hook Trigger Hurt", "1.0", "Raheem")
- for(new iEnt = 0; iEnt <= charsmax(g_szEntities); iEnt++)
- {
- RegisterHam(Ham_Touch, g_szEntities[iEnt], "Fw_TouchMoving_Pre", 0)
- }
- RegisterHam(Ham_Touch, "trigger_multiple", "Fw_TouchTriggerMultiple_Pre", 0)
- // Here we register touching any trigger_hurt
- RegisterHam(Ham_Touch, "trigger_hurt", "Fw_TouchTrigger_Pre", 0)
- g_iTriggerHurtForward = CreateMultiForward("ze_trigger_hurt", ET_IGNORE)
- // Get map name
- get_mapname(g_szMapName, charsmax(g_szMapName))
- }
- public ze_game_started()
- {
- g_bCalled = false
- }
- public Fw_TouchTriggerMultiple_Pre(iEnt, id)
- {
- // ze_military_v1 only use normal trigger hurt calling
- if (equal(g_szMapName, "ze_military_v1"))
- return
- // Here player touching trigger_multiple
- // Let's check first if he is touching also the train or not
- if (TouchingMovingVehicle(id))
- {
- if (equal(g_szMapName, "ze_metropolitano_lg"))
- {
- new szModel[32]
- get_entvar(iEnt, EntVars:var_model, szModel, charsmax(szModel))
- if (equal(szModel, "*44"))
- {
- if (!g_bCalled)
- {
- ExecuteForward(g_iTriggerHurtForward)
- g_bCalled = true
- }
- }
- return
- }
- if (equal(g_szMapName, "ze_black_train_v1"))
- {
- new szModel[32]
- pev(iEnt, pev_model, szModel, charsmax(szModel))
- //get_entvar(iEnt, EntVars:var_model, szModel, charsmax(szModel))
- if (equal(szModel, "*34"))
- {
- if (!g_bCalled)
- {
- ExecuteForward(g_iTriggerHurtForward)
- g_bCalled = true
- }
- }
- return
- }
- // Player in vehicle and he touched trigger_multiple
- if (!g_bCalled)
- {
- // Here we execute our forward
- ExecuteForward(g_iTriggerHurtForward)
- g_bCalled = true
- }
- }
- }
- public Fw_TouchTrigger_Pre(iEnt, id)
- {
- if (!is_user_alive(id) || !pev_valid(iEnt))
- return HAM_IGNORED
- if (equal(g_szMapName, "ze_black_train_v1"))
- return HAM_IGNORED
- if (pev(iEnt, pev_dmg) > MIN_DAMAGE)
- {
- if (!g_bCalled)
- {
- ExecuteForward(g_iTriggerHurtForward)
- g_bCalled = true
- }
- }
- return HAM_IGNORED
- }
- public Fw_TouchMoving_Pre(iEnt, id)
- {
- if (!is_user_connected(id))
- return HAM_IGNORED;
- // ze_jurassicpark_v2 map
- if (equal(g_szMapName, "ze_jurassicpark_v2"))
- {
- new szModel[32]
- get_entvar(iEnt, EntVars:var_model, szModel, charsmax(szModel))
- if (equal(szModel, "*51"))
- {
- return HAM_IGNORED;
- }
- }
- // ze_egyptopark map
- if (equal(g_szMapName, "ze_egyptopark"))
- {
- new szModel[32]
- get_entvar(iEnt, EntVars:var_model, szModel, charsmax(szModel))
- if (equal(szModel, "*30"))
- {
- return HAM_IGNORED;
- }
- }
- g_flLastTouched[id] = get_gametime()
- return HAM_IGNORED;
- }
- stock TouchingMovingVehicle(id)
- {
- if (!is_user_alive(id))
- return false;
- if (g_flLastTouched[id] + 0.01 >= get_gametime()) /* For more accurecy lower 0.1 to for example 0.01*/
- {
- return true;
- }
- return false;
- }
- #include <zombie_escape>
- #define MESSAGE_TASK 11661
- #define CHANCE_TASK 22331
- forward ze_trigger_hurt();
- // Cvars
- new g_pCvarDelayTime, g_pCvarDHUHEnable
- // Variables
- new bool:g_bMessageAppeared, g_iCounter[33], g_iMaxClients, g_szMapName[32]
- public plugin_init()
- {
- register_plugin("Round End Control", "1.0", "Raheem")
- // Cvars
- g_pCvarDelayTime = register_cvar("auto_slay_delay_control", "90")
- g_pCvarDHUHEnable = register_cvar("hud_enable_autoslay", "1")
- g_iMaxClients = get_member_game(m_nMaxPlayers)
- // Get map name
- get_mapname(g_szMapName, charsmax(g_szMapName))
- }
- public ze_trigger_hurt()
- {
- if (equal(g_szMapName, "ze_black_train_v1"))
- {
- set_task(45.0, "CheckPlayers")
- return
- }
- set_task(20.0, "CheckPlayers")
- }
- public CheckPlayers()
- {
- if (ze_get_zombies_number() >= 1)
- {
- for(new id = 1; id <= g_iMaxClients; id++)
- {
- if (!is_user_alive(id))
- continue
- if (ze_is_user_zombie(id))
- {
- ze_colored_print(id, "!tYou have !g%i seconds !tto infect all humans!y!!!", get_pcvar_num(g_pCvarDelayTime))
- if (get_pcvar_num(g_pCvarDHUHEnable))
- {
- set_task(1.0, "ShowCounter", MESSAGE_TASK+id, _, _, "b")
- }
- set_task(get_pcvar_float(g_pCvarDelayTime), "GiveChance", CHANCE_TASK+id)
- g_iCounter[id] = get_pcvar_num(g_pCvarDelayTime)
- }
- }
- g_bMessageAppeared = true
- }
- }
- public ShowCounter(taskid)
- {
- new id = taskid - MESSAGE_TASK
- if (!g_iCounter[id] || !is_user_alive(id))
- {
- remove_task(taskid)
- return
- }
- set_dhudmessage(0, 255, 0, -1.0, 0.20, 0, 0.0, 0.6)
- show_dhudmessage(id, "** AUTO SLAY AFTER: %i **", g_iCounter[id])
- g_iCounter[id]--
- }
- public GiveChance(taskid)
- {
- new id = taskid - CHANCE_TASK
- if (!is_user_alive(id) || !ze_is_user_zombie(id))
- {
- remove_task(taskid)
- return
- }
- user_kill(id)
- client_cmd(id, "spk vox/bizwarn")
- ze_colored_print(id, "!tChance is over!y, !tyou failed to infect all humans!y!!!")
- }
- public ze_roundend(WinTeam)
- {
- for(new id = 1; id <= g_iMaxClients; id++)
- {
- remove_task(id+MESSAGE_TASK)
- remove_task(id+CHANCE_TASK)
- }
- g_bMessageAppeared = false
- }
- public ze_user_humanized(id)
- {
- g_iCounter[id] = 0
- g_bMessageAppeared = false
- remove_task(id+MESSAGE_TASK)
- remove_task(id+CHANCE_TASK)
- }
- public ze_game_started()
- {
- g_bMessageAppeared = false
- }
- public client_disconnected(id)
- {
- remove_task(id+MESSAGE_TASK)
- remove_task(id+CHANCE_TASK)
- }
- public ze_user_infected(iVictim, iInfector)
- {
- if (iInfector == 0)
- return
- if (ze_get_humans_number() == 0)
- return
- if (g_bMessageAppeared)
- {
- g_iCounter[iVictim] = g_iCounter[iInfector]
- ze_colored_print(iVictim, "!tYou have !g%i seconds !tto infect all humans!y!!!", g_iCounter[iVictim])
- set_task(1.0, "ShowCounter", MESSAGE_TASK+iVictim, _, _, "b")
- set_task(float(g_iCounter[iVictim]), "GiveChance", CHANCE_TASK+iVictim)
- }
- }
- You will need to install these 2 plugins.
- There is some hard coded values for some maps.
- I wasted much time on this plugin, it's working like 95% without issues. But still 5%, you can report bugs exactly so it became 100% working.
- All bugs will be resolved once it's reported correctly.
- Any map need hard code, just post it down if this plugin not work exactly in it.
- Maybe you face sometimes slay for zombies without reason, if you faced something like this try trace the issue and report me so i solve it.