Solved Dhud Escape Status

Unpaid Requests, Public Plugins
Post Reply
User avatar
Spir0x
Veteran Member
Veteran Member
Tunisia
Posts: 641
Joined: 7 years ago
Location: Tunisia
Contact:

Dhud Escape Status

#1

Post by Spir0x » 5 years ago

Yo all :D
Who can made a plugin shows Dhud message on round end when zombies win or humans win. and Remove "Esacpe Success" & "Escape Failed" from zombie_escape.txt. and add Dhud escape status like: ZOMBIES WIN or HUMANS WIN with dhud and random Colors if possible.
thanks :)

User avatar
Spir0x
Veteran Member
Veteran Member
Tunisia
Posts: 641
Joined: 7 years ago
Location: Tunisia
Contact:

#2

Post by Spir0x » 5 years ago

Up...

User avatar
Night Fury
Mod Developer
Mod Developer
Posts: 677
Joined: 7 years ago
Contact:

#3

Post by Night Fury » 5 years ago

Tomorrow.
Want your own mod edition? PM me.
Accepting private projects.
Discord: Fury#7469
Image

User avatar
Spir0x
Veteran Member
Veteran Member
Tunisia
Posts: 641
Joined: 7 years ago
Location: Tunisia
Contact:

#4

Post by Spir0x » 5 years ago

then tomorrow it's too late now.

User avatar
Night Fury
Mod Developer
Mod Developer
Posts: 677
Joined: 7 years ago
Contact:

#5

Post by Night Fury » 5 years ago

Spir0x wrote: 5 years ago then tomorrow it's too late now.
Had connection issues.

Replace client_print(.. Line with this this

Code: Select all

set_dhudmessage(175, 0, 0, -1.0, -0.19, 0, 0.8, 0.8)
	show_dhudmessage(0, "%L", LANG_PLAYER, "ZOMBIE_RELEASE", g_iCountDown)
Then replace edit your message as well as you need it.
Want your own mod edition? PM me.
Accepting private projects.
Discord: Fury#7469
Image

User avatar
Spir0x
Veteran Member
Veteran Member
Tunisia
Posts: 641
Joined: 7 years ago
Location: Tunisia
Contact:

#6

Post by Spir0x » 5 years ago

in ze_core ? then i said end round message not countdown or release.

Muhammet20
Veteran Member
Veteran Member
Posts: 408
Joined: 5 years ago
Contact:

#7

Post by Muhammet20 » 5 years ago

Spir0x wrote: 5 years ago Yo all :D
Who can made a plugin shows Dhud message on round end when zombies win or humans win. and Remove "Esacpe Success" & "Escape Failed" from zombie_escape.txt. and add Dhud escape status like: ZOMBIES WIN or HUMANS WIN with dhud and random Colors if possible.
thanks :)
try this :
_________

Code: Select all

#include <zombie_escape>

public plugin_init()
{
	register_plugin("[ZE] Win Hud Message", "1.0", "Muhammet Kaya")
}
public ze_roundend(winteam)
{
	for(new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
	{
		if(winteam == ZE_TEAM_HUMAN)
		{
			set_hudmessage(0, 42, 255, -1.0, -1.0, 0, 6.0, 5.0)
			show_hudmessage(id, "Humans Win")
		}
		else
		{
			set_hudmessage(255, 0, 0, -1.0, -1.0, 0, 6.0, 5.0)
			show_hudmessage(id, "Zombies Win")
		}
	}
}

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

#8

Post by Raheem » 5 years ago

In ze_core.sma:

Change any: To:
    1. set_dhudmessage(0, 255, 0, -1.0, 0.35, 0, 0.0, get_pcvar_float(g_pCvarRoundEndDelay))
    2. show_dhudmessage(0, "%L", LANG_PLAYER, "NO_WINNER")
Change any: To:
    1. set_dhudmessage(0, 255, 0, -1.0, 0.35, 0, 0.0, get_pcvar_float(g_pCvarRoundEndDelay))
    2. show_dhudmessage(0, "%L", LANG_PLAYER, "ESCAPE_FAIL")
Change any: To:
    1. set_dhudmessage(0, 255, 0, -1.0, 0.35, 0, 0.0, get_pcvar_float(g_pCvarRoundEndDelay))
    2. show_dhudmessage(0, "%L", LANG_PLAYER, "ESCAPE_SUCCESS")
Change any: To:
    1. set_dhudmessage(0, 255, 0, -1.0, 0.35, 0, 0.0, 5.0)
    2. show_dhudmessage(0, "%L", LANG_PLAYER, "START_GAME")
So final code should be like:

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

User avatar
Spir0x
Veteran Member
Veteran Member
Tunisia
Posts: 641
Joined: 7 years ago
Location: Tunisia
Contact:

#9

Post by Spir0x » 5 years ago

Okay thanks but what's this : g_pCvarSmartRandom = register_cvar("ze_smart_random", "1") i don't have it in my ze_core did you updated it ?

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

#10

Post by Raheem » 5 years ago

It's here: https://github.com/raheem-cs/Zombie-Esc ... /scripting
Will be in coming version 1.4
He who fails to plan is planning to fail

User avatar
Spir0x
Veteran Member
Veteran Member
Tunisia
Posts: 641
Joined: 7 years ago
Location: Tunisia
Contact:

#11

Post by Spir0x » 5 years ago

but what about my own ze_core ? how can i update it ?
it's not like original one you know it's edited to zombies respawn.

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

#12

Post by Raheem » 5 years ago

If you speak about latest core, forget it till the new version is out then i'll help you update it.
Right now you can follow explanation here: viewtopic.php?p=9320#p9320
He who fails to plan is planning to fail

User avatar
Spir0x
Veteran Member
Veteran Member
Tunisia
Posts: 641
Joined: 7 years ago
Location: Tunisia
Contact:

#13

Post by Spir0x » 5 years ago

So now how i will update my main ze_core with your new 1.4 one ?!

User avatar
Spir0x
Veteran Member
Veteran Member
Tunisia
Posts: 641
Joined: 7 years ago
Location: Tunisia
Contact:

#14

Post by Spir0x » 5 years ago

Bro help me there please !

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

#15

Post by Raheem » 5 years ago

Just follow this: viewtopic.php?p=9320#p9320, i told you what you need to change.

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

User avatar
Spir0x
Veteran Member
Veteran Member
Tunisia
Posts: 641
Joined: 7 years ago
Location: Tunisia
Contact:

#16

Post by Spir0x » 5 years ago

cuz my core is not like normal one it's changed with zombies respawn and hud win messages you know so this code is the one ?

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 5 guests