Advertisement
Guest User

Untitled

a guest
Feb 28th, 2012
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.68 KB | None | 0 0
  1. if ( SERVER ) then
  2.     hook.Add( "TTTEndRound", "ChangeMap", function()
  3.         rounds_left = math.max(0, GetGlobalInt("ttt_rounds_left", 6))
  4.         if rounds_left <= 0 then
  5.             maplist =   {   "cs_assult",
  6.                             "cs_compound",
  7.                             "cs_havana",
  8.                             "cs_militia",
  9.                             "cs_office"
  10.             }
  11.             Results = { 0, 0, 0, 0, 0 }
  12.             newmaplist = {}
  13.             map = nil
  14.             for i=1,5 do
  15.                 randommap = math.random( 1, #maplist )
  16.                 newmaplist[i] = maplist[randommap]
  17.                 table.remove( maplist, randommap )
  18.                 --print( newmaplist[i] )
  19.             end
  20.            
  21.             for k, v in pairs( player.GetAll() ) do
  22.                 umsg.Start( "SendVoteMsg" );
  23.                     for i=1,5 do
  24.                         local map = newmaplist[i]
  25.                         --print( map )
  26.                         umsg.String( tostring( map ) )
  27.                     end
  28.                 umsg.End();
  29.             end
  30.            
  31.             timer.Simple( 10, function()
  32.                 map = DetermineMapWinner()
  33.                 for k,v in pairs( player.GetAll() ) do
  34.                     evolve.Notify( ply, evolve.colors.red, map .. " has won the vote!" )
  35.                 end
  36.             end )
  37.             timer.Simple( 15, function()
  38.                 game.ConsoleCommand( "ev map " .. map .. "" )
  39.             end )
  40.         end
  41.     end )
  42.     concommand.Add( "VoteForMap1", function()
  43.         Results[1] = Results[1] + 1
  44.     end )
  45.     concommand.Add( "VoteForMap2", function()
  46.         Results[2] = Results[2] + 1
  47.     end )
  48.     concommand.Add( "VoteForMap3", function()
  49.         Results[3] = Results[3] + 1
  50.     end )
  51.     concommand.Add( "VoteForMap4", function()
  52.         Results[4] = Results[4] + 1
  53.     end )
  54.     concommand.Add( "VoteForMap5", function()
  55.         Results[5] = Results[5] + 1
  56.     end )
  57.    
  58.     function DetermineMapWinner()
  59.         max = 0
  60.         for k,v in pairs( Results ) do
  61.             if v > max then
  62.                 max = v
  63.             end
  64.         end
  65.         for k,v in pairs( Results ) do
  66.             if v == max then
  67.                 return newmaplist[k]
  68.             end
  69.         end
  70.     end
  71. end
  72. if ( CLIENT ) then
  73.     usermessage.Hook( "SendVoteMsg", function( um )
  74.             VoteMapWindow = vgui.Create( "DFrame" )
  75.             VoteMapWindow:SetSize( 200, 95 )
  76.             VoteMapWindow:SetPos( ScrW() / 2 - VoteMapWindow:GetWide() / 2, ScrH() / 2 - VoteMapWindow:GetTall() / 2 )
  77.             VoteMapWindow:SetTitle( "Map Vote" )           
  78.             VoteMapWindow:SetDraggable( false )
  79.             VoteMapWindow:ShowCloseButton( true )
  80.             VoteMapWindow:SetBackgroundBlur( true )
  81.             VoteMapWindow:MakePopup()
  82.            
  83.             local optionlist = vgui.Create( "DPanelList", VoteMapWindow )
  84.             optionlist:SetPos( 5, 25 )
  85.             optionlist:SetSize( 190, 65 )
  86.             optionlist:SetPadding( 5 )
  87.             optionlist:SetSpacing( 5 )
  88.                    
  89.             map1string = um:ReadString()
  90.             map2string = um:ReadString()
  91.             map3string = um:ReadString()
  92.             map4string = um:ReadString()
  93.             map5string = um:ReadString()
  94.            
  95.             local map1 = vgui.Create( "DButton" )
  96.             map1:SetText( map1string )
  97.             map1:SetTall( 25 )
  98.             map1.DoClick = function()
  99.                 RunConsoleCommand( "VoteForMap1" )
  100.                 VoteMapWindow:Close()
  101.             end
  102.            
  103.             local map2 = vgui.Create( "DButton" )
  104.             map2:SetText( map2string )
  105.             map2:SetTall( 25 )
  106.             map2.DoClick = function()
  107.                 RunConsoleCommand( "VoteForMap2" )
  108.                 VoteMapWindow:Close()
  109.             end
  110.            
  111.             local map3 = vgui.Create( "DButton" )
  112.             map3:SetText( map3string )
  113.             map3:SetTall( 25 )
  114.             map3.DoClick = function()
  115.                 RunConsoleCommand( "VoteForMap3" )
  116.                 VoteMapWindow:Close()
  117.             end
  118.            
  119.             local map4 = vgui.Create( "DButton" )
  120.             map4:SetText( map4string )
  121.             map4:SetTall( 25 )
  122.             map4.DoClick = function()
  123.                 RunConsoleCommand( "VoteForMap4" )
  124.                 VoteMapWindow:Close()
  125.             end
  126.            
  127.             local map5 = vgui.Create( "DButton" )
  128.             map5:SetText( map5string )
  129.             map5:SetTall( 25 )
  130.             map5.DoClick = function()
  131.                 RunConsoleCommand( "VoteForMap5" )
  132.                 VoteMapWindow:Close()
  133.             end
  134.            
  135.                
  136.             optionlist:AddItem( map1 )
  137.             optionlist:AddItem( map2 )
  138.             optionlist:AddItem( map3 )
  139.             optionlist:AddItem( map4 )
  140.             optionlist:AddItem( map5 )
  141.  
  142.     end )
  143. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement