Approved Win Message

Gameplay Addons
User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 281
Joined: 1 Year Ago
Location: Des Moines/USA
Donation: 1x donated in total €10.00
Has thanked: 6 times
Been thanked: 21 times
Age: 34
Contact:

Re: Win Message

#11

Post by Mark » 1 Year Ago

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

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1962
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 21
Contact:

#12

Post by Raheem » 1 Year Ago

No, a while and i'll go pc and give you example.

[ Post made via Nexus 7 ]
You don't know? Learn and you will know.

User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 281
Joined: 1 Year Ago
Location: Des Moines/USA
Donation: 1x donated in total €10.00
Has thanked: 6 times
Been thanked: 21 times
Age: 34
Contact:

#13

Post by Mark » 1 Year Ago

Raheem wrote:
1 Year Ago
No, a while and i'll go pc and give you example.
no problem take your time.

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1962
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 21
Contact:

#14

Post by Raheem » 1 Year Ago

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

  1. #include <zombie_escape>
  2.  
  3. native ze_round_time_expired();
  4.  
  5. new Escape_Success[] = "models/win/escape_success.mdl"
  6. new Escape_Fail[] = "models/win/escape_fail.mdl"
  7.  
  8. public plugin_init()
  9. {
  10.     register_plugin("[ZE] Win Message", "1.1", "Raheem")
  11. }
  12.  
  13. public plugin_precache()
  14. {
  15.     precache_model(Escape_Success)
  16.     precache_model(Escape_Fail)
  17. }
  18.  
  19. public ze_roundend(WinTeam)
  20. {
  21.     for (new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
  22.     {
  23.         if (!is_user_alive(id))
  24.             continue
  25.        
  26.         if (ze_round_time_expired() && !ze_is_user_zombie(id))
  27.             continue;
  28.        
  29.         if(WinTeam == ZE_TEAM_HUMAN)
  30.         {
  31.             client_cmd(id, "cl_righthand 1")
  32.             engclient_cmd(id, "weapon_knife")
  33.             set_pev(id , pev_viewmodel2, Escape_Success)
  34.         }
  35.         else
  36.         {
  37.             client_cmd(id, "cl_righthand 1")
  38.             engclient_cmd(id, "weapon_knife")
  39.             set_pev(id , pev_viewmodel2, Escape_Fail)
  40.         }
  41.     }
  42. }
You don't know? Learn and you will know.

User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 281
Joined: 1 Year Ago
Location: Des Moines/USA
Donation: 1x donated in total €10.00
Has thanked: 6 times
Been thanked: 21 times
Age: 34
Contact:

#15

Post by Mark » 1 Year Ago

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

  1. #include <zombie_escape>
  2.  
  3. native ze_round_time_expired();
  4.  
  5. new Escape_Success[] = "models/win/escape_success.mdl"
  6. new Escape_Fail[] = "models/win/escape_fail.mdl"
  7.  
  8. public plugin_init()
  9. {
  10.     register_plugin("[ZE] Win Message", "1.1", "Raheem")
  11. }
  12.  
  13. public plugin_precache()
  14. {
  15.     precache_model(Escape_Success)
  16.     precache_model(Escape_Fail)
  17. }
  18.  
  19. public ze_roundend(WinTeam)
  20. {
  21.     for (new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
  22.     {
  23.         if (!is_user_alive(id))
  24.             continue
  25.        
  26.         if (ze_round_time_expired() && !ze_is_user_zombie(id))
  27.             continue;
  28.        
  29.         if(WinTeam == ZE_TEAM_HUMAN)
  30.         {
  31.             client_cmd(id, "cl_righthand 1")
  32.             engclient_cmd(id, "weapon_knife")
  33.             set_pev(id , pev_viewmodel2, Escape_Success)
  34.         }
  35.         else
  36.         {
  37.             client_cmd(id, "cl_righthand 1")
  38.             engclient_cmd(id, "weapon_knife")
  39.             set_pev(id , pev_viewmodel2, Escape_Fail)
  40.         }
  41.     }
  42. }
You trying to make sure im still awake? need , lol
  1. // Variables
  2. new g_iAliveHumansNum,
  3.     g_iAliveZombiesNum,
  4.     g_iRoundTime,
  5.     g_iCountDown,
  6.     g_iReleaseNotice,
  7.     g_iMaxClients,
  8.     g_iHumansScore,
  9.     g_iZombiesScore,
  10.     g_iRoundNum,
  11.     g_iHSpeedFactor[33],
  12.     g_iZSpeedSet[33],
  13.     bool:g_bGameStarted,
  14.     bool:g_bIsZombie[33],
  15.     bool:g_bIsZombieFrozen[33],
  16.     bool:g_bZombieFreezeTime,
  17.     bool:g_bIsRoundEnding,
  18.     bool:g_bHSpeedUsed[33],
  19.     bool:g_bZSpeedUsed[33],
  20.     bool:g_bEndCalled,
  21.     bool:g_bRoundTimeExpired
  22.     Float:g_flReferenceTime

to
  1. // Variables
  2. new g_iAliveHumansNum,
  3.     g_iAliveZombiesNum,
  4.     g_iRoundTime,
  5.     g_iCountDown,
  6.     g_iReleaseNotice,
  7.     g_iMaxClients,
  8.     g_iHumansScore,
  9.     g_iZombiesScore,
  10.     g_iRoundNum,
  11.     g_iHSpeedFactor[33],
  12.     g_iZSpeedSet[33],
  13.     bool:g_bGameStarted,
  14.     bool:g_bIsZombie[33],
  15.     bool:g_bIsZombieFrozen[33],
  16.     bool:g_bZombieFreezeTime,
  17.     bool:g_bIsRoundEnding,
  18.     bool:g_bHSpeedUsed[33],
  19.     bool:g_bZSpeedUsed[33],
  20.     bool:g_bEndCalled,
  21.     bool:g_bRoundTimeExpired,
  22.     Float:g_flReferenceTime

User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 281
Joined: 1 Year Ago
Location: Des Moines/USA
Donation: 1x donated in total €10.00
Has thanked: 6 times
Been thanked: 21 times
Age: 34
Contact:

#16

Post by Mark » 1 Year Ago

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

  1. #include <zombie_escape>
  2.  
  3. native ze_round_time_expired();
  4.  
  5. new Escape_Success[] = "models/win/escape_success.mdl"
  6. new Escape_Fail[] = "models/win/escape_fail.mdl"
  7.  
  8. public plugin_init()
  9. {
  10.     register_plugin("[ZE] Win Message", "1.1", "Raheem")
  11. }
  12.  
  13. public plugin_precache()
  14. {
  15.     precache_model(Escape_Success)
  16.     precache_model(Escape_Fail)
  17. }
  18.  
  19. public ze_roundend(WinTeam)
  20. {
  21.     for (new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
  22.     {
  23.         if (!is_user_alive(id))
  24.             continue
  25.        
  26.         if (ze_round_time_expired() && !ze_is_user_zombie(id))
  27.             continue;
  28.        
  29.         if(WinTeam == ZE_TEAM_HUMAN)
  30.         {
  31.             client_cmd(id, "cl_righthand 1")
  32.             engclient_cmd(id, "weapon_knife")
  33.             set_pev(id , pev_viewmodel2, Escape_Success)
  34.         }
  35.         else
  36.         {
  37.             client_cmd(id, "cl_righthand 1")
  38.             engclient_cmd(id, "weapon_knife")
  39.             set_pev(id , pev_viewmodel2, Escape_Fail)
  40.         }
  41.     }
  42. }
You trying to make sure im still awake? need , lol
  1. // Variables
  2. new g_iAliveHumansNum,
  3.     g_iAliveZombiesNum,
  4.     g_iRoundTime,
  5.     g_iCountDown,
  6.     g_iReleaseNotice,
  7.     g_iMaxClients,
  8.     g_iHumansScore,
  9.     g_iZombiesScore,
  10.     g_iRoundNum,
  11.     g_iHSpeedFactor[33],
  12.     g_iZSpeedSet[33],
  13.     bool:g_bGameStarted,
  14.     bool:g_bIsZombie[33],
  15.     bool:g_bIsZombieFrozen[33],
  16.     bool:g_bZombieFreezeTime,
  17.     bool:g_bIsRoundEnding,
  18.     bool:g_bHSpeedUsed[33],
  19.     bool:g_bZSpeedUsed[33],
  20.     bool:g_bEndCalled,
  21.     bool:g_bRoundTimeExpired
  22.     Float:g_flReferenceTime

to
  1. // Variables
  2. new g_iAliveHumansNum,
  3.     g_iAliveZombiesNum,
  4.     g_iRoundTime,
  5.     g_iCountDown,
  6.     g_iReleaseNotice,
  7.     g_iMaxClients,
  8.     g_iHumansScore,
  9.     g_iZombiesScore,
  10.     g_iRoundNum,
  11.     g_iHSpeedFactor[33],
  12.     g_iZSpeedSet[33],
  13.     bool:g_bGameStarted,
  14.     bool:g_bIsZombie[33],
  15.     bool:g_bIsZombieFrozen[33],
  16.     bool:g_bZombieFreezeTime,
  17.     bool:g_bIsRoundEnding,
  18.     bool:g_bHSpeedUsed[33],
  19.     bool:g_bZSpeedUsed[33],
  20.     bool:g_bEndCalled,
  21.     bool:g_bRoundTimeExpired,
  22.     Float:g_flReferenceTime
Ok now in chat it says escape success but the image is escape failed

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1962
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 21
Contact:

#17

Post by Raheem » 1 Year Ago

lol, sorry the comma i forget it xd.

Not get you, can you explain what happens now with code i did? i don't test it.
You don't know? Learn and you will know.

User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 281
Joined: 1 Year Ago
Location: Des Moines/USA
Donation: 1x donated in total €10.00
Has thanked: 6 times
Been thanked: 21 times
Age: 34
Contact:

#18

Post by Mark » 1 Year Ago

Raheem wrote:
1 Year Ago
lol, sorry the comma i forget it xd.

Not get you, can you explain what happens now with code i did? i don't test it.
Ill get back to you on this as it happen once but can't remember if i changed the map after updating it.

Ill test it in a bit

User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 281
Joined: 1 Year Ago
Location: Des Moines/USA
Donation: 1x donated in total €10.00
Has thanked: 6 times
Been thanked: 21 times
Age: 34
Contact:

#19

Post by Mark » 1 Year Ago

Raheem wrote:
1 Year Ago
lol, sorry the comma i forget it xd.

Not get you, can you explain what happens now with code i did? i don't test it.
This is what it does.
20180917191853_1.jpg

User avatar
Mark
Senior Member
Senior Member
United States of America
Posts: 281
Joined: 1 Year Ago
Location: Des Moines/USA
Donation: 1x donated in total €10.00
Has thanked: