Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local picking, testMarker, zDifference
- local markerInfo = {}
- function pickPosition()
- if (not picking or not isCursorShowing()) then
- return false
- end
- local dumpx, dumpy, worldX, worldY, worldZ = getCursorPosition()
- local px, py, pz = getCameraMatrix()
- local hit, x, y, z, elementHit = processLineOfSight(px, py, pz, worldX, worldY, worldZ)
- if (not hit) then
- return false
- end
- z = z + zDifference
- setElementPosition(testMarker, x, y, z)
- local text = "X: " .. x .. ", Y: " .. y .. ", Z: " .. z
- dxDrawText(text, 0, 0, 0, 0) -- debugging only
- markerInfo = {}
- markerInfo = {x, y, z}
- end
- function increaseZ()
- if (not picking) then
- return false
- end
- zDifference = zDifference + 0.1
- end
- function decreaseZ()
- if (not picking) then
- return false
- end
- zDifference = zDifference - 0.1
- end
- function spawnMarker()
- if (not picking or not isCursorShowing()) then
- return false
- end
- local x, y, z = markerInfo[1], markerInfo[2], markerInfo[3]
- local zone, city = getZoneName(x, y, z), getZoneName(x, y, z, true)
- outputChatBox(x .. " " .. x .. " " .. z)
- outputChatBox(zone .. ", " .. city)
- toggleListening()
- end
- function toggleListening()
- picking = not picking
- showCursor(picking)
- if (picking) then
- testMarker = createMarker(0, 0, 0, "cylinder", 2, 255, 167, 0)
- removeEventHandler("onClientRender", root, pickPosition)
- addEventHandler("onClientRender", root, pickPosition)
- picking = true
- zDifference = 0
- bindKey("mouse1", "down", spawnMarker)
- bindKey("pgup", "down", increaseZ)
- bindKey("pgdn", "down", decreaseZ)
- bindKey("num_8", "down", increaseZ)
- bindKey("num_2", "down", decreaseZ)
- return false
- end
- markerInfo = {}
- destroyElement(testMarker)
- testMarker = nil
- unbindKey("pgup", "down", increaseZ)
- unbindKey("pgdn", "down", decreaseZ)
- unbindKey("num_8", "down", increaseZ)
- unbindKey("num_2", "down", decreaseZ)
- unbindKey("mouse1", "down", spawnMarker)
- end
- addCommandHandler("tc", toggleListening)
Advertisement
Add Comment
Please, Sign In to add comment