Jump to content

checking if map is started


Anubhav

Recommended Posts

You can use addEvent, addEventHandler and triggerEvent. EXAMPLE:

  
local map = { 
    info = {name = "Map",author = "Someone"} 
} 
  
map.creation_handler = function() 
    createObject(...) 
    createObject(...) 
    triggerEvent("onMapLoad",resourceRoot,map.info.name,map.info.author) 
end 
addEvent("onMapLoad",true) 
addEventHandler("onMapLoad",resourceRoot,function(name,author) 
    -- your stuff 
end) 
  
-- and to create the map you call the creation_handler function 
map.creation_handler() 
  

Link to comment

You can make it more simply :

addEvent ( 'onServerMapStart',true ) 
addEventHandler ( 'onResourceStart',root, 
    function ( resource ) 
        if getResourceInfo ( resource,'type' ) == 'map' then 
            triggerEvent ( 'onServerMapStart',resourceRoot ) 
        end 
    end 
) 

In the other resource or any resource :

addEventHandler ( 'onServerMapStart',root, 
    function (    ) 
        outputChatBox ( 'Map Started',root ) 
    end 
) 

Now you can use 'onServerMapStart' Event when want :) .

Link to comment
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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