Guest User

Untitled

a guest
Apr 24th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. function GM:CanStartRound(iNum)
  2. for _, v in pairs(team.GetPlayers(TEAM_GAMEMASTER)) do
  3. v:SetTeam(TEAM_RUNNER)
  4. end
  5. if team.NumPlayers(TEAM_RUNNER) > 1 then
  6. local players = team.GetPlayers(TEAM_RUNNER)
  7. local maxvar = 0
  8. local maxvarplayers = {}
  9. for i,ply in pairs(players) do
  10. if (ply:GetNWInt("NoSRRounds") > maxvar) then
  11. maxvar = ply:GetNWInt("NoSRRounds")
  12. end
  13. end
  14. for i,ply in pairs(players) do
  15. if (ply:GetNWInt("NoSRRounds") == maxvar) then
  16. table.insert(maxvarplayers, ply)
  17. end
  18. end
  19. local the_chosen_one = table.Random(maxvarplayers) //Select random gamemaster
  20. the_chosen_one:SetTeam(TEAM_GAMEMASTER)
  21. the_chosen_one:SetNWInt("NoSRRounds", 0)
  22. return true
  23. else
  24. return false
  25. end
  26. end
  27.  
  28. hook.Add( "OnRoundStart", "GM_OnRoundStart", GM_OnRoundStart )
  29.  
  30. function GM_OnRoundStart()
  31. pls = player.GetAll
  32. for i, ply in pairs(pls) do
  33. if (ply:Team() == TEAM_RUNNER) then
  34. ply:SetNWInt("NoSRRounds", ply:GetNWInt("NoSRRounds") + 1)
  35. elseif (ply:Team() == TEAM_GAMEMASTER) then
  36. ply:SetNWInt("NoSRRounds", 0)
  37. end
  38. end
  39. end
Add Comment
Please, Sign In to add comment