Miika Posted May 2, 2016 Share Posted May 2, 2016 Hi, I have a problem. When i fly over marker that i have created, it triggers my stuff even if i don't hit the marker. Same thing happens if i go under it. Here's part of my code: for i=1, #drugs do local co = split(drugs[i][2], ", ") local col = split(drugs[i][3], ", ") marker[i] = createMarker(co[1], co[2], co[3]-1, "cylinder", 1.5, 0, 255, 255, 100) setElementInterior(marker[i], 2) setElementData(marker[i], "drugsystem:marker", i) end addEventHandler("onClientMarkerHit", resourceRoot, function(hitElement, matchingDimension) if matchingDimension == true then if not (getElementData(source, "drugsystem:marker") == false) then if (getElementType(hitElement) == "player") then if not (isPedInVehicle(hitElement)) then if (guiGetVisible(window["gui"]) == false) then markerObject = source guiSetVisible(window["gui"], true) showCursor(true) guiSetText(label["drugid"], "Drug type: " .. drugs[getElementData(source, "drugsystem:marker")][1]) guiSetText(label["duration"], "Creation time: " .. drugs[getElementData(source, "drugsystem:marker")][4] .. " seconds") guiSetText(label["effect"], "Effect: " .. drugs[getElementData(source, "drugsystem:marker")][5]) end end end end end end ) Link to comment
Anubhav Posted May 2, 2016 Share Posted May 2, 2016 Yeah, it is like that Use isPedOnGround Link to comment
Miika Posted May 2, 2016 Author Share Posted May 2, 2016 Yeah, it is like thatUse isPedOnGround But it won't fix the problem, if someone walks in lower floor it triggers it. In my case, i have markers in smoke's crack place at drug lab and when you walk in lower floor to stairs, it triggers the marker. Link to comment
Miika Posted May 2, 2016 Author Share Posted May 2, 2016 oh, i fixed the problem. (Used getElementPosition and if) Link to comment
Moderators IIYAMA Posted May 2, 2016 Moderators Share Posted May 2, 2016 local _, _, z1 = getElementPosition (hitElement) local _, _, z2 = getElementPosition (source) if math.max(z1-z2, z2-z1) < 3 then end It does have one bug. If you fall from the sky, it will not trigger. Because you already triggered it when you entered the sky. Or use as detection a colshape. (you don't have to delete the marker) https://wiki.multitheftauto.com/wiki/CreateColSphere @Miika822 as you said... I was still replying, when you did answer your own question. 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