Jump to content

Marker triggers map/gm change doesnt work. .lua script


Recommended Posts

Idea: Creating a marker on Map "Draqonlife" (gamemode play), which leads you to to another map.

In this case "DraqonDocks" (gamemode race).

known issues to be ignored: event triggers any marker

known issues to be fixed: after gamemode change, the map wont change.

Marker.lua :

>Creates a marker (works)

>Triggers player on entering and leaving any Marker (works)

>Starts gamemode race (works)

! Does not start Map !

!! No error when map does not start !!

!! ERROR: lobby/ChangeMode.lua:7:  attempt to call global 'changeGamemodeMap'  (a nil value) !!

resourceRoot = getResourceRootElement()
function onCurrentResourceStart(Draqonlife)
	local resourceName = getResourceName(Draqonlife)
    outputChatBox("Hello and welcome to " .. resourceName .. "!")
	Marker = createMarker (2860, -2115, 10, "corona", 4.0, 0, 0, 255, 255) --  create Marker
addEventHandler("onResourceStart", resourceRoot, onCurrentResourceStart)
//Create Marker

function MarkerHit( hitElement, matchingDimension ) 
local elementType = getElementType( hitElement )
	local resource = getResourceFromName ("race") -- | this works,
	startResource( resource ) -- 					 | really good tho
			--local resource = getResourceFromName ("DraqonDocks") 
			--startResource( resource ) 						   
		   // If I try to start the map Resource directly after the race resource,
 		  // the Map resource wont load up
addEventHandler( "onMarkerHit", root, MarkerHit) 
//Should start gamemode race (and map)

function MarkerLeave( leaveElement,matchingDimension) 
local elementType = getElementType( leaveElement ) 
	local resource = getResourceFromName ("DraqonDocks") -- |Also not working, server ignores this line,
	startResource( resource )   						 -- |as it Ignores this line too.
addEventHandler( "onMarkerLeave", root, MarkerLeave )


> My Idea to fix this problem

--Thats why i want to import the mapmanager  (or the function changeGamemodeMap)
--Sadly I found no useful documentation for my case.
--adding <exports.mapmanager:changeGamemodeMap/> to the meta.xml of the scripts didnt work

function changeGamemodeMap()

changeGamemodeMap("DraqonDocks", "race") -- this doesnt work

addCommandHandler("420", changeGamemodeMap)


It would be very kind if someone could enlight me and give me a short introduction to  using mapmanagers functions properly. Sadly the Mapmanager post in wiki didnt help me too much.

If you find a fix for the existing (half working)  Marker.lua, then I'd be really glad too

I would love to get feedback and already thank  everyone


Edited by Draqon
Link to comment
marker = createMarker(2498.1, -1657.1,  13.1, "corona", 2.0, 255, 0, 0, 255)

function markerhits (source, matchingDimension)
	if isElementWithinMarker(source, marker) then
	local resource = getResourceFromName("race")

addEventHandler ( "onMarkerHit", getRootElement(), markerhits )

function markerLeave( leaveElement, matchingDimension )
	if (not isElementWithinMarker(source, marker)) then
        		local resource = getResourceFromName("DraqMap")

addEventHandler( "onMarkerLeave", marker, markerLeave )
On 6.7.2017 at 03:20, Draqon said:


using     if isElementWithinMarker(source, marker)       directly after markerhits or markerLeave gets it working



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