oPIXz Posted October 1, 2013 Share Posted October 1, 2013 Hi guys, function startNextMapVote() exports.votemanager:stopPoll() if maybeApplyForcedNextMap() then return end local compatibleMaps = exports.mapmanager:getMapsCompatibleWithGamemode(getThisResource()) if #compatibleMaps > 9 then math.randomseed(getTickCount()) repeat table.remove(compatibleMaps, math.random(1, #compatibleMaps)) until #compatibleMaps == 9 elseif #compatibleMaps < 2 then return false, errorCode.onlyOneCompatibleMap end for i,map in ipairs(compatibleMaps) do local swapWith = math.random(1, #compatibleMaps) local temp = compatibleMaps[i] compatibleMaps[i] = compatibleMaps[swapWith] compatibleMaps[swapWith] = temp end local poll = { title="Choose the next map:", visibleTo=getRootElement(), percentage=51, timeout=15, allowchange=true; } for index, map in ipairs(compatibleMaps) do local mapName = getResourceInfo(map, "name") or getResourceName(map) table.insert(poll, {mapName, 'nextMapVoteResult', getRootElement(), map}) end local currentMap = exports.mapmanager:getRunningGamemodeMap() if currentMap then table.insert(poll, {"Play again", 'nextMapVoteResult', getRootElement(), currentMap}) end This code to start vote for next map when map ended in race gm How i can change it to be like this example? E.g : http://www.m5zn.com/newuploads/2013/09/ ... 6ba140.png ? Link to comment
oPIXz Posted October 1, 2013 Author Share Posted October 1, 2013 dm maps has [DM] in the full name my race maps has [RC] in the full name Link to comment
Discord Moderators Zango Posted October 1, 2013 Discord Moderators Share Posted October 1, 2013 My guess is that you could use exports.mapmanager:getMapsCompatibleWithGamemode again - and retrieve the compatible maps for a deathmatch gamemode. Example: exports.mapmanager:getMapsCompatibleWithGamemode(getResourceFromName('deathmatch')) You would need to decrement this list as well (you might want to create a function for it instead). From the snippet you posted, you can't change how the client renders the data in "poll". Example: function processCompatibleMapsList(t_Maps) if (not t_Maps) or (type(t_Maps) ~= 'table') then return false end math.randomseed(getTickCount()) if (#t_Maps > 9) then repeat table.remove(t_Maps, math.random(1, #t_Maps)) until (#t_Maps == 9) elseif (#t_Maps < 2) then return false, errorCode.onlyOneCompatibleMap end return t_Maps end function shuffleMapsList(t_Maps) for i, map in ipairs (t_Maps) do local int_swapWith = math.random(1, #t_Maps) local map_curMap = map t_Maps[i] = t_Maps[int_swapWith] t_Maps[int_swapWith] = map_curMap end return t_Maps end function startNextMapVote() exports.votemanager:stopPoll() if maybeApplyForcedNextMap() then return end local race_compatibleMaps, e = processCompatibleMapsList(exports.mapmanager:getMapsCompatibleWithGamemode(getThisResource())) if (not race_compatibleMaps) then return false, e end local dm_compatibleMaps, e = processCompatibleMapsList(exports.mapmanager:getMapsCompatibleWithGamemode(getResourceFromName('deathmatch'))) if (not dm_compatibleMaps) then return false, e end race_compatibleMaps = shuffleMapsList(race_compatibleMaps) dm_compatibleMaps = shuffleMapsList(dm_compatibleMaps) -- move both lists into one local mapsList = {} for _, map in ipairs (race_compatibleMaps) do table.insert (mapsList, map) end; race_compatibleMaps = nil for _, map in ipairs (dm_compatibleMaps) do table.insert (mapsList, map) end; dm_compatibleMaps = nil local poll = { title="Choose the next map:", visibleTo=getRootElement(), percentage=51, timeout=15, allowchange=true; } for index, map in ipairs(mapsList) do local mapName = getResourceInfo(map, "name") or getResourceName(map) table.insert(poll, {mapName, 'nextMapVoteResult', getRootElement(), map}) end local currentMap = exports.mapmanager:getRunningGamemodeMap() if currentMap then table.insert(poll, {"Play again", 'nextMapVoteResult', getRootElement(), currentMap}) end Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now