Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- algemas = {}
- Interaction = {}
- Interaction.Show = function(element)
- selectedElement = element
- addEventHandler ("onClientRender", root, dxPainel_a)
- end
- function dxPainel_a()
- algemaO = tonumber(algemas[selectedElement])
- local ID = getElementData(selectedElement, "ID") or "N/A"
- local px, py, pz = getElementPosition(localPlayer)
- local ex, ey, ez = getElementPosition(selectedElement)
- if getDistanceBetweenPoints3D(px, py, pz, ex, ey, ez) > getElementRadius(selectedElement) * 2 then
- removeEventHandler("onClientRender", root, dxPainel_a)
- return
- end
- dxDrawRectangle(x*804, y*352, x*133, y*193, tocolor(0, 0, 0, 148), false)
- dxDrawRectangle(x*804, y*352, x*133, y*21, tocolor(81, 202, 21, 254), false)
- 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)
- if cursorPosition(x*829, y*388, x*81, y*23) then
- dxDrawRectangle(x*829, y*388, x*81, y*23, tocolor(81, 202, 21, 214), false)
- else
- dxDrawRectangle(x*829, y*388, x*81, y*23, tocolor(0, 0, 0, 214), false)
- end
- if cursorPosition(x*829, y*426, x*81, y*23) then
- dxDrawRectangle(x*829, y*426, x*81, y*23, tocolor(81, 202, 21, 214), false)
- else
- dxDrawRectangle(x*829, y*426, x*81, y*23, tocolor(0, 0, 0, 214), false)
- end
- if cursorPosition(x*829, y*426+38, x*81, y*23) then
- dxDrawRectangle(x*829, y*426+38, x*81, y*23, tocolor(81, 202, 21, 214), false)
- else
- dxDrawRectangle(x*829, y*426+38, x*81, y*23, tocolor(0, 0, 0, 214), false)
- end
- if cursorPosition(x*829, y*426+38*2, x*81, y*23) then
- dxDrawRectangle(x*829, y*426+38*2, x*81, y*23, tocolor(81, 202, 21, 214), false)
- else
- dxDrawRectangle(x*829, y*426+38*2, x*81, y*23, tocolor(0, 0, 0, 214), false)
- end
- if algemaO == 1 then
- text = "Desalgemar"
- else
- text = "Algemar"
- end
- 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)
- 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)
- 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)
- 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)
- end
- addEventHandler("onClientClick", root, function(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement)
- if button == "right" and state == "down" then
- if isElement(clickedElement) then
- if clickedElement ~= localPlayer then
- if getElementType(clickedElement) == "player" then
- selectedElement = clickedElement
- if isEventHandlerAdded("onClientRender", getRootElement(), dxPainel_a) then
- removeEventHandler("onClientRender", root, dxPainel_a)
- else
- Interaction.Show(clickedElement)
- end
- end
- end
- end
- end
- end)
- function botoesDx (_,state)
- if isEventHandlerAdded("onClientRender", root, dxPainel_a) then
- if state == "down" then
- if cursorPosition(x*848, y*431+38*2, x*964, y*443) then -- fechar
- removeEventHandler("onClientRender", root, dxPainel_a)
- effectOn = false
- elseif cursorPosition(x*829, y*388, x*81, y*23) then -- algemar
- algemas[selectedElement] = 1
- triggerServerEvent("algemar_A", localPlayer, selectedElement)
- end
- end
- end
- end
- addEventHandler("onClientClick", root, botoesDx)
- function isEventHandlerAdded( sEventName, pElementAttachedTo, func )
- if
- type( sEventName ) == 'string' and
- isElement( pElementAttachedTo ) and
- type( func ) == 'function'
- then
- local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo )
- if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then
- for i, v in ipairs( aAttachedFunctions ) do
- if v == func then
- return true
- end
- end
- end
- end
- return false
- end
- function cursorPosition(x, y, w, h)
- if (not isCursorShowing()) then
- return false
- end
- local mx, my = getCursorPosition()
- local fullx, fully = guiGetScreenSize()
- cursorx, cursory = mx*fullx, my*fully
- if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then
- return true
- else
- return false
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement