scaremane Posted October 12, 2018 Share Posted October 12, 2018 Hey! I am new on Lua and I was wondering if someone can help me with this. Basically I want the markers hidden when hitting the markers, it works perfectly but the marker can still be selected once any player gets in. I want them to dissapear and also nobody would be able to interact with them. local act1Marker1 = createMarker(2445.3193359375,2376.3627929688,12.163512229919, "cylinder", 1.0,0,246,255,50) createBlipAttachedTo(act1Marker1,60) local act1Marker2 = createMarker(2435.3193359375,2376.3627929688,12.163512229919, "cylinder", 1.0,0,246,255,50) setElementVisibleTo ( act1Marker2, root, false ) addEventHandler("onMarkerHit",act1Marker1, function(hitElement,matchingDimension) triggerClientEvent("showGui", hitElement, hitElement) end) function startact1Job(thePlayer) outputChatBox("Anda al siguiente marker!", hitElement,100,100,100) setElementVisibleTo ( act1Marker1, root, false) setElementVisibleTo ( act1Marker2, root, true) end addEvent("giveact1Job",true) addEventHandler("giveact1Job", root, startact1Job) function MarkerHit54( hitElement, matchingDimension ) outputChatBox("Ganaste!", hitElement,100,100,100) setElementVisibleTo ( act1Marker1, root, true) setElementVisibleTo ( act1Marker2, root, false) end addEventHandler( "onMarkerHit", act1Marker2, MarkerHit54 ) Thanks in advance! Link to comment
LilDawage Posted October 12, 2018 Share Posted October 12, 2018 setElementVisibleTo ( act1Marker1, root, true) setElementVisibleTo ( act1Marker2, root, false) make source to who you want Visible it Link to comment
scaremane Posted October 13, 2018 Author Share Posted October 13, 2018 I think I didn't explain very well. Problem is script is working but the marker still can be selected when any player hit it. SetElementVisible just hides the marker object or also the functions it has? Or I gotta user another function? Link to comment
VenomOG Posted October 13, 2018 Share Posted October 13, 2018 8 minutes ago, IvanAkaSick said: I think I didn't explain very well. Problem is script is working but the marker still can be selected when any player hit it. SetElementVisible just hides the marker object or also the functions it has? Or I gotta user another function? Explain the script. @IvanAkaSick local act1Marker1 = createMarker(2445.3193359375,2376.3627929688,12.163512229919, "cylinder", 1.0,0,246,255,50) createBlipAttachedTo(act1Marker1,60) local act1Marker2 = createMarker(2435.3193359375,2376.3627929688,12.163512229919, "cylinder", 1.0,0,246,255,50) setElementVisibleTo ( act1Marker2, root, false ) addEventHandler("onMarkerHit",act1Marker1, function(hitElement,matchingDimension) triggerClientEvent("showGui", hitElement, hitElement) end) function startact1Job(thePlayer) outputChatBox("Anda al siguiente marker!", hitElement,100,100,100) setElementVisibleTo ( act1Marker1, thePlayer, false ) setElementVisibleTo ( act1Marker2, thePlayer, true ) end addEvent("giveact1Job",true) addEventHandler("giveact1Job", root, startact1Job) function MarkerHit54( hitElement, matchingDimension ) outputChatBox("Ganaste!", hitElement,100,100,100) setElementVisibleTo ( act1Marker1, hitElement, true) setElementVisibleTo ( act1Marker2, hitElement, false) end addEventHandler( "onMarkerHit", act1Marker2, MarkerHit54 ) Link to comment
Z4Zy Posted October 13, 2018 Share Posted October 13, 2018 4 hours ago, IvanAkaSick said: Basically I want the markers hidden when hitting the markers, it works perfectly but the marker can still be selected once any player gets in. I want them to dissapear and also nobody would be able to interact with them. Well, as I understand... Use "destroyElement" to destroy the marker when someone hit. Instead of changing it's visibility. destroyElement([[Marker_Name]]) Link to comment
VenomOG Posted October 13, 2018 Share Posted October 13, 2018 2 minutes ago, DeadthStrock said: Well, as I understand... Use "destroyElement" to destroy the marker when someone hit. Instead of changing it's visibility. destroyElement([[Marker_Name]]) Its a job so setElementVisibleTo will be best, just remove the marker until the job is ready for it again Link to comment
Z4Zy Posted October 13, 2018 Share Posted October 13, 2018 So, it's easy to use setElementData to set an data to the marker when someone hit and check that element data is true or false when someone again hit it to decide that function should run or not. Link to comment
VenomOG Posted October 13, 2018 Share Posted October 13, 2018 2 minutes ago, DeadthStrock said: So, it's easy to use setElementData to set an data to the marker when someone hit and check that element data is true or false when someone again hit it to decide that function should run or not. "Hey! I am new on Lua and I was wondering if someone can help me with this" he said this mabye hes just testing Link to comment
Z4Zy Posted October 13, 2018 Share Posted October 13, 2018 (edited) This is an untested example. Hope it working ! Here you are ... local act1Marker1= createMarker(2445.3193359375,2376.3627929688,12.163512229919, "cylinder", 1.0,0,246,255,50) createBlipAttachedTo(act1Marker1,60) setElementData ( act1Marker1, "work", true ) local act1Marker2 = createMarker(2435.3193359375,2376.3627929688,12.163512229919, "cylinder", 1.0,0,246,255,50) setElementVisibleTo ( act1Marker2 , root, false ) setElementData ( act1Marker2, "work", false ) addEventHandler("onMarkerHit",act1Marker1, function(hitElement,matchingDimension) if getElementData ( source, "work" ) == true then triggerClientEvent("showGui", hitElement, hitElement) end end) function startact1Job(thePlayer) outputChatBox("Anda al siguiente marker!", hitElement,100,100,100) setElementVisibleTo ( act1Marker1, root, false) setElementData ( act1Marker1, "work", false ) setElementVisibleTo ( act1Marker2, root, true) setElementData ( act1Marker2, "work", true ) end addEvent("giveact1Job",true) addEventHandler("giveact1Job", root, startact1Job) function MarkerHit54( hitElement, matchingDimension ) if getElementData ( source, "work" ) == true then outputChatBox("Ganaste!", hitElement,100,100,100) setElementVisibleTo ( act1Marker1, root, true) setElementData ( act1Marker1, "work", true ) setElementVisibleTo ( act1Marker2, root, false) setElementData ( act1Marker2, "work", false ) end end addEventHandler( "onMarkerHit", act1Marker2, MarkerHit54 ) Edited October 13, 2018 by DeadthStrock Link to comment
scaremane Posted October 13, 2018 Author Share Posted October 13, 2018 1 hour ago, DeadthStrock said: This is an untested example. Hope it working ! Here you are ... local act1Marker1= createMarker(2445.3193359375,2376.3627929688,12.163512229919, "cylinder", 1.0,0,246,255,50) createBlipAttachedTo(act1Marker1,60) setElementData ( act1Marker1, "work", true ) local act1Marker2 = createMarker(2435.3193359375,2376.3627929688,12.163512229919, "cylinder", 1.0,0,246,255,50) setElementVisibleTo ( act1Marker2 , root, false ) setElementData ( act1Marker2, "work", false ) addEventHandler("onMarkerHit",act1Marker1, function(hitElement,matchingDimension) if getElementData ( source, "work" ) == true then triggerClientEvent("showGui", hitElement, hitElement) end end) function startact1Job(thePlayer) outputChatBox("Anda al siguiente marker!", hitElement,100,100,100) setElementVisibleTo ( act1Marker1, root, false) setElementData ( act1Marker1, "work", false ) setElementVisibleTo ( act1Marker2, root, true) setElementData ( act1Marker2, "work", true ) end addEvent("giveact1Job",true) addEventHandler("giveact1Job", root, startact1Job) function MarkerHit54( hitElement, matchingDimension ) if getElementData ( source, "work" ) == true then outputChatBox("Ganaste!", hitElement,100,100,100) setElementVisibleTo ( act1Marker1, root, true) setElementData ( act1Marker1, "work", true ) setElementVisibleTo ( act1Marker2, root, false) setElementData ( act1Marker2, "work", false ) end end addEventHandler( "onMarkerHit", act1Marker2, MarkerHit54 ) worked perfect , thanks you very much! 1 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