Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Script By Csoki
- local screenX, screenY = guiGetScreenSize()
- local currentTab = 1
- local tabs = {
- {
- name = "oldal 1",
- content = function(x, y, w, h) --Ide amit fel akarsz rajzolni tartalom
- dxDrawText("oldal 1", x, y, x + w, y + h, tocolor(255, 0, 0), 1, "sans", "center", "center")
- end
- },
- {
- name = "oldal 2",
- content = function(x, y, w, h) --Ide amit fel akarsz rajzolni tartalom
- dxDrawText("oldal 2", x, y, x + w, y + h, tocolor(0, 255, 0), 1, "sans", "center", "center")
- end
- }
- }
- local hoverButton = false
- function renderPanel()
- hoverButton = false
- local padding = 10
- local w, h = 300, 200
- local x, y = screenX/2 - w/2, screenY/2 - h/2
- local _x, _y = x, y
- dxDrawRectangle(x, y, w, h, tocolor(0, 0, 0, 180))
- local tabW, tabH = 100, 20
- x = x - tabW - padding
- for tabID, value in pairs(tabs) do
- dxDrawRectangle(x, y, tabW, tabH, tocolor(0, 0, 0, 180))
- if isMouseInPosition(x, y, tabW, tabH) then
- dxDrawRectangle(x, y, tabW, tabH, tocolor(100, 100, 100, 50))
- hoverButton = tabID
- end
- dxDrawText(value.name, x, y, x + tabW, y + tabH, tocolor(255, 255, 255), 1, "default", "center", "center")
- y = y + tabH + padding
- end
- if tabs[currentTab] then
- tabs[currentTab].content(_x, _y, w, h)
- end
- end
- function clickPanel(button, state)
- if button == "left" and state == "down" then
- if hoverButton then
- if currentTab ~= hoverButton then
- currentTab = hoverButton
- end
- end
- end
- end
- function openPanel()
- removeEventHandler("onClientRender", root, renderPanel)
- addEventHandler("onClientRender", root, renderPanel)
- removeEventHandler("onClientClick", root, clickPanel)
- addEventHandler("onClientClick", root, clickPanel)
- hoverButton = false
- end
- addEventHandler("onClientResourceStart", root, openPanel)
- --Useful from mta wiki
- function isMouseInPosition ( x, y, width, height )
- if ( not isCursorShowing( ) ) then
- return false
- end
- local sx, sy = guiGetScreenSize ( )
- local cx, cy = getCursorPosition ( )
- local cx, cy = ( cx * sx ), ( cy * sy )
- return ( ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) )
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement