Jump to content

start Resource if map is DM


h4x7o0r

Recommended Posts

Posted

Hello there,

I wanna check when map starts, if the map has specific word "dm" in its name. If so , i wanna start a resource . Otherwise, i want that the resource to be stopped during map playing.

I have the following code:

  
addEvent("onClientRequestRespawn", true) 
addEventHandler("onClientRequestRespawn", getRootElement(), 
function checkDM ( mapName ) 
    if not string.find( mapName, "[DD]", 1, true ) or string.find( mapName, "[FDD]", 1, true ) then 
        startResource (test)  
    else 
        stopResource (test) 
    end 
    ) 
  

Posted

Try this:

addEventHandler ( "onMapStarting", root, 
    function ( mapInfo ) 
        if string.find ( mapInfo.name, "[DM]", 1, true ) then 
            startResource ( getResourceFromName ( "TEST" ) ) 
        else 
            stopResource ( getResourceFromName ( "TEST" ) ) 
        end 
    end 
) 

Posted

Thank you for your help. I've test it, but doesn't work without any error. client or server ? i've use it both (even with admin rights set on the resource itself).

Posted

Try this and see what it says on chat box:

addEventHandler ( "onMapStarting", root, 
    function ( mapInfo ) 
outputChatBox ( "Map name: ".. mapInfo.name ) 
        if string.find ( mapInfo.name, "[DM]", 1, true ) then 
            startResource ( getResourceFromName ( "TEST" ) ) 
        else 
            stopResource ( getResourceFromName ( "TEST" ) ) 
        end 
    end 
) 

Posted

I've tried new code, nothing's appearing. What kind a script should this be ? i presume it's server-side.

LE. i've checked again and it's appearing Map name : ..

Posted
I've tried new code, nothing's appearing. What kind a script should this be ? i presume it's server-side.

LE. i've checked again and it's appearing Map name : ..

yes it is server-sided.

anyways, if that event isn't called, then I'm assuming that you aren't running the Race Gamemode

Posted

the mistake was that my maps was kinda Cross 1 DM and not Cross 1 [DM] like. So i've modified the script and now it's working very fine . Thank you guys for all your help. Now all i need is to figure it out why isn't working that well votemanager but there's another topic. Again thank you for helping me. All the best.

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