HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <zombie_escape>
  2.  
  3. // Fowards
  4. enum _:TOTAL_FORWARDS
  5. {
  6. FORWARD_NONE = 0,
  7. FORWARD_ROUNDEND,
  8. FORWARD_HUMANIZED,
  9. FORWARD_INFECTED,
  10. FORWARD_ZOMBIE_APPEAR,
  11. FORWARD_ZOMBIE_RELEASE,
  12. FORWARD_GAME_STARTED
  13. }
  14.  
  15. new g_iForwards[TOTAL_FORWARDS], g_iFwReturn, g_iTeam
  16.  
  17. // Tasks IDs
  18. enum
  19. {
  20. TASK_COUNTDOWN = 1100,
  21. TASK_COUNTDOWN2,
  22. TASK_SCORE_MESSAGE,
  23. FREEZE_ZOMBIES,
  24. ROUND_TIME_LEFT
  25. }
  26.  
  27. // Variables
  28. new g_iCTNum, g_iTNum, g_iRoundTime, g_iCountDown, g_iReleaseNotice, g_iMaxClients, g_iHumansScore, g_iZombiesScore,
  29. bool:g_bGameStarted, bool:g_bIsZombie[33], bool:g_bIsZombieFrozen[33], bool:g_bZombieFrozenTime,
  30. Float:g_fReferenceTime
  31.  
  32. // Cvars
  33. new Cvar_Human_fSpeedFactor, Cvar_Human_fGravity, Cvar_Human_iHealth, Cvar_Zombie_fSpeed, Cvar_Zombie_fGravity,
  34. Cvar_Zombie_iReleaseTime, Cvar_iFreezeTime, Cvar_fRoundTime, Cvar_iReqPlayers, Cvar_Zombie_iHealth, Cvar_FirstZombies_iHealth,
  35. Cvar_Zombie_fKnockback, Cvar_ScoreMessage_iType, Cvar_ScoreMessage_iRed, Cvar_ScoreMessage_iGreen, Cvar_ScoreMessage_iBlue
  36.  
  37. public plugin_natives()
  38. {
  39. register_native("ze_is_user_zombie", "native_ze_is_user_zombie", 1)
  40. register_native("ze_set_user_zombie", "native_ze_set_user_zombie", 1)
  41. register_native("ze_set_user_human", "native_ze_set_user_human", 1)
  42. register_native("ze_get_release_time", "native_ze_get_release_time", 1)
  43. }
  44.  
  45. public plugin_init()
  46. {
  47. register_plugin("[ZE] Core/Engine", ZE_VERSION, AUTHORS)
  48.  
  49. // Hook Chains
  50. RegisterHookChain(RG_CBasePlayer_TraceAttack, "Fw_TraceAttack_Pre", 0)
  51. RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
  52. RegisterHookChain(RG_CBasePlayer_Spawn, "Fw_PlayerSpawn_Post", 1)
  53. RegisterHookChain(RG_CSGameRules_CheckWinConditions, "Fw_CheckMapConditions_Post", 1)
  54. RegisterHookChain(RG_CBasePlayer_Killed, "Fw_PlayerKilled_Post", 1)
  55.  
  56. // Events
  57. register_event("HLTV", "New_Round", "a", "1=0", "2=0")
  58. register_event("TextMsg", "Map_Restart", "a", "2=#Game_Commencing", "2=#Game_will_restart_in", "2=#Round_Draw")
  59. register_logevent("Round_Start", 2, "1=Round_Start")
  60. register_logevent("Round_End", 2, "1=Round_End")
  61.  
  62. // Hams
  63. RegisterHam(Ham_Item_PreFrame, "player", "Fw_RestMaxSpeed_Post", 1)
  64.  
  65. // Create Forwards (All Return Values Ignored)
  66. g_iForwards[FORWARD_ROUNDEND] = CreateMultiForward("ze_roundend", ET_IGNORE, FP_CELL)
  67. g_iForwards[FORWARD_HUMANIZED] = CreateMultiForward("ze_user_humanized", ET_IGNORE, FP_CELL)
  68. g_iForwards[FORWARD_INFECTED] = CreateMultiForward("ze_user_infected", ET_IGNORE, FP_CELL, FP_CELL)
  69. g_iForwards[FORWARD_ZOMBIE_APPEAR] = CreateMultiForward("ze_zombie_appear", ET_IGNORE)
  70. g_iForwards[FORWARD_ZOMBIE_RELEASE] = CreateMultiForward("ze_zombie_release", ET_IGNORE)
  71. g_iForwards[FORWARD_GAME_STARTED] = CreateMultiForward("ze_game_started", ET_IGNORE)
  72.  
  73. // Hud Messages
  74. g_iReleaseNotice = CreateHudSyncObj()
  75.  
  76. // Sequential files (.txt)
  77. register_dictionary("zombie_escape.txt")
  78.  
  79. // Humans Cvars
  80. Cvar_Human_fSpeedFactor = register_cvar("ze_human_speed_factor", "20.0")
  81. Cvar_Human_fGravity = register_cvar("ze_human_gravity", "1.0")
  82. Cvar_Human_iHealth = register_cvar("ze_human_health", "1000")
  83.  
  84. // Zombie Cvars
  85. Cvar_Zombie_fSpeed = register_cvar("ze_zombie_speed", "350.0")
  86. Cvar_Zombie_fGravity = register_cvar("ze_zombie_gravity", "0.8")
  87. Cvar_Zombie_iHealth = register_cvar("ze_zombie_health", "10000")
  88. Cvar_FirstZombies_iHealth = register_cvar("ze_first_zombies_health", "20000")
  89. Cvar_Zombie_fKnockback = register_cvar("ze_zombie_knockback", "300.0")
  90.  
  91. // General Cvars
  92. Cvar_Zombie_iReleaseTime = register_cvar("ze_release_time", "15")
  93. Cvar_iFreezeTime = register_cvar("ze_freeze_time", "20")
  94. Cvar_fRoundTime = register_cvar("ze_round_time", "9.0")
  95. Cvar_iReqPlayers = register_cvar("ze_required_players", "2")
  96. Cvar_ScoreMessage_iType = register_cvar("ze_score_message_type", "1")
  97. Cvar_ScoreMessage_iRed = register_cvar("ze_score_message_red", "200")
  98. Cvar_ScoreMessage_iGreen = register_cvar("ze_score_message_green", "100")
  99. Cvar_ScoreMessage_iBlue = register_cvar("ze_score_message_blue", "0")
  100.  
  101. // Default Values
  102. g_bGameStarted = false
  103.  
  104. // Static Values
  105. g_iMaxClients = get_member_game(m_nMaxPlayers)
  106.  
  107. // Check Round Time to Terminate it
  108. set_task(1.0, "Check_RoundTimeleft", ROUND_TIME_LEFT, _, _, "b")
  109. }
  110.  
  111. public plugin_cfg()
  112. {
  113. // Get our configiration file and Execute it
  114. new szCfgDir[64]
  115. get_localinfo("amxx_configsdir", szCfgDir, charsmax(szCfgDir))
  116. server_cmd("exec %s/zombie_escape.cfg", szCfgDir)
  117.  
  118. // Set Game Name
  119. new szGameName[64]
  120. formatex(szGameName, sizeof(szGameName), "Zombie Escape v%s", ZE_VERSION)
  121. set_member_game(m_GameDesc, szGameName)
  122. }
  123.  
  124. public Fw_CheckMapConditions_Post()
  125. {
  126. // Block Game Commencing
  127. set_member_game(m_bGameStarted, true)
  128.  
  129. // Set Freeze Time
  130. set_member_game(m_iIntroRoundTime, get_pcvar_num(Cvar_iFreezeTime))
  131.  
  132. // Set Round Time
  133. set_member_game(m_iRoundTime, floatround(get_pcvar_float(Cvar_fRoundTime) * 60.0))
  134. }
  135.  
  136. public Fw_PlayerKilled_Post(id)
  137. {
  138. new iCTNum; iCTNum = GetAlivePlayersNum(CsTeams:TEAM_CT)
  139. new iTNum; iTNum = GetAlivePlayersNum(CsTeams:TEAM_TERRORIST)
  140.  
  141. if (iCTNum == 0 && iTNum == 0)
  142. {
  143. // No Winner, All Players in one team killed Or Both teams Killed
  144. client_print(0, print_center, "%L", LANG_PLAYER, "NO_WINNER")
  145. }
  146. }
  147.  
  148. public Fw_RestMaxSpeed_Post(id)
  149. {
  150. if (!g_bIsZombie[id])
  151. {
  152. static Float:fMaxSpeed
  153. pev(id, pev_maxspeed, fMaxSpeed)
  154.  
  155. if(fMaxSpeed != 1.0 && is_user_alive(id))
  156. {
  157. // Set Human Speed Factor
  158. set_pev(id, pev_maxspeed, fMaxSpeed + get_pcvar_float(Cvar_Human_fSpeedFactor))
  159. }
  160. return HAM_IGNORED
  161. }
  162. return HAM_SUPERCEDE
  163. }
  164.  
  165. public Fw_PlayerSpawn_Post(id)
  166. {
  167. if (!g_bGameStarted)
  168. {
  169. // Force All player to be Humans if Game not started yet
  170. rg_set_user_team(id, TEAM_CT, MODEL_UNASSIGNED)
  171. }
  172. else
  173. {
  174. if (get_member_game(m_bFreezePeriod))
  175. {
  176. // Respawn Him As human if we are in freeze time (Zombie Not Chosen yet)
  177. Set_User_Human(id)
  178. g_bIsZombieFrozen[id] = false
  179. }
  180. else
  181. {
  182. if (g_bZombieFrozenTime)
  183. {
  184. // Zombie Chosen and zombies Frozen, Spawn him as zombie and Freeze Him
  185. Set_User_Zombie(id)
  186. g_bIsZombieFrozen[id] = true
  187. set_pev(id, pev_maxspeed, 1.0)
  188. }
  189. else
  190. {
  191. // Respawn him as normal zombie
  192. Set_User_Zombie(id)
  193. g_bIsZombieFrozen[id] = false
  194. }
  195. }
  196. }
  197. }
  198.  
  199. public New_Round()
  200. {
  201. // Remove All tasks in the New Round
  202. remove_task(TASK_COUNTDOWN)
  203. remove_task(TASK_COUNTDOWN2)
  204. remove_task(TASK_SCORE_MESSAGE)
  205. remove_task(FREEZE_ZOMBIES)
  206.  
  207. // Score Message Task
  208. set_task(10.0, "Score_Message", TASK_SCORE_MESSAGE, _, _, "b")
  209.  
  210. // 2 is Hardcoded Value, It's Fix for the countdown to work correctly
  211. g_iCountDown = get_member_game(m_iIntroRoundTime) - 2
  212.  
  213. if (!g_bGameStarted)
  214. {
  215. // No Enough Players
  216. ze_colored_print(0, "%L", LANG_PLAYER, "NO_ENOUGH_PLAYERS", get_pcvar_num(Cvar_iReqPlayers))
  217. return // Block the execution of the blew code
  218. }
  219.  
  220. if (g_bGameStarted)
  221. {
  222. // Game Already started, Countdown now started
  223. set_task(1.0, "Countdown_Start", TASK_COUNTDOWN, _, _, "b")
  224. ze_colored_print(0, "%L", LANG_PLAYER, "READY_TO_RUN")
  225. ExecuteForward(g_iForwards[FORWARD_GAME_STARTED], g_iFwReturn)
  226. }
  227. }
  228.  
  229. // Score Message Task
  230. public Score_Message(TaskID)
  231. {
  232. if (get_pcvar_num(Cvar_ScoreMessage_iType) == 0)
  233. return
  234.  
  235. if (get_pcvar_num(Cvar_ScoreMessage_iType) == 1)
  236. {
  237. set_dhudmessage(get_pcvar_num(Cvar_ScoreMessage_iRed), get_pcvar_num(Cvar_ScoreMessage_iGreen), get_pcvar_num(Cvar_ScoreMessage_iBlue), -1.0, 0.01, 0, 0.0, 9.0)
  238. show_dhudmessage(0, "%L", LANG_PLAYER, "SCORE_MESSAGE", g_iZombiesScore, g_iHumansScore)
  239. }
  240. else if (get_pcvar_num(Cvar_ScoreMessage_iType) == 2)
  241. {
  242. set_hudmessage(get_pcvar_num(Cvar_ScoreMessage_iRed), get_pcvar_num(Cvar_ScoreMessage_iGreen), get_pcvar_num(Cvar_ScoreMessage_iBlue), -1.0, 0.01, 0, 0.0, 9.0)
  243. show_hudmessage(0, "%L", LANG_PLAYER, "SCORE_MESSAGE", g_iZombiesScore, g_iHumansScore)
  244. }
  245. }
  246.  
  247. public Countdown_Start(TaskID)
  248. {
  249. // Check if the players Disconnected and there is only one player then remove all messages, and stop tasks
  250. if (!g_bGameStarted)
  251. return
  252.  
  253. if (!g_iCountDown) // When it reach 0 the !0 will be 1 So it's True
  254. {
  255. Choose_Zombies()
  256. remove_task(TaskID) // Remove the task
  257. return // Block the execution of the blew code
  258. }
  259.  
  260. set_hudmessage(random(256), random(256), random(256), -1.0, 0.21, 0, 2.0, 2.0)
  261. show_hudmessage(0, "%L", LANG_PLAYER, "RUN_NOTICE", g_iCountDown)
  262.  
  263. g_iCountDown -- // Means: g_iCountDown = g_iCountDown -1
  264. }
  265.  
  266. public Choose_Zombies()
  267. {
  268. new iZombies, id, AliveCount; AliveCount = GetAllAlivePlayersNum()
  269. new iReqZombies; iReqZombies = RequiredZombies()
  270.  
  271. while (iZombies < iReqZombies)
  272. {
  273. id = GetRandomAlive(random_num(1, AliveCount))
  274.  
  275. if (!is_user_alive(id) || g_bIsZombie[id])
  276. continue
  277.  
  278. Set_User_Zombie(id)
  279. set_user_health(id, get_pcvar_num(Cvar_FirstZombies_iHealth))
  280. g_bIsZombieFrozen[id] = true
  281. g_bZombieFrozenTime = true
  282. set_pev(id, pev_maxspeed, 1.0)
  283. set_task(0.1, "Freeze_Zombies", FREEZE_ZOMBIES, _, _, "b") // Better than PreThink
  284. ExecuteForward(g_iForwards[FORWARD_ZOMBIE_APPEAR], g_iFwReturn)
  285. iZombies ++
  286. }
  287.  
  288. // 2 is Hardcoded Value, It's Fix for the countdown to work correctly
  289. g_iCountDown = get_pcvar_num(Cvar_Zombie_iReleaseTime) - 2
  290.  
  291. set_task(1.0, "ReleaseZombie_CountDown", TASK_COUNTDOWN2, _, _, "b")
  292. }
  293.  
  294. public ReleaseZombie_CountDown(TaskID)
  295. {
  296. if(!g_iCountDown)
  297. {
  298. ReleaseZombie()
  299. remove_task(TaskID)
  300.  
  301. return
  302. }
  303.  
  304. // Release Hud Message
  305. set_hudmessage(255, 255, 0, -1.0, 0.21, 1, 2.0, 2.0)
  306. ShowSyncHudMsg(0, g_iReleaseNotice, "%L", LANG_PLAYER, "ZOMBIE_RELEASE", g_iCountDown)
  307.  
  308. g_iCountDown --
  309. }
  310.  
  311. public ReleaseZombie()
  312. {
  313. ExecuteForward(g_iForwards[FORWARD_ZOMBIE_RELEASE], g_iFwReturn)
  314.  
  315. for(new i = 1; i <= g_iMaxClients; i++)
  316. {
  317. if(is_user_alive(i) && g_bIsZombie[i])
  318. {
  319. g_bIsZombieFrozen[i] = false
  320. g_bZombieFrozenTime = false
  321. }
  322. }
  323. }
  324.  
  325. public Freeze_Zombies(TaskID)
  326. {
  327. for(new i = 1; i <= g_iMaxClients; i++)
  328. {
  329. if(!is_user_alive(i))
  330. continue
  331.  
  332. if (g_bIsZombieFrozen[i] && g_bIsZombie[i])
  333. {
  334. // Zombie & Frozen then Freeze him
  335. set_pev(i, pev_maxspeed, 1.0)
  336. }
  337.  
  338. if (!g_bIsZombieFrozen[i] && g_bIsZombie[i])
  339. {
  340. // Zombie but Not Frozen the set his speed form .cfg
  341. set_pev(i, pev_maxspeed, get_pcvar_float(Cvar_Zombie_fSpeed))
  342. }
  343. }
  344. }
  345.  
  346. public Fw_TraceAttack_Pre(iVictim, iAttacker, Float:damage, Float:direction[3], tracehandle, damagebits)
  347. {
  348. if (iVictim == iAttacker || !is_user_connected(iVictim) || !is_user_connected(iAttacker))
  349. return HC_CONTINUE
  350.  
  351. // Attacker and Victim is in same teams? Skip here only
  352. if (get_member(iAttacker, m_iTeam) == get_member(iVictim, m_iTeam))
  353. return HC_CONTINUE
  354.  
  355. // In freeze time? Skip all other plugins
  356. if (g_bIsZombieFrozen[iVictim] || g_bIsZombieFrozen[iAttacker])
  357. return HC_SUPERCEDE
  358.  
  359. g_iCTNum = GetAlivePlayersNum(CsTeams:TEAM_CT)
  360.  
  361. if (get_member(iAttacker, m_iTeam) == TEAM_TERRORIST)
  362. {
  363. Set_User_Zombie(iVictim)
  364. ExecuteForward(g_iForwards[FORWARD_INFECTED], g_iFwReturn, iVictim, iAttacker)
  365.  
  366. if (g_iCTNum == 1) // Check if this is Last Human, Because of Delay i can't check if it's 0 instead of 1
  367. {
  368. // Zombie Win, Leave text blank so we use ours from ML
  369. rg_round_end(3.0, WINSTATUS_TERRORISTS, ROUND_TERRORISTS_WIN, "")
  370.  
  371. // Show Our Message
  372. client_print(0, print_center, "%L", LANG_PLAYER, "ESCAPE_FAIL")
  373.  
  374. // This needed so forward work also to add +1 for Zombies
  375. g_iTeam = 1 // ZE_TEAM_ZOMBIE
  376. ExecuteForward(g_iForwards[FORWARD_ROUNDEND], g_iFwReturn, g_iTeam)
  377. }
  378. }
  379. return HC_CONTINUE
  380. }
  381.  
  382. public Fw_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:fDamage, bitsDamageType)
  383. {
  384. // Not Vaild Victim or Attacker so skip the event (Important to block out bounds errors)
  385. if (!is_user_connected(iVictim) || !is_user_connected(iAttacker))
  386. return HC_CONTINUE
  387.  
  388. // Set Knockback here, So if we blocked damage in TraceAttack event player won't get knockback (Fix For Madness)
  389. if (g_bIsZombie[iVictim] && !g_bIsZombie[iAttacker])
  390. {
  391. // Remove Shock Pain
  392. set_member(iVictim, m_flVelocityModifier, 1.0)
  393.  
  394. // Set Knockback
  395. static Float:fOrigin[3]
  396. pev(iAttacker, pev_origin, fOrigin)
  397. Set_Knockback(iVictim, fOrigin, get_pcvar_float(Cvar_Zombie_fKnockback), 2)
  398. }
  399. return HC_CONTINUE
  400. }
  401.  
  402. public Round_End()
  403. {
  404. g_iTNum = GetAlivePlayersNum(CsTeams:TEAM_TERRORIST)
  405.  
  406. if (g_iTNum == 0)
  407. {
  408. g_iTeam = 2 // ZE_TEAM_HUMAN
  409. ExecuteForward(g_iForwards[FORWARD_ROUNDEND], g_iFwReturn, g_iTeam)
  410. client_print(0, print_center, "%L", LANG_PLAYER, "ESCAPE_SUCCESS")
  411. g_iHumansScore ++
  412. return // To block Execute the code blew
  413. }
  414.  
  415. g_iTeam = 1 // ZE_TEAM_ZOMBIE
  416. g_iZombiesScore ++
  417. ExecuteForward(g_iForwards[FORWARD_ROUNDEND], g_iFwReturn, g_iTeam)
  418. client_print(0, print_center, "%L", LANG_PLAYER, "ESCAPE_FAIL")
  419. }
  420.  
  421. public Round_Start()
  422. {
  423. g_fReferenceTime = get_gametime()
  424. g_iRoundTime = get_member_game(m_iRoundTime)
  425. }
  426.  
  427. public Check_RoundTimeleft()
  428. {
  429. new Float:fRoundTimeLeft; fRoundTimeLeft = (g_fReferenceTime + float(g_iRoundTime)) - get_gametime()
  430.  
  431. if (floatround(fRoundTimeLeft) == 0)
  432. {
  433. // If Time is Out the Terminate the Round
  434. rg_round_end(3.0, WINSTATUS_TERRORISTS, ROUND_TERRORISTS_WIN, "")
  435.  
  436. // Show our Message
  437. client_print(0, print_center, "%L", LANG_PLAYER, "ESCAPE_FAIL")
  438. }
  439. }
  440.  
  441. public client_disconnect(id)
  442. {
  443. // Delay Then Check Players to Terminate The round (Delay needed)
  444. set_task(0.1, "Check_AlivePlayers", _, _, _, "a", 1)
  445. }
  446.  
  447. // This check done when player disconnect
  448. public Check_AlivePlayers()
  449. {
  450. g_iTNum = GetAlivePlayersNum(CsTeams:TEAM_TERRORIST)
  451. g_iCTNum = GetAlivePlayersNum(CsTeams:TEAM_CT)
  452.  
  453. // Game Started? (There is at least 2 players Alive?)
  454. if (g_bGameStarted)
  455. {
  456. // We are in freeze time?
  457. if (get_member_game(m_bFreezePeriod))
  458. {
  459. // Humans alive number = 1 and no zombies?
  460. if (g_iCTNum == 1 && g_iTNum == 0)
  461. {
  462. // Game started false again
  463. g_bGameStarted = false
  464. }
  465. }
  466. else // Not freeze time?
  467. {
  468. // Humans number =1 and no zombies?
  469. if (g_iCTNum == 1 && g_iTNum == 0)
  470. {
  471. // Game started is false and humans wins (Escape Success)
  472. g_bGameStarted = false
  473. rg_round_end(3.0, WINSTATUS_CTS, ROUND_CTS_WIN, "")
  474. client_print(0, print_center, "%L", LANG_PLAYER, "ESCAPE_SUCCESS")
  475. }
  476.  
  477. // Zombies Number = 1 and no Humans?
  478. if (g_iTNum == 1 && g_iCTNum == 0)
  479. {
  480. // Game started false and zombies win (Escape Fail)
  481. g_bGameStarted = false
  482. rg_round_end(3.0, WINSTATUS_TERRORISTS, ROUND_TERRORISTS_WIN, "")
  483. client_print(0, print_center, "%L", LANG_PLAYER, "ESCAPE_FAIL")
  484. }
  485.  
  486. // Humans number more than 1 and no zombies?
  487. if (g_iCTNum > 1 && g_iTNum == 0)
  488. {
  489. // Then Escape success as there is no Zombies
  490. rg_round_end(3.0, WINSTATUS_CTS, ROUND_CTS_WIN, "")
  491. client_print(0, print_center, "%L", LANG_PLAYER, "ESCAPE_SUCCESS")
  492. }
  493.  
  494. // Zombies number more than 1 and no humans?
  495. if (g_iTNum > 1 && g_iCTNum == 0)
  496. {
  497. // Then Escape Fail as there is no humans
  498. rg_round_end(3.0, WINSTATUS_TERRORISTS, ROUND_TERRORISTS_WIN, "")
  499. client_print(0, print_center, "%L", LANG_PLAYER, "ESCAPE_FAIL")
  500. }
  501. }
  502. }
  503. }
  504.  
  505. public client_putinserver(id)
  506. {
  507. // Add Delay and Check Conditions To start the Game (Delay needed)
  508. set_task(1.0, "Check_AllPlayersNumber", _, _, _, "b")
  509. }
  510.  
  511. public Check_AllPlayersNumber(TaskID)
  512. {
  513. if (g_bGameStarted)
  514. {
  515. // If game started remove the task and block the blew Checks
  516. remove_task(TaskID)
  517. return
  518. }
  519.  
  520. if (GetAllAlivePlayersNum() < get_pcvar_num(Cvar_iReqPlayers))
  521. return
  522.  
  523. if (GetAllAlivePlayersNum() == get_pcvar_num(Cvar_iReqPlayers))
  524. {
  525. // Players In server == The Required so game started is true
  526. g_bGameStarted = true
  527.  
  528. // Restart the game
  529. server_cmd("sv_restart 2")
  530.  
  531. // Print Fake game Commencing Message
  532. client_print(0, print_center, "%L", LANG_PLAYER, "START_GAME")
  533.  
  534. // Remove the task
  535. remove_task(TaskID)
  536. }
  537.  
  538. // Simple Fix for bots, If many of them connect fast then the == 2 won't be detected so this to detect it
  539. if (GetAllAlivePlayersNum() > get_pcvar_num(Cvar_iReqPlayers) && !g_bGameStarted)
  540. {
  541. g_bGameStarted = true
  542.  
  543. // Restart the game
  544. server_cmd("sv_restart 2")
  545.  
  546. // Print Fake "Game Commencing" Message
  547. client_print(0, print_center, "%L", LANG_PLAYER, "START_GAME")
  548.  
  549. // Remove the task
  550. remove_task(TaskID)
  551. }
  552. }
  553.  
  554. public Set_User_Human(id)
  555. {
  556. if (!is_user_alive(id))
  557. return
  558.  
  559. g_bIsZombie[id] = false
  560. set_user_gravity(id, get_pcvar_float(Cvar_Human_fGravity))
  561. set_user_health(id, get_pcvar_num(Cvar_Human_iHealth))
  562. ExecuteForward(g_iForwards[FORWARD_HUMANIZED], g_iFwReturn, id)
  563.  
  564. if (get_member(id, m_iTeam) != TEAM_CT)
  565. rg_set_user_team(id, TEAM_CT, MODEL_UNASSIGNED)
  566. }
  567.  
  568. public Set_User_Zombie(id)
  569. {
  570. if (!is_user_alive(id))
  571. return
  572.  
  573. g_bIsZombie[id] = true
  574. set_user_health(id, get_pcvar_num(Cvar_Zombie_iHealth))
  575. set_user_gravity(id, get_pcvar_float(Cvar_Zombie_fGravity))
  576. rg_remove_all_items(id)
  577. rg_give_item(id, "weapon_knife")
  578. ExecuteForward(g_iForwards[FORWARD_INFECTED], g_iFwReturn, id, 0)
  579.  
  580. if (get_member(id, m_iTeam) != TEAM_TERRORIST)
  581. rg_set_user_team(id, TEAM_TERRORIST, MODEL_UNASSIGNED)
  582. }
  583.  
  584. public Map_Restart()
  585. {
  586. // Add Delay To help Rest Scores if player kill himself, and there no one else him so round draw (Delay needed)
  587. set_task(0.1, "Rest_Score_Message", _, _, _, "a", 1)
  588. }
  589.  
  590. public Rest_Score_Message()
  591. {
  592. g_iHumansScore = 0
  593. g_iZombiesScore = 0
  594. }
  595.  
  596. // Natives
  597. public native_ze_is_user_zombie(id)
  598. {
  599. return g_bIsZombie[id]
  600. }
  601.  
  602. public native_ze_set_user_zombie(id)
  603. {
  604. Set_User_Zombie(id)
  605. }
  606.  
  607. public native_ze_set_user_human(id)
  608. {
  609. Set_User_Human(id)
  610. }
  611.  
  612. public native_ze_get_release_time()
  613. {
  614. return get_pcvar_num(Cvar_Zombie_iReleaseTime)
  615. }