Jump to content

next map (Race game mode) with IRC command, help!


Recommended Posts

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...