• Simple Map Voting Addon
    235 replies, posted
[b]Simple Map Voting Addon[/b] [t]http://i.imgur.com/S1tSwyI.jpg[/t] This is a wonderful little addon that allows you to easily invoke a map vote from within any gamemode of your choosing. (You can find a tutorial for setting this up with TTT below) Starting a vote from within lua is rather simple. [lua]MapVote.Start(voteLength, allowCurrentMap, mapLimit, mapPrefix)[/lua] All arguments to this function are optional and the map prefix is acquired from the gamemode.txt file if available. You can also set up defaults within lua/autorun/mapvote.lua. mapPrefix can be an array of prefixes, if not defined the script attempts to read from the gamemode's txt file for the map pattern. It is also possible to cancel map votes from within lua with: [lua]MapVote.Cancel()[/lua] You can give players extra voting power in lua/autorun/mapvote.lua with the MapVote.HasExtraVotePower function. [b]How to use this with Trouble in Terrorist Town[/b] Just install the addon and place [url=https://www.dropbox.com/s/jxl71o3jv15cy28/ttt_mapvote.lua]ttt_mapvote.lua (click here to download this file separately!)[/url] in to lua/autorun/server/ttt_mapvote.lua This file can be edited to meet your preferences: If you plan on using different map prefixes, you can replace {"ttt_", "cs_italy"} with (for example): {"ttt_", "dm_"} to allow both TTT and HL2:DM maps. This causes a map vote to start at the end of the game that lasts 15 seconds, doesn't include the current map, includes a maximum of 8 choices, and ensures all maps begin with "ttt_" or "cs_italy". It should also notify users that the map will be chosen from a map vote after each round. [b]Download![/b] Download Link: [url]https://github.com/wiox/gmod-mapvote/releases/download/1/mapvote.zip[/url] GitHub Repository: [url]https://github.com/wiox/gmod-mapvote[/url] Also, do whatever you like with it. I can't honestly say how much code I borrowed from Fretta, but any that I did borrow was for the voting panel. If you have any issues feel free to contact me over steam. One day I hope to create a ~way~ better version of this. This was originally meant for use by developers but clearly hasn't been, so any future versions will be easier on the user. TTT VIDEO TUTORIAL! Made especially for [url=http://steamcommunity.com/profiles/76561198040331952/]MrGreen[/url] [vid]https://dl.dropbox.com/u/14265905/share/2014-05/2014-05-15_23-05-38.webm[/vid]
OMG THANK YOU SO MUCH <3 LOVE YOU MAN! EXACTLY WHAT I WANTED [editline]5th May 2013[/editline] Well.... This Just F**cked up my server -_-
[QUOTE=adnan;40535513]OMG THANK YOU SO MUCH <3 LOVE YOU MAN! EXACTLY WHAT I WANTED [editline]5th May 2013[/editline] Well.... This Just F**cked up my server -_-[/QUOTE] Want to be more descriptive?
Don't worry, I just got TONS of lua errors when i changed the init.lua but dont worry ill fix it :)
[QUOTE=adnan;40535643]Don't worry, I just got TONS of lua errors when i changed the init.lua but dont worry ill fix it :)[/QUOTE] It's possible you accidentally changed more lines than intended, the exact replacement I put in the OP should work fine.
[QUOTE=Willox;40535655]It's possible you accidentally changed more lines than intended, the exact replacement I put in the OP should work fine.[/QUOTE] Ok and when i fix it ill post a download link for the init.lua :)
Shouldn't the de_, cs_, and dm_ map prefixes be in there for the TTT map vote?
kk ty
[QUOTE=Gatekeeper828;40535822]Shouldn't the de_, cs_, and dm_ map prefixes be in there for the TTT map vote?[/QUOTE] That's true, but the issue is all of the maps would be popping up. I'll see about making a whitelist some-when so you can enable just the maps you want + ttt_.
why not just make it so they pull from a list ?
[QUOTE=Evil Melon;40537798]why not just make it so they pull from a list ?[/QUOTE] Good idea, I'll add this in some-when soon unless somebody else wants to.
Also, There should be a continue on this map Willox!
[QUOTE=adnan;40538194]Also, There should be a continue on this map Willox![/QUOTE] No, mainly because everyone would want to play 67thway Also this is a lovely addon thank you very much
I am going to and try and fix my code a bit from here because this does something I never did
So, I should just remove my init file (Make a backup first of coarse) Then, replace the file? Thanks! ~kpj :eng101:
[QUOTE=kpjVideo;40549895]So, I should just remove my init file (Make a backup first of coarse) Then, replace the file? Thanks! ~kpj :eng101:[/QUOTE] You also need the addon installed
Just to make sure this is correct... What is the file location for the init.lua file? I found a bunch of ones mixed in with some addons... Thanks! ~kpj :eng101:
[QUOTE=kpjVideo;40550222]Just to make sure this is correct... What is the file location for the init.lua file? I found a bunch of ones mixed in with some addons... Thanks! ~kpj :eng101:[/QUOTE] gamemodes/terrortown/gamemode/init.lua
Thanks! I added it to my server but it appears to be blue... How can I modify it to make it transparent like the one in your picture? Thanks!
Now how would a lazy person like my self set this up with DeathRun?
Thank you. Some people like Pheonix would like to charge $20 for a simple fretta system, and you made one for free and released it. True good Samaritan.
[QUOTE=Sgt. Sicknezz;40553745]Now how would a lazy person like my self set this up with DeathRun?[/QUOTE] Actually I breezed through the code of this addon real quick, I don't there are any dependencies for TTT, you just got to put [lua] MapVote.Start(voteLength, allowCurrentMap, mapLimit, mapPrefix) [/lua] Where it would normally do the "next map" part in the gamemode(yours being jail break) So yours would be something like [lua] MapVote.Start(15, false, 24, "jb_") [/lua] Just find the right place to put it, probably the part of the gamemode that handles the next map.
[QUOTE=kpjVideo;40553180]Thanks! I added it to my server but it appears to be blue... How can I modify it to make it transparent like the one in your picture? Thanks![/QUOTE] If you can upload a screenshot I'll take a look. Later today I'm going to update it so multiple map prefixes can be used.
[QUOTE=J.R.;40555031]Actually I breezed through the code of this addon real quick, I don't there are any dependencies for TTT, you just got to put [lua] MapVote.Start(voteLength, allowCurrentMap, mapLimit, mapPrefix) [/lua] Where it would normally do the "next map" part in the gamemode(yours being jail break) So yours would be something like [lua] MapVote.Start(15, false, 24, "jb_") [/lua] Just find the right place to put it, probably the part of the gamemode that handles the next map.[/QUOTE] Where would i put the [lua]MapVote.Start(15, false, 24, "jb_")[/lua]?
[QUOTE=M60warrior;40557562]Where would i put the [lua]MapVote.Start(15, false, 24, "jb_")[/lua]?[/QUOTE] Line 728 of the init file of this section spanning lines 726 and 733 [lua] if switchmap then timer.Stop("end2prep") MapVote.Start(15, false, 24, "jb_") elseif ShouldMapSwitch() then LANG.Msg("limit_left", {num = rounds_left, time = math.ceil(time_left / 60), mapname = "Defined by vote"}) end[/lua] "load next map" It should be similar inits for most gamemodes so I'm assuming its as OP stated above. If it isn't look for where in the file it references "load next map." Always make a copy of the file before editing.
[QUOTE=Dark Pacifist;40557688]Line 728 of the init file of this section spanning lines 726 and 733 [lua] if switchmap then timer.Stop("end2prep") MapVote.Start(15, false, 24, "jb_") elseif ShouldMapSwitch() then LANG.Msg("limit_left", {num = rounds_left, time = math.ceil(time_left / 60), mapname = "Defined by vote"}) end[/lua] It should be similar inits for most gamemodes so I'm assuming its as OP stated above where he said where it went.[/QUOTE] I looked in the gamemode init.lua and all that is in there is [lua]--Loading the initialisation files. include("sh_init.lua"); AddCSLuaFile("cl_init.lua"); AddCSLuaFile("sh_init.lua"); --resource [/lua]
well... hate to be of no use... It may be in sh_init.lua but I really couldn't say where or anything of use you havn't likely thought of... sorry
Is it possible to set this up to read from a txt file rather than all maps of that prefix? I have more maps on my server than just the ones users play on, some are waiting to be armed. Also, does it select a random 24 maps to be voted on, or does it display them in order?
[QUOTE=Eccid;40557850]Is it possible to set this up to read from a txt file rather than all maps of that prefix? I have more maps on my server than just the ones users play on, some are waiting to be armed. Also, does it select a random 24 maps to be voted on, or does it display them in order?[/QUOTE] It's random. I'm just about to start work on an update that allows: A) Reading from a text file B) A table of extensions eg: [lua]MapVote.Start(15, false, 24, {"ttt_", "de_", "dm_"})[/lua] [editline]7th May 2013[/editline] [QUOTE=M60warrior;40557779]I looked in the gamemode init.lua and all that is in there is [lua]--Loading the initialisation files. include("sh_init.lua"); AddCSLuaFile("cl_init.lua"); AddCSLuaFile("sh_init.lua"); --resource [/lua][/QUOTE] If you add me on Steam I'll look in to a tutorial for your specific gamemode.
is there anyway to like initiate this like an !rtv command?
Sorry, you need to Log In to post a reply to this thread.