RyanUSNS

SO Coords

Sep 7th, 2017
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.61 KB | None | 0 0
  1. local picking, testMarker, zDifference
  2.  
  3. function pickPosition()
  4.     if (not picking) then
  5.         return false
  6.     end
  7.     if (not isCursorShowing()) then
  8.         return false
  9.     end
  10.     local dumpx, dumpy, worldX, worldY, worldZ = getCursorPosition()
  11.     local px, py, pz = getCameraMatrix()
  12.     local hit, x, y, z, elementHit = processLineOfSight(px, py, pz, worldX, worldY, worldZ)
  13.     if (not hit) then
  14.         return false
  15.     end
  16.     z = z + zDifference
  17.     if (getKeyState("mouse1")) then
  18.         local zone, city = getZoneName(x, y, z), getZoneName(x, y, z, true)
  19.         outputChatBox(x .. " " .. y .. " " .. z)
  20.         outputChatBox(zone .. ", " .. city)
  21.         toggleListening()
  22.         createMarker(x, y, z, "cylinder")
  23.         return true
  24.     elseif (getKeyState("num_8")) then
  25.         zDifference = zDifference + 0.01
  26.     elseif (getKeyState("num_2")) then
  27.         zDifference = zDifference - 0.01
  28.     end
  29.     setElementPosition(testMarker, x, y, z)
  30.     local text = "X: " .. x .. ", Y: " .. y .. ", Z: " .. z
  31.     dxDrawText(text, 0, 0, 0, 0)
  32. end
  33.  
  34. function toggleListening()
  35.     picking = not picking
  36.     if (picking) then
  37.         showCursor(false)
  38.         outputDebugString("Stopped picking")
  39.         picking = false
  40.         destroyElement(testMarker)
  41.         testMarker = nil
  42.         return false
  43.     end
  44.     showCursor(true)
  45.     testMarker = createMarker(0, 0, 0, "corona", 0.15, 255, 0, 0)
  46.     removeEventHandler("onClientRender", root, pickPosition)
  47.     addEventHandler("onClientRender", root, pickPosition)
  48.     outputDebugString("Started picking")
  49.     picking = true
  50.     zDifference = 0
  51. end
  52. addCommandHandler("tc", toggleListening)
Advertisement
Add Comment
Please, Sign In to add comment