emuk Posted January 25, 2013 Share Posted January 25, 2013 when I start the server why I get this warning ? WARNING: mapmanager\mapmanager_main.lua:6: Bad argument @ 'setGameType' [Expected string at argument 1, got boolean] thanks p.s also with the default server Link to comment
boro Posted January 25, 2013 Share Posted January 25, 2013 use this mapmanager_main currentGamemode = nil currentGamemodeMap = nil nextGamemode = nil nextGamemodeMap = nil rootElement = getRootElement() addEvent("onGamemodeStart") addEvent("onGamemodeStop") addEvent("onGamemodeMapStart") addEvent("onGamemodeMapStop") addEventHandler("onResourcePreStart", rootElement, function (startingResource) --Is starting resource a gamemode? if isGamemode(startingResource) then --Check if another gamemode is running already if getRunningGamemode() and getRunningGamemode() ~= startingResource then -- Initiate a new changemode sequence and cancel this event outputMapManager( "Initiating changemode from '" .. getResourceName(getRunningGamemode()) .. "' to '" .. getResourceName(startingResource) .. "'" ) changeGamemode(startingResource) cancelEvent(true) end elseif isMap(startingResource) then --Check if another map is running already if getRunningGamemodeMap() and getRunningGamemodeMap() ~= startingResource then -- Initiate a new changemap sequence and cancel this event if isGamemodeCompatibleWithMap ( getRunningGamemode(), startingResource ) then outputMapManager( "Initiating changemap from '" .. getResourceName(getRunningGamemodeMap()) .. "' to '" .. getResourceName(startingResource) .. "'" ) changeGamemodeMap(startingResource) end cancelEvent(true) end end end ) addEventHandler("onPlayerJoin", rootElement, function() if get("currentmap") and getRunningGamemode() and getRunningGamemodeMap() then outputMapManager( "Currently playing: " .. (getResourceInfo(getRunningGamemode(), "name") or getResourceName(getRunningGamemode())) .. " - " .. (getResourceInfo(getRunningGamemodeMap(), "name") or getResourceName(getRunningGamemodeMap())), source ) end end ) addEventHandler("onResourceStart", rootElement, function (startedResource) --Is this resource a gamemode? if isGamemode(startedResource) then --Check no gamemode is running already if getRunningGamemode() then return end if triggerEvent("onGamemodeStart", getResourceRootElement(startedResource), startedResource) then currentGamemode = startedResource --Setup our announcements local gamemodeName = getResourceInfo(currentGamemode, "name") or getResourceName(currentGamemode) if get("ASE") then setGameType(gamemodeName) end if get("messages") then local name = getInstigatorName ( " by " ) or "" outputMapManager("Gamemode '"..gamemodeName.."' started" .. name .. "." ) end --We need to wait a while to see if any maps were started. If not, lets try and start a random one setTimer( function() if not getRunningGamemodeMap() then --Lets check if there are any maps for this gamemode local maps = getMapsCompatibleWithGamemode(getRunningGamemode()) --If we have any, we'll start a random one if #maps > 0 then changeGamemodeMap (maps[math.random(1,#maps)]) end end end, 50, 1 ) else currentGamemode = nil end elseif isMap(startedResource) then --If its a map --Make sure there is a gamemode running if not getRunningGamemode() then return end --Is there a map running already? if getRunningGamemodeMap() then return end --Is it compatible with our gamemode? if isGamemodeCompatibleWithMap ( getRunningGamemode(), startedResource ) then --Lets link the map with the gamemode if ( triggerEvent("onGamemodeMapStart", getResourceRootElement(startedResource), startedResource) ) then currentGamemodeMap = startedResource --Setup our announcements local gamemodeMapName = getResourceInfo(currentGamemodeMap, "name") or getResourceName(currentGamemodeMap) applyMapSettings( currentGamemodeMap ) if get("ASE") then setMapName(gamemodeMapName) end if get("messages") then local name = getInstigatorName ( " by " ) or "" outputMapManager("Map '"..gamemodeMapName.."' started" .. name .. ".") end else currentGamemodeMap = nil end end end end ) addEventHandler("onResourceStop", rootElement, function (stoppedResource) local resourceRoot = getResourceRootElement(stoppedResource) if stoppedResource == currentGamemode then triggerEvent("onGamemodeStop", resourceRoot, currentGamemode) currentGamemode = nil setGameType(false) if currentGamemodeMap then stopResource(currentGamemodeMap) elseif nextGamemode then startGamemodeT(nextGamemode) nextGamemode = nil if nextGamemodeMap then startGamemodeMapT(nextGamemodeMap) nextGamemodeMap = nil end end elseif stoppedResource == currentGamemodeMap then triggerEvent("onGamemodeMapStop", resourceRoot, currentGamemodeMap) currentGamemodeMap = nil resetMapInfo() setMapName("None") if nextGamemode then startGamemodeT(nextGamemode) nextGamemode = nil if nextGamemodeMap then startGamemodeMapT(nextGamemodeMap) nextGamemodeMap = nil end elseif nextGamemodeMap then startGamemodeMapT(nextGamemodeMap) nextGamemodeMap = nil end end end ) function changeGamemodeMap_cmd(source, command, ...) local mapName = #{...}>0 and table.concat({...},' ') or nil source = source or serverConsole local map if mapName then map = getMapFromName(mapName) if not isMap(map) then if (refreshResources and hasObjectPermissionTo(getThisResource(), "function.refreshResources", false)) then outputMapManager("'"..mapName.."' is not a valid map.", source) else outputMapManager("'"..mapName.."' is not a valid map. Use the refresh command and try again", source) end return false end else outputMapManager("Usage: /"..command.." map",source) return false end local gamemode = currentGamemode if not isGamemode(gamemode) then outputMapManager("No gamemode is running.",source) elseif not isMapCompatibleWithGamemode(map, gamemode) then outputMapManager("Map '"..getResourceName(map).. "' is not compatible with '"..getResourceName(gamemode).."'.",source) else setInstigator( source ) changeGamemodeMap(map, gamemode) end end addCommandHandler("changemap", changeGamemodeMap_cmd, true) function changeGamemode_cmd(source, command, gamemodeName,...) local mapName = #{...}>0 and table.concat({...},' ') or nil source = source or serverConsole local gamemode if gamemodeName then gamemode = getResourceFromName(gamemodeName) if not isGamemode(gamemode) then if (refreshResources and hasObjectPermissionTo(getThisResource(), "function.refreshResources", false)) then refreshResources(false) gamemode = getResourceFromName(gamemodeName) if not isGamemode(gamemode) then outputMapManager("'"..gamemodeName.."' is not a valid gamemode.", source) return false end else outputMapManager("'"..gamemodeName.."' is not a valid gamemode. Use the refresh command and try again", source) return false end end else outputMapManager("Usage: /"..command.." gamemode [map]",source) return false end local map if mapName then map = getMapFromName(mapName) if not isMap(map) then if (refreshResources and hasObjectPermissionTo(getThisResource(), "function.refreshResources", false)) then outputMapManager("'"..mapName.."' is not a valid map.", source) else outputMapManager("'"..mapName.."' is not a valid map. Use the refresh command and try again", source) end return false end end setInstigator( source ) changeGamemode(gamemode,map) end addCommandHandler("gamemode", changeGamemode_cmd, true) addCommandHandler("changemode", changeGamemode_cmd, true) function stopGamemode_cmd(source) source = source or serverConsole if currentGamemode then stopGamemode() local gamemodeName = getResourceInfo(currentGamemode, "name") or getResourceName(currentGamemode) outputMapManager("Gamemode '"..gamemodeName.."' stopped.",source) else outputMapManager("No gamemode is running.",source) end end addCommandHandler("stopmode", stopGamemode_cmd, true) function stopGamemodeMap_cmd(source) source = source or serverConsole Link to comment
emuk Posted January 25, 2013 Author Share Posted January 25, 2013 thanks!! now it works 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