if ( SERVER ) then hook.Add( "TTTEndRound", "ChangeMap", function() rounds_left = math.max(0, GetGlobalInt("ttt_rounds_left", 6)) if rounds_left <= 0 then 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 umsg.Start( "SendVoteMsg" ); for i=1,5 do local map = newmaplist[i] --print( map ) umsg.String( tostring( map ) ) end umsg.End(); end timer.Simple( 10, function() map = DetermineMapWinner() for k,v in pairs( player.GetAll() ) do evolve.Notify( ply, evolve.colors.red, map .. " has won the vote!" ) end end ) timer.Simple( 15, function() game.ConsoleCommand( "ev map " .. map .. "" ) 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 ) function DetermineMapWinner() max = 0 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 return newmaplist[k] end end end end if ( CLIENT ) then usermessage.Hook( "SendVoteMsg", function( um ) VoteMapWindow = vgui.Create( "DFrame" ) VoteMapWindow:SetSize( 200, 95 ) 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, 65 ) 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