Advertisement
Guest User

Untitled

a guest
Oct 29th, 2016
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.43 KB | None | 0 0
  1. local CATEGORY_NAME = "Owen Custom"
  2. print(TEAM_HUNTERS)
  3. --------------------Rock The Vote--------------------
  4.  
  5. RTV = RTV or {}
  6.  
  7. RTV.ChatCommands = {
  8.    
  9.     "!rtv",
  10.     "/rtv",
  11.     "rtv"
  12.  
  13. }
  14.  
  15. RTV.PlayerCount = 3
  16.  
  17. RTV.TotalVotes = 0
  18.  
  19. RTV.Wait = 90 -- The wait time in seconds. This is how long a player has to wait before voting when the map changes.
  20.               -- If the "extend" option is picked, you have to wait double this before voting again.
  21.  
  22.  
  23. RTV._ActualWait = CurTime() + RTV.Wait
  24.  
  25.  
  26.  
  27. function RTV.ShouldChange()
  28.     return RTV.TotalVotes >= math.Round(#player.GetAll()*0.66)
  29. end
  30.  
  31. function RTV.RemoveVote()
  32.     RTV.TotalVotes = math.Clamp( RTV.TotalVotes - 1, 0, math.huge )
  33. end
  34.  
  35. function RTV.Start()
  36.  
  37. MapVote.Start(voteLength, allowCurrentMap, mapLimit, mapPrefix)
  38.  
  39. end
  40.  
  41.  
  42. function RTV.AddVote( ply )
  43.  
  44.     if RTV.CanVote( ply ) then
  45.         RTV.TotalVotes = RTV.TotalVotes + 1
  46.         ply.RTVoted = true
  47.         MsgN( ply:Nick().." has voted to Rock the Vote." )
  48.         PrintMessage( HUD_PRINTTALK, ply:Nick().." has voted to Rock the Vote. ("..RTV.TotalVotes.."/"..math.Round(#player.GetAll()*0.66)..")" )
  49.  
  50.         if RTV.ShouldChange() then
  51.             RTV.Start()
  52.         end
  53.     end
  54.  
  55. end
  56.  
  57. hook.Add( "PlayerDisconnected", "Remove RTV", function( ply )
  58.  
  59.     if ply.RTVoted then
  60.         RTV.RemoveVote()
  61.     end
  62.  
  63.     timer.Simple( 0.1, function()
  64.  
  65.         if RTV.ShouldChange() then
  66.             RTV.Start()
  67.         end
  68.  
  69.     end )
  70.  
  71. end )
  72.  
  73. function RTV.CanVote( ply )
  74. local plyCount = table.Count(player.GetAll())
  75.  
  76.     if RTV._ActualWait >= CurTime() then
  77.         return false, "You must wait a bit before voting!"
  78.     end
  79.  
  80.     if GetGlobalBool( "In_Voting" ) then
  81.         return false, "There is currently a vote in progress!"
  82.     end
  83.  
  84.     if ply.RTVoted then
  85.         return false, "You have already voted to Rock the Vote!"
  86.     end
  87.  
  88.     if RTV.ChangingMaps then
  89.         return false, "There has already been a vote, the map is going to change!"
  90.     end
  91.     if plyCount < RTV.PlayerCount then
  92.         return false, "You need more players before you can rock the vote!"
  93.     end
  94.    
  95.     return true
  96.  
  97. end
  98.  
  99. function RTV.StartVote( ply )
  100.  
  101.     local can, err = RTV.CanVote(ply)
  102.  
  103.     if not can then
  104.         ply:PrintMessage( HUD_PRINTTALK, err )
  105.         return
  106.     end
  107.  
  108.     RTV.AddVote( ply )
  109.  
  110. end
  111.  
  112. concommand.Add( "rtv_start", RTV.StartVote )
  113.  
  114. hook.Add( "PlayerSay", "RTV Chat Commands", function( ply, text )
  115.  
  116.     if table.HasValue( RTV.ChatCommands, string.lower(text) ) then
  117.         RTV.StartVote( ply )
  118.         return ""
  119.     end
  120.  
  121. end )
  122.  
  123. --------------------Unstuck--------------------
  124.  function ulx.unstuck( calling_ply )
  125.     if calling_ply:alive() then
  126.         calling_ply:spawn()
  127.     else
  128.         ULib.tsayError( calling_ply, calling_ply:Nick() .. "You Are Dead!" )
  129.     end
  130.     ulx.fancyLogAdmin( calling_ply, "#A Has Used !unstuck", calling_ply )
  131. end
  132. local unstuck = ulx.command ( CATEGORY_NAME, "ulx unstuck", ulx.unstuck, "!unstuck" )
  133. unstuck:defaultAccess( ULib.ACCESS_ALL )
  134. unstuck:help( "Teleports A User To Spawn" )
  135.  
  136. --------------------Afk--------------------
  137.  function ulx.afk( calling_ply, target_plys )
  138.     if  target_plys:Team() == TEAM_HUNTERS then
  139.         target_plys:Kill()
  140.         target_plys:SetTeam(TEAM_SPECTATORS)
  141.     elseif target_plys:Team() == TEAM_PROPS then
  142.         target_plys:Kill()
  143.         target_plys:SetTeam(TEAM_SPECTATORS)
  144.     end
  145.     ulx.fancyLogAdmin( calling_ply, "#A has moved #T to spectator.", target_plys )
  146. end
  147. local afk = ulx.command(CATEGORY_NAME, "ulx afk", ulx.afk "!afk" )
  148. afk:addParam{ type=ULib.cmds.PlayersArg }
  149. afk:defaultAccess( ULib.ACCESS_ADMIN )
  150. afk:help ( "Moves A Player To Spectator" )
  151. --------------------Force Swap--------------------
  152.  
  153. function ulx.forceswap( calling_ply, target_plys )
  154.     if target_plys:Team() == TEAM_HUNTERS then
  155.        target_plys:Kill()
  156.        target_plys:SetTeam(TEAM_PROPS)
  157.     elseif
  158.         target_plys:Team() == TEAM_PROPS then
  159.         target_plys:Kill()
  160.         target_plys:SetTeam(TEAM_HUNTERS)
  161.     end
  162. ulx.fancyLogAdmin( calling_ply, "#A has forceswapped #T", target_plys )
  163. end
  164. local forceswap = ulx.command(CATEGORY_NAME, "ulx forceswap", ulx.forceswap "!forceswap" )
  165. forceswap:addParam{ type=ULib.cmds.PlayersArg }
  166. forceswap:defaultAccess( ULib.ACCESS_ADMIN )
  167. forceswap:help ( "Force Swaps A Player To The Opposite Team" )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement