Guest User

Untitled

a guest
Jan 5th, 2019
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.30 KB | None | 0 0
  1. local screenW, screenH = guiGetScreenSize()
  2.  
  3. function isMouseInPosition ( x, y, width, height )
  4. if ( not isCursorShowing( ) ) then
  5. return false
  6. end
  7. local sx, sy = guiGetScreenSize ( )
  8. local cx, cy = getCursorPosition ( )
  9. local cx, cy = ( cx * sx ), ( cy * sy )
  10. if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then
  11. return true
  12. else
  13. return false
  14. end
  15. end
  16.  
  17. local marker = createMarker(-1879.73, -1659.73, 21.75-1, "cylinder", 3, 0, 102, 204, 125)
  18. local blip = createBlip(-1879.73, -1659.73, 21.75,37)
  19. local t_text = createElement('text')
  20. setElementPosition(t_text,-1879.73, -1659.73, 21.75)
  21. setElementData(t_text,'name','Złomowisko')
  22. local showed = false
  23.  
  24. local click = 1
  25.  
  26. function KGtoTB(kg)
  27. if tonumber(kg) > 1000 then
  28. return (kg/1000).."T"
  29. end
  30. return kg.."KG"
  31. end
  32.  
  33. addEventHandler("onClientMarkerHit", marker, function(hit)
  34. if hit ~= localPlayer then return end
  35. --if getPlayerSerial(localPlayer) ~= 'E31AEC4C62F98B8C0EA93CFB5A469042' and getPlayerSerial(localPlayer) ~= '48A8847F2FE11ACDCC0B0D3855F56902' then return end
  36. local veh = hit:getOccupiedVehicle(hit)
  37. if not veh then return end
  38. if not veh:getData("vehicle:id") then return end
  39. local owner = veh:getData("vehicle:ownedPlayer")
  40. if owner ~= hit:getData("player:sid") then return end
  41. if veh:getController() ~= hit then return end
  42. addEventHandler("onClientRender", root, gui)
  43. showCursor(true)
  44. showed = true
  45. click = 0
  46. end)
  47.  
  48. function gui()
  49. local veh = localPlayer:getOccupiedVehicle()
  50. if not veh then return end
  51. local h = veh:getHandling()
  52. local m = h["mass"]
  53. local txt = "Za złomowanie pojazdu "..(veh:getName() or "ERROR").." o uid: "..(veh:getData("vehicle:id") or 0).."\n oraz wadze "..KGtoTB(m).." otrzymasz "..math.floor(m*100).."$"
  54. exports["buttons"]:createCustomWindow("Zlomowisko", screenW * 0.3604, screenH * 0.2787, screenW * 0.2792, screenH * 0.4426, tocolor(255, 255, 255, 255), false)
  55. exports["buttons"]:createCustomButton("Złomuj", screenW * 0.386, screenH * 0.65, screenW * 0.102, screenH * 0.044, tocolor(255, 255, 255, 255), false)
  56. exports["buttons"]:createCustomButton("Anuluj", screenW * 0.511, screenH * 0.65, screenW * 0.102, screenH * 0.044, tocolor(255, 255, 255, 255), false)
  57. exports["buttons"]:createCustomText(txt, screenW * 0.3667, screenH * 0.3454, screenW * 0.6318, screenH * 0.6296, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, true, false, false, false)
  58. end
  59.  
  60. addEventHandler("onClientClick", root, function(b,s)
  61. if b ~= "left" or s ~= "down" then return end
  62. if showed ~= true then return end
  63. if isMouseInPosition(screenW * 0.386, screenH * 0.65, screenW * 0.102, screenH * 0.044) then
  64. local veh = localPlayer:getOccupiedVehicle()
  65. if not veh then return end
  66. if click == 0 then
  67. click = 1
  68. outputChatBox("Kliknij ponownie aby potwierdzić zezłomowanie pojazdu "..veh:getName())
  69. elseif click == 1 then
  70. click = 0
  71. showed = false
  72. triggerServerEvent("zlomuj", localPlayer, veh)
  73. removeEventHandler("onClientRender", root, gui)
  74. showCursor(false)
  75. end
  76. elseif isMouseInPosition(screenW * 0.511, screenH * 0.65, screenW * 0.102, screenH * 0.044) then
  77. removeEventHandler("onClientRender", root, gui)
  78. showCursor(false)
  79. showed = false
  80. click = 0
  81. end
  82. end)
Advertisement
Add Comment
Please, Sign In to add comment