I’m trying to make a vote map system to be used at the end of the match on terror town but I keep getting errors. If someone could help me, please do.
Btw I’m not very good with lua and this is one of the first things I’ve tried to make, go easy on me please :).
Server side
[lua] AddCSLuaFile(“sdwe.lua”)
AddCSLuaFile(“init.lua”)
maplist = {}
maplist[1] = “ttt_amsterville_b5”
maplist[2] = “ttt_alt_borders_b13”
maplist[3] = “ttt_camel_v1”
maplist[4] = “ttt_canyon_a4”
maplist[5] = “ttt_cluedo_b5”
maplist[6] = “ttt_district_a4”
maplist[6] = “ttt_enclave_b1”
maplist[7] = “ttt_icarus_b2”
maplist[8] = “ttt_lost_temple_b2”
maplist[9] = “ttt_nexus_v2”
function startvote()
local voting = true
startvotecl()
for k,v in pairs(player.GetAll()) do
v["voted"] = false
end
for key, value in pairs(maplist) do
value = {}
value["votes"] = 0
end
timer.Simple(15, votingended)
end
function startvotecl()
for k,v in pairs(player.GetAll()) do
umsg.Start(“mapvote”, v)
umsg.End()
end
end
local function actualvote(ply, cmd, args)
if voting and not ply.voted then
ply[“voted”] = true
tonumber(args[1])[“votes”] = tonumber(args[1])[“votes”] + 1
end
end
concommand.Add(“mapvote”, actualvote)
local mapvotes = {}
function votingended()
for k,v in pairs(player.GetAll()) do
umsg.Start(“votingended”, v)
umsg.End()
end
voting = false
b = 1
a = maplist**[“votes”]
for i = 1 , #maplist do
if not maplist*[“votes”] then
de = maplist*
de[“votes”] = 0
end
end
if a > tonumber(maplist[2])[“votes”] then b = 2
end
if not a > maplist[3][“votes”] then b = 3
end
if not a > maplist[4][“votes”] then b = 4
end
if not a > maplist[5][“votes”] then b = 5
end
if not a > maplist[6][“votes”] then b = 6
end
if not a > maplist[7][“votes”] then b = 7
end
if not a > maplist[8][“votes”] then b = 8
end
if not a > maplist[9][“votes”] then b = 9
end
RunConsoleCommand(“Changelevel”, tostring(maplist**))
end
– lua_openscript autorun/server/votingthing.lua [/lua]
client side
[lua] maplist = {}
maplist[1] = “ttt_amsterville_b5”
maplist[2] = “ttt_alt_borders_b13”
maplist[3] = “ttt_camel_v1”
maplist[4] = “ttt_canyon_a4”
maplist[5] = “ttt_cluedo_b5”
maplist[6] = “ttt_district_a4”
maplist[6] = “ttt_enclave_b1”
maplist[7] = “ttt_icarus_b2”
maplist[8] = “ttt_lost_temple_b2”
maplist[9] = “ttt_nexus_v2”
function lmaosss()
DermaPanel = vgui.Create( “DFrame” )
DermaPanel:SetPos( ScrW() /4 ,50 ) – Position on the players screen
DermaPanel:SetSize( ScrW() /2, ScrH() /2 ) – Size of the frame
DermaPanel:SetTitle( “Map vote” )
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( false ) //Can the player drag the frame /True/False
DermaPanel:ShowCloseButton( false ) //Show the X (Close button) /True/False
DermaPanel:MakePopup()
TestingComboBox = vgui.Create( “DComboBox”, DermaPanel )
TestingComboBox:SetPos( 10, 35 )
TestingComboBox:SetSize( 100, 185 )
TestingComboBox:SetMultiple( false )
for k,v in pairs(maplist) do
TestingComboBox:AddItem( v )
end
mapvotebutton = vgui.Create(“DButton”, DermaPanel)
mapvotebutton:SetText( “Vote” )
mapvotebutton:SetPos( 25, 300 )
mapvotebutton:SetSize( 150, 50 )
mapvotebutton.DoClick = function( ply )
if TestingComboBox:GetSelectedItems() and TestingComboBox:GetSelectedItems()[1] then
RunConsoleCommand( “mapvote”, TestingComboBox:GetSelectedItems()[1]:GetValue() )
DermaPanel:SetVisible(false)
end
end
end
usermessage.Hook( “mapvote”, lmaosss )
– lua_openscript_cl autorun/client/sdwe.lua [/lua]