DjSt3rios Posted July 11, 2011 Share Posted July 11, 2011 Hello, I Was on vacation so i decided to make something for IRC, !nextmap command which will set next map... i have this code: addIRCCommandHandler("!nextmap", function (server,channel,user,command,...) local query = #{...}>0 and table.concat({...},' ') or nil if not query then ircNotice(user, "Wrong Usage. Correct Usage: !nextmap ") return end local map = findMap( query ) if not map then ircNotice(user, "No map found.") return end outputChatBox('Next map set to ' .. getMapName( map ) .. ' by IRC Administrator ' .. user, getRootElement(), 0, 240, 0) executeCommandHandler("nextmap", user, map) outputIRC("Next map set to " .. getMapName(map) .. " by " .. user) end) So, The problem actually is that its not in Race resource, its in different.. so my error is this: ERROR: mapmanager/mapmanager_exports.lua:158: getMapsCompatibleWithGamemode: Invalid gamemode resource. Well, The map is fine, because we have played this map more than 400 times in my server.. and i also tried a lot of maps. Any help would be appriciated! Thanks! Link to comment
DjSt3rios Posted July 11, 2011 Author Share Posted July 11, 2011 Here are the functions which i copied from racevoting_server.lua: function findMap( query ) local maps = findMaps( query ) -- Make status string local status = "Found " .. #maps .. " match" .. ( #maps==1 and "" or "es" ) for i=1,math.min(5,#maps) do status = status .. ( i==1 and ": " or ", " ) .. "'" .. getMapName( maps[i] ) .. "'" end if #maps > 5 then status = status .. " (" .. #maps - 5 .. " more)" end if #maps == 0 then return nil, status .. " for '" .. query .. "'" end if #maps == 1 then return maps[1], status end if #maps > 1 then return nil, status end end -- Find all maps which match the query string function findMaps( query ) local results = {} -- Loop through and find matching maps for i,resource in ipairs(exports.mapmanager:getMapsCompatibleWithGamemode(getThisResource())) do local resName = getResourceName( resource ) local infoName = getMapName( resource ) -- Look for exact match first if query == resName or query == infoName then return {resource} end -- Find match for query within infoName if string.find( infoName:lower(), query:lower() ) then table.insert( results, resource ) end end return results end function getMapName( map ) return getResourceInfo( map, "name" ) or getResourceName( map ) or "unknown" end Link to comment
SDK Posted July 12, 2011 Share Posted July 12, 2011 Replace getThisResource() with getResourceFromName("race") (And you do know you're not doing anything with the found map in this script, right? I mean, it won't be "set next") Link to comment
DjSt3rios Posted July 13, 2011 Author Share Posted July 13, 2011 I will test it soon.. but why it wont be next map? Isnt this supposed to set next map? --> executeCommandHandler("nextmap", user, map) ? Link to comment
SDK Posted July 14, 2011 Share Posted July 14, 2011 Oh right, I missed that line, but it still won't work. First, user is probably a string with the irc user's nick. Second, that command is most likely an admin-only command, so you'll have to work around that. Your best options are to either somehow export the race function to set the nextmap or to write your own nextmap script. Link to comment
DjSt3rios Posted July 21, 2011 Author Share Posted July 21, 2011 hmmm.. im not really that good to make it maybe you could help me? 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