Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.96 KB | None | 0 0
  1. algemas = {}
  2.  
  3. Interaction = {}
  4.  
  5.  
  6. Interaction.Show = function(element)
  7.     selectedElement = element
  8.     addEventHandler ("onClientRender", root, dxPainel_a)
  9. end
  10.  
  11.  
  12.     function dxPainel_a()
  13.         algemaO = tonumber(algemas[selectedElement])
  14.         local ID = getElementData(selectedElement, "ID") or "N/A"
  15.  
  16.         local px, py, pz = getElementPosition(localPlayer)
  17.         local ex, ey, ez = getElementPosition(selectedElement)
  18.         if getDistanceBetweenPoints3D(px, py, pz, ex, ey, ez) > getElementRadius(selectedElement) * 2 then
  19.             removeEventHandler("onClientRender", root, dxPainel_a)
  20.             return
  21.         end
  22.  
  23.         dxDrawRectangle(x*804, y*352, x*133, y*193, tocolor(0, 0, 0, 148), false)
  24.         dxDrawRectangle(x*804, y*352, x*133, y*21, tocolor(81, 202, 21, 254), false)
  25.         dxDrawText("Painel policial - ("..ID..")", x*811, y*357, x*927, y*369, tocolor(255, 255, 255, 255), x*0.33, font, "left", "top", false, false, false, false, false)
  26.         if cursorPosition(x*829, y*388, x*81, y*23) then
  27.         dxDrawRectangle(x*829, y*388, x*81, y*23, tocolor(81, 202, 21, 214), false)
  28.         else
  29.         dxDrawRectangle(x*829, y*388, x*81, y*23, tocolor(0, 0, 0, 214), false)
  30.         end
  31.     if cursorPosition(x*829, y*426, x*81, y*23) then
  32.         dxDrawRectangle(x*829, y*426, x*81, y*23, tocolor(81, 202, 21, 214), false)
  33.     else
  34.         dxDrawRectangle(x*829, y*426, x*81, y*23, tocolor(0, 0, 0, 214), false)
  35.     end
  36.     if cursorPosition(x*829, y*426+38, x*81, y*23) then
  37.         dxDrawRectangle(x*829, y*426+38, x*81, y*23, tocolor(81, 202, 21, 214), false)
  38. else
  39.         dxDrawRectangle(x*829, y*426+38, x*81, y*23, tocolor(0, 0, 0, 214), false)
  40.     end
  41.     if cursorPosition(x*829, y*426+38*2, x*81, y*23) then
  42.         dxDrawRectangle(x*829, y*426+38*2, x*81, y*23, tocolor(81, 202, 21, 214), false)
  43. else
  44.         dxDrawRectangle(x*829, y*426+38*2, x*81, y*23, tocolor(0, 0, 0, 214), false)
  45.     end
  46.         if algemaO == 1 then
  47.         text = "Desalgemar"
  48.     else
  49.         text = "Algemar"
  50.     end
  51.         dxDrawText(text, x*848, y*394, x*964, y*406, tocolor(255, 255, 255, 255), x*0.35, font, "left", "top", false, false, false, false, false)
  52.         dxDrawText("Carregar", x*848, y*431, x*964, y*443, tocolor(255, 255, 255, 255), x*0.35, font, "left", "top", false, false, false, false, false)
  53.         dxDrawText("Revistar", x*848, y*431+38, x*964, y*443, tocolor(255, 255, 255, 255), x*0.35, font, "left", "top", false, false, false, false, false)
  54.         dxDrawText("Fechar", x*848, y*431+38*2, x*964, y*443, tocolor(255, 255, 255, 255), x*0.35, font, "left", "top", false, false, false, false, false)
  55.     end
  56.  
  57.  
  58. addEventHandler("onClientClick", root, function(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement)
  59.     if button == "right" and state == "down" then
  60.         if isElement(clickedElement) then
  61.             if clickedElement ~= localPlayer then
  62.                 if  getElementType(clickedElement) == "player" then
  63.                     selectedElement = clickedElement
  64.                     if isEventHandlerAdded("onClientRender", getRootElement(), dxPainel_a) then  
  65.                        
  66.                         removeEventHandler("onClientRender", root, dxPainel_a)
  67.                     else                    
  68.                         Interaction.Show(clickedElement)
  69.                     end
  70.                 end
  71.             end
  72.         end
  73.     end
  74. end)
  75.  
  76. function botoesDx (_,state)
  77.     if isEventHandlerAdded("onClientRender", root, dxPainel_a) then  
  78.         if state == "down" then  
  79.         if cursorPosition(x*848, y*431+38*2, x*964, y*443) then -- fechar
  80.             removeEventHandler("onClientRender", root, dxPainel_a)
  81.             effectOn = false
  82.         elseif cursorPosition(x*829, y*388, x*81, y*23) then -- algemar
  83.             algemas[selectedElement] = 1
  84.             triggerServerEvent("algemar_A", localPlayer, selectedElement)
  85.             end
  86.         end
  87.     end
  88. end
  89. addEventHandler("onClientClick", root, botoesDx)
  90.  
  91. function isEventHandlerAdded( sEventName, pElementAttachedTo, func )
  92.     if
  93.         type( sEventName ) == 'string' and
  94.         isElement( pElementAttachedTo ) and
  95.         type( func ) == 'function'
  96.     then
  97.         local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo )
  98.         if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then
  99.             for i, v in ipairs( aAttachedFunctions ) do
  100.                 if v == func then
  101.                     return true
  102.                 end
  103.             end
  104.         end
  105.     end
  106.  
  107.     return false
  108. end
  109.  
  110. function cursorPosition(x, y, w, h)
  111.     if (not isCursorShowing()) then
  112.         return false
  113.     end
  114.     local mx, my = getCursorPosition()
  115.     local fullx, fully = guiGetScreenSize()
  116.     cursorx, cursory = mx*fullx, my*fully
  117.     if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then
  118.         return true
  119.     else
  120.         return false
  121.     end
  122. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement