Solved Dhud Escape Status

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

#11

Post by Spir0x » 5 years ago

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

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

#12

Post by Raheem » 5 years ago

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

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

#13

Post by Spir0x » 5 years ago

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

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

#14

Post by Spir0x » 5 years ago

Bro help me there please !

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

#15

Post by Raheem » 5 years ago

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

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

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

#16

Post by Spir0x » 5 years ago

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

Post Reply

Create an account or sign in to join the discussion

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

Create an account

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

Register

Sign in

Who is online

Users browsing this forum: No registered users and 4 guests