Kenix Posted January 26, 2011 Share Posted January 26, 2011 how to make the mission without a single marker and more? Link to comment
DakiLLa Posted January 26, 2011 Share Posted January 26, 2011 Eh, can you please explain better and more clearly what you actually want? Link to comment
Kenix Posted January 26, 2011 Author Share Posted January 26, 2011 Eh, can you please explain better and more clearly what you actually want? I wanted to do for the mission checkpoints example: but it does not work. local localplayer = getLocalPlayer() function Markers ( hitElement, matchingDimension ) local testnum = getElementData ( localPlayer, "test" ) destroyElement ( test ) if testnum == 1 then test = createMarker ( 1058.8583984375,1375.248046875,10.446697235107, "checkpoint" ) end if testnum == 2 then test = createMarker ( 1005.3486328125,1334.0693359375,10.419406890869, "checkpoint" ) end if testnum == 3 then test = createMarker ( 1029.42578125,1190.646484375,10.588260650635, "checkpoint" ) end setElementData ( localPlayer, "test", testnum + 1 ) addEventHandler( "onClientMarkerHit", test, Markers ) end Link to comment
DakiLLa Posted January 26, 2011 Share Posted January 26, 2011 Ok, lets go by steps: 1) look the first line: the variable 'localplayer' should be 'localPlayer' (case sensitive, you know). 2) I just got a code for you (not tested though) with comments: local localPlayer = getLocalPlayer() --lets put all your markers co-ordinates in a table to handle them later local mp = { { 1058.8583984375,1375.248046875,10.446697235107 }, { 1005.3486328125,1334.0693359375,10.419406890869 }, { 1029.42578125,1190.646484375,10.588260650635 } } function createFirstMarker() setElementData( localPlayer, "test", 1 ); createNextMarker( 1 ) --to create the first marker end addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource() ), createFirstMarker ) function onTestMarkerHit( hitElement, dim ) if getElementType( hitElement ) == "player" then --if a player just got in the marker removeEventHandler( "onClientMarkerHit", source, onTestMarkerHit ) --source is the marker that player got in destroyElement( source ); --we dont need this marker anymore setElementData( hitElement, "test", getElementData( hitElement, "test" ) + 1 ) --increase player 'marker count' by one if mp[ getElementData( hitElement, "test" ) ] then --if there is an existing row with this index in 'mp' table, create the next marker createNextMarker( getElementData( hitElement, "test" ) ) else outputChatBox( "There are no any markers left" ); end end end function createNextMarker( id ) local x, y, z = mp[ id ][ 1 ], mp[ id ][ 2 ], mp[ id ][ 3 ] --get the co-ordinates from the 'mp' table local newMarker = createMarker( x, y, z, "checkpoint" ) addEventHandler( "onClientMarkerHit", newMarker, onTestMarkerHit ) end Link to comment
Kenix Posted January 26, 2011 Author Share Posted January 26, 2011 Ok, lets go by steps:1) look the first line: the variable 'localplayer' should be 'localPlayer' (case sensitive, you know). 2) I just got a code for you (not tested though) with comments: local localPlayer = getLocalPlayer() --lets put all your markers co-ordinates in a table to handle them later local mp = { { 1058.8583984375,1375.248046875,10.446697235107 }, { 1005.3486328125,1334.0693359375,10.419406890869 }, { 1029.42578125,1190.646484375,10.588260650635 } } function createFirstMarker() setElementData( localPlayer, "test", 1 ); createNextMarker( 1 ) --to create the first marker end addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource() ), createFirstMarker ) function onTestMarkerHit( hitElement, dim ) if getElementType( hitElement ) == "player" then --if a player just got in the marker removeEventHandler( "onClientMarkerHit", source, onTestMarkerHit ) --source is the marker that player got in destroyElement( source ); --we dont need this marker anymore setElementData( hitElement, "test", getElementData( hitElement, "test" ) + 1 ) --increase player 'marker count' by one if mp[ getElementData( hitElement, "test" ) ] then --if there is an existing row with this index in 'mp' table, create the next marker createNextMarker( getElementData( hitElement, "test" ) ) else outputChatBox( "There are no any markers left" ); end end end function createNextMarker( id ) local x, y, z = mp[ id ][ 1 ], mp[ id ][ 2 ], mp[ id ][ 3 ] --get the co-ordinates from the 'mp' table local newMarker = createMarker( x, y, z, "checkpoint" ) addEventHandler( "onClientMarkerHit", newMarker, onTestMarkerHit ) end Thank you cool dude:) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now