Jump to content

checking if map is started


Anubhav

Recommended Posts

Posted

Is it possible to check if map is started?

Or i need to make a event.

I don't need it for race . I need for my gamemode of rhino TDM.

Please help. Remember if you know how to do then please show a example code.

Posted

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() 
  

Posted

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

Posted

Hmm. Is it possible to make a exported function to check if map start. Like :

If its true then its started else if its false then not

  
local map = exports.resourcename:isMapStart() 
if map == false then 
--My code 
  
end 
  

Posted
What should i do in getResourceInfo first argument what should i write in it?

The resource that you want to get info about. I suggest you to use the event better such i posted above .

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

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