Jump to content

next map


Kenix

Recommended Posts

Here's the script does not work help me fix it. :(

  
local lastmap = nil 
  
function startnextmap() 
    local array = {} 
    local z = 0 
  
    for i,v in ipairs(getResources()) do 
        if string.match(getResourceName(v), "zm") then  
            z = z + 1  
            array[z]=v  
        end 
    end 
         
    local nextmap = array[math.random(1,z)] 
    if lastmap ~= nextmap then  
        stopResource(nextmap)  
        startResource(getResourceFromName(getResourceName(nextmap))) 
        lastmap = nextmap 
    end 
end 
  

Link to comment

The stopResource and startResource are wrong, use the correct pointers.

Or if you're running mapmanager, you can use this (it's probably better to not use this tho):

local lastmap = nil 
  
function startnextmap() 
    local gamemode = exports.mapmanager:getRunningGamemode()     -- current gamemode 
    local array = exports.mapmanager:getMapsCompatibleWithGamemode(gamemode) 
    local nextmap = array[math.random(1,#array)] 
    if lastmap ~= nextmap then  
        stopResource(exports.mapmanager:getRunningGamemodeMap())  
        startResource(nextmap) 
        lastmap = nextmap 
    end 
end 

Link to comment
The stopResource and startResource are wrong, use the correct pointers.

Or if you're running mapmanager, you can use this (it's probably better to not use this tho):

local lastmap = nil 
  
function startnextmap() 
    local gamemode = exports.mapmanager:getRunningGamemode()     -- current gamemode 
    local array = exports.mapmanager:getMapsCompatibleWithGamemode(gamemode) 
    local nextmap = array[math.random(1,#array)] 
    if lastmap ~= nextmap then  
        stopResource(exports.mapmanager:getRunningGamemodeMap())  
        startResource(nextmap) 
        lastmap = nextmap 
    end 
end 

not working need admin rights

[2011-01-15 22:41:22] Access denied @ 'stopResource'

[2011-01-15 22:41:22] Access denied @ 'startResource'

edit : mapmanager running

Link to comment

already a better job but he swears at stopResource

Bad argument @ 'stopResource'

acl

 name="Admin">         name="resource.zombie_mod" />name="Admin">        name="function.stopResource" access="true" />        name="function.startResource" access="true" /> 

Link to comment

help make that he has started any card please.

I used to use it here but it loads the game mode and maps as well I'd like to do to load only the map

  
exports.mapmanager:changeGamemode( getResourceFromName('zombie_mod') ) 
  

Link to comment
if you want only to load the map then why you put changeGamemode? i think you should use
changeGamemodeMap 

something is not working.

error in both cases mapmanager: invalid map specified.

  
function startnextmap() 
        local array = {} 
    local z = 0 
  
    for i,v in ipairs(getResources()) do 
        if string.match(getResourceName(v), "zm") then  
            z = z + 1  
            array[z]=v  
        end 
    end 
        exports.mapmanager:changeGamemodeMap(math.random(1,z)) 
         
end 
  

  
exports.mapmanager:changeGamemodeMap() 
  

Link to comment

here I am slightly corrected the error but still the problem with stop maps and runs it perfectly

immediately evident that he was stupidly run maps

[2011-01-19 16:55:25] Starting zm-newisland

[2011-01-19 16:55:25] start: Resource 'zm-newisland' started

[2011-01-19 16:55:44] Starting zm-angar

[2011-01-19 16:55:44] start: Resource 'zm-angar' started

[2011-01-19 16:55:56] Starting zm-war-island

[2011-01-19 16:55:56] start: Resource 'zm-war-island' started

  
function startnextmap() 
    local gamemode = exports.mapmanager:getRunningGamemode()      
    outputChatBox( "gamemode = " .. tostring(gamemode) ) 
  
    local array = exports.mapmanager:getMapsCompatibleWithGamemode(gamemode) 
    outputChatBox( "array = " .. tostring(array) ) 
  
    local nextmap = array[math.random(1,#array)] 
    outputChatBox( "nextmap = " .. tostring(nextmap) ) 
  
     
    if lastmap ~= nextmap then  
        
         local curentmap = exports.mapmanager:getRunningGamemodeMap()      
        outputChatBox( "MAP = " .. tostring(curentmap) )    
         
        startResource(nextmap) 
        lastmap = nextmap 
    else 
        outputChatBox( "случайно выбрана все та же текущая карта" ) 
    end 
end 
  

help please :(

Link to comment
And it doesn't work now? Please post full script again and debug

userdata wrote and values.

  
function startnextmap() 
    local gamemode = exports.mapmanager:getRunningGamemode()      
    outputChatBox( "gamemode = " .. tostring(gamemode) ) 
  
    local array = exports.mapmanager:getMapsCompatibleWithGamemode(gamemode) 
    outputChatBox( "array = " .. tostring(array) ) 
  
    local nextmap = array[math.random(1,#array)] 
    outputChatBox( "nextmap = " .. tostring(nextmap) ) 
  
     
    if lastmap ~= nextmap then  
         
        local thismap = exports.mapmanager:getRunningGamemodeMap() 
         outputChatBox( "MAP = " .. tostring(thismap) )   
  
        stopResource(thismap) 
        startResource(nextmap) 
        lastmap = nextmap 
    else 
        outputChatBox( "случайно выбрана все та же текущая карта" ) 
    end 
end 
  
  

edit :and call

  
setTimer(startnextmap, 6100, 1) 
  

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...