Selavi Posted April 2, 2015 Share Posted April 2, 2015 Witam, przerobiłem lekko gamemode "race" i po zakończeniu mapy odlicza 5 sec po czym ładuje losowo następną: Chciałbym zamienić, to losowe na tą samą mapę. (przykład: RaceCheetah->RaceCheetah). Jeżeli dobrze myślę to funkcję należy zmienić tu (mapmanager_main.lua): 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) -- Incase the resource being stopped has been deleted local stillExists = false for i, res in ipairs(getResources()) do if res == stoppedResource then stillExists = true break end end if not stillExists then return end 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 ) Nie jestem utalentowany w większej partii kodu więc prosiłbym o przeróbkę. Z góry dziękuję Link to comment
WhoAmI Posted April 2, 2015 Share Posted April 2, 2015 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 ) To musisz przerobić. 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