Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ( SERVER ) then
- function DetermineMapWinner()
- max = 0
- winningcount = 0
- winners = {}
- for k,v in pairs( Results ) do
- if v > max then
- max = v
- end
- end
- for k,v in pairs( Results ) do
- if v == max then
- winningcount = winningcount + 1
- winnerindex = table.Count( winners ) + 1
- winners[winnerindex] = k
- end
- end
- if winningcount > 1 then
- finalwinner = table.Random( winningcount )
- return newmaplist[finalwinner]
- else
- return newmaplist[finalwinner]
- end
- end
- hook.Add( "TTTEndRound", "ChangeMap", function()
- rounds_left = math.max(0, GetGlobalInt("ttt_rounds_left", 6))
- if rounds_left <= 0 then
- if DoChangeMap or DoChangeMap == nil then
- DoChangeMap = false
- maplist = { "cs_assult",
- "cs_compound",
- "cs_havana",
- "cs_militia",
- "cs_office"
- }
- Results = { 0, 0, 0, 0, 0 }
- newmaplist = {}
- map = nil
- for i=1,5 do
- randommap = math.random( 1, #maplist )
- newmaplist[i] = maplist[randommap]
- table.remove( maplist, randommap )
- --print( newmaplist[i] )
- end
- for k, v in pairs( player.GetAll() ) do
- timer.Simple( 5, function()
- umsg.Start( "SendVoteMsg" );
- for i=1,5 do
- local map = newmaplist[i]
- --print( map )
- umsg.String( tostring( map ) )
- end
- umsg.End();
- end )
- end
- timer.Simple( 10, function()
- local map = DetermineMapWinner()
- evolve.Notify( evolve.colors.red, map .. " has won the vote!" )
- end )
- timer.Simple( 15, function()
- RunConsoleCommand( "ev", "map", map )
- end )
- end
- end
- end )
- concommand.Add( "VoteForMap1", function()
- Results[1] = Results[1] + 1
- end )
- concommand.Add( "VoteForMap2", function()
- Results[2] = Results[2] + 1
- end )
- concommand.Add( "VoteForMap3", function()
- Results[3] = Results[3] + 1
- end )
- concommand.Add( "VoteForMap4", function()
- Results[4] = Results[4] + 1
- end )
- concommand.Add( "VoteForMap5", function()
- Results[5] = Results[5] + 1
- end )
- end
- if ( CLIENT ) then
- usermessage.Hook( "SendVoteMsg", function( um )
- VoteMapWindow = vgui.Create( "DFrame" )
- VoteMapWindow:SetSize( 200,185 )
- VoteMapWindow:SetPos( ScrW() / 2 - VoteMapWindow:GetWide() / 2, ScrH() / 2 - VoteMapWindow:GetTall() / 2 )
- VoteMapWindow:SetTitle( "Map Vote" )
- VoteMapWindow:SetDraggable( false )
- VoteMapWindow:ShowCloseButton( true )
- VoteMapWindow:SetBackgroundBlur( true )
- VoteMapWindow:MakePopup()
- local optionlist = vgui.Create( "DPanelList", VoteMapWindow )
- optionlist:SetPos( 5, 25 )
- optionlist:SetSize( 190, 155 )
- optionlist:SetPadding( 5 )
- optionlist:SetSpacing( 5 )
- map1string = um:ReadString()
- map2string = um:ReadString()
- map3string = um:ReadString()
- map4string = um:ReadString()
- map5string = um:ReadString()
- local map1 = vgui.Create( "DButton" )
- map1:SetText( map1string )
- map1:SetTall( 25 )
- map1.DoClick = function()
- RunConsoleCommand( "VoteForMap1" )
- VoteMapWindow:Close()
- end
- local map2 = vgui.Create( "DButton" )
- map2:SetText( map2string )
- map2:SetTall( 25 )
- map2.DoClick = function()
- RunConsoleCommand( "VoteForMap2" )
- VoteMapWindow:Close()
- end
- local map3 = vgui.Create( "DButton" )
- map3:SetText( map3string )
- map3:SetTall( 25 )
- map3.DoClick = function()
- RunConsoleCommand( "VoteForMap3" )
- VoteMapWindow:Close()
- end
- local map4 = vgui.Create( "DButton" )
- map4:SetText( map4string )
- map4:SetTall( 25 )
- map4.DoClick = function()
- RunConsoleCommand( "VoteForMap4" )
- VoteMapWindow:Close()
- end
- local map5 = vgui.Create( "DButton" )
- map5:SetText( map5string )
- map5:SetTall( 25 )
- map5.DoClick = function()
- RunConsoleCommand( "VoteForMap5" )
- VoteMapWindow:Close()
- end
- optionlist:AddItem( map1 )
- optionlist:AddItem( map2 )
- optionlist:AddItem( map3 )
- optionlist:AddItem( map4 )
- optionlist:AddItem( map5 )
- end )
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement