Miika Posted May 2, 2016 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 ) Real motorbike backflip / frontflip script: https://forum.mtasa.com/viewtopic.php?f=108&t=98191
Anubhav Posted May 2, 2016 Posted May 2, 2016 Yeah, it is like that Use isPedOnGround See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
Miika Posted May 2, 2016 Author 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. Real motorbike backflip / frontflip script: https://forum.mtasa.com/viewtopic.php?f=108&t=98191
Miika Posted May 2, 2016 Author Posted May 2, 2016 oh, i fixed the problem. (Used getElementPosition and if) Real motorbike backflip / frontflip script: https://forum.mtasa.com/viewtopic.php?f=108&t=98191
Moderators IIYAMA Posted May 2, 2016 Moderators 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. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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