Guest User

Untitled

a guest
Jun 22nd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.34 KB | None | 0 0
  1. /*---------------------------------------------------------
  2.    RoundStart
  3.    Code ran at the start of the round, mostly handles
  4.    if the round can start, giving the players weapons
  5.    and their spawn.
  6. ---------------------------------------------------------*/
  7.  
  8. function RoundStart()
  9.     if IsRound == false then -- Checks if it isn't a round so it won't start a round in middle of another.
  10.         if #player.GetAll() >= GetConVar("jw_minplayers"):GetInt() then -- Checks if there are enough players to start the rounds.
  11.             RoundStartTime
  12.             print("debug RoundStart")
  13.             RoundTime()
  14.             IsRound = true -- Makes sure to only run this function once.
  15.         end
  16.     end
  17. end
  18. hook.Add("Think", "SecondPrint2", RoundStart)
  19.  
  20. /*---------------------------------------------------------
  21.    RoundEnd
  22.    Handles the conditions of a round end and calls
  23.    the end screen.
  24. ---------------------------------------------------------*/
  25.  
  26. function RoundEnd()
  27.     if #player.GetAll() < GetConVar("jw_minplayers"):GetInt() then return end -- Checks if there isn't enough players so it won't keep doing rounds when there aren't players.
  28.     if IsRound == false then return end -- Makes sure this does not conflicts with the RoundStart
  29.     if IsRound == true then -- Runs code after the round has started.
  30.         if team.NumPlayers(1) == 0 and team.NumPlayers(2) == 0 then -- Check for stalemate
  31.             print("Stalemate!")
  32.             IsRound = false
  33.             timer.Simple(2, RoundStart)
  34.         elseif team.NumPlayers(1) >= 1 and team.NumPlayers(2) == 0 then -- Check for Guards winning.
  35.             print("The guards stopped the rebellion!")
  36.             IsRound = false
  37.             timer.Simple(2, RoundStart)
  38.         elseif team.NumPlayers(1) == 0 and team.NumPlayers(2) >= 1 then -- Check for Inmates winning.
  39.             print("The Inmates have outrun the guards!")
  40.             IsRound = false
  41.             timer.Simple(2, RoundStart)
  42.         elseif RoundEndTime >= CurTime() then  -- Check for the round end because of time(makes it a stalemate.)
  43.             print("Stalemate!")
  44.             IsRound = false
  45.             timer.Simple(2, RoundStart)
  46.         end
  47.     end
  48. end
  49. hook.Add("Think", "SecondPrint", RoundEnd)
  50.  
  51. /*---------------------------------------------------------
  52.    RoundTime
  53.    Creates the timed part of the rounds.
  54. ---------------------------------------------------------*/
  55. function RoundTime()
  56.     RoundStartTime = CurTime()
  57.     RoundEndTime = RoundStartTime + GetConVar("jw_roundtime"):GetInt()
  58. end
Add Comment
Please, Sign In to add comment