Jump to content

[Help] Markers visibility


scaremane

Recommended Posts

Posted

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!

Posted

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?

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

 

Posted
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]])

 

Posted
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

Posted

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.

Posted
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

Posted (edited)

This is an untested example. Hope it working ! :wink: 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 by DeadthStrock
Posted
1 hour ago, DeadthStrock said:

This is an untested example. Hope it working ! :wink: 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!

  • Like 1

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