Alright, I'm very very very new to LUA and what I've made so far is just from copying parts of other things in ULX. I want to make a votemenu that will change the gamemode.
With the code shown below, I can get a menu to pop up but nothing happens when I select an option. Can someone tell me how to fix this? I pretty much don't know what I'm doing so this may be very very wrong code.
local function rtgDone ( t, ply, sandbox, bhop, terrortown )
local results = t.results
local winner
local winnernum = 0
for id, numvotes in pairs( results ) do
if numvotes > winnernum then
winner = id
winnernum = numvotes
end
end
if #sandbox > 1 then
ULib.consoleCommand( "gamemode sandbox" )
end
if #bhop > 1 then
ULib.consoleCommand( "gamemode bhop" )
end
if #terrortown > 1 then
ULib.consoleCommand( "gamemode terrortown" )
end
end
function ulx.rtg( calling_ply )
local sandbox = "Sandbox"
local bhop = "Bhop"
local terrortown = "TTT"
if ulx.voteInProgress then
ULib.tsayError( calling_ply, "There is already a vote in progress. Please wait for the current one to end.", true )
return
end
local msg = "Switch gamemode to..."
ulx.doVote( msg, { sandbox, bhop, terrortown }, rtgDone )
end
local rtg = ulx.command( CATEGORY_NAME, "ulx rtg", ulx.rtg, "!rtg" )
rtg:defaultAccess( ULib.ACCESS_ADMIN )
rtg:help( "Starts a vote to switch the gamemode." )