--[[
FiveM Lua Menü Arayüzü Şablonu
Bu script, oyun içinde temel bir menü arayüzü oluşturmak için bir başlangıç noktasıdır.
Herhangi bir hile veya zararlı işlevsellik İÇERMEZ.
Yalnızca eğitim amaçlı bir arayüz (UI) örneğidir.
]]
-- Menü ayarları
local menu = {
x = 0.1, -- Menünün X eksenindeki konumu (0.0 - 1.0)
y = 0.2, -- Menünün Y eksenindeki konumu (0.0 - 1.0)
width = 0.2, -- Menünün genişliği
height = 0.04, -- Her bir menü öğesinin yüksekliği
titleHeight = 0.05, -- Başlık yüksekliği
visible = false, -- Menü başlangıçta gizli mi?
selectedIndex = 1, -- Seçili olan menü öğesi
options = {}, -- Menü seçenekleri burada saklanacak
}
-- Renkler
local colors = {
background = { r = 20, g = 20, b = 20, a = 200 },
titleBackground = { r = 150, g = 0, b = 0, a = 220 },
selectedBackground = { r = 200, g = 50, b = 50, a = 200 },
text = { r = 255, g = 255, b = 255, a = 255 },
titleText = { r = 255, g = 255, b = 255, a = 255 },
}
-- Yardımcı çizim fonksiyonları
function DrawText(text, x, y, font, scale, color)
SetTextFont(font)
SetTextScale(scale, scale)
SetTextColour(color.r, color.g, color.b, color.a)
SetTextWrap(0.0, 1.0)
SetTextCentre(false)
SetTextDropshadow(2, 0, 0, 0, 255)
SetTextEdge(1, 0, 0, 0, 205)
SetTextEntry("STRING")
AddTextComponentString(text)
DrawText(x, y)
end
-- Menü Seçeneklerini Tanımlama
-- Her seçenek bir 'label' (görünen metin) ve bir 'action' (tıklandığında çalışacak fonksiyon) içerir.
menu.options = {
{
label = "Oyuncu Ayarları",
action = function()
-- Bu butona tıklandığında ne olacağını buraya yaz.
-- Örneğin, bildirim gösterebiliriz.
TriggerEvent('chat:addMessage', { args = { '^1[Menü]', 'Oyuncu ayarları açılıyor...' } })
end
},
{
label = "Araç Ayarları",
action = function()
TriggerEvent('chat:addMessage', { args = { '^2[Menü]', 'Araç ayarları açılıyor...' } })
end
},
{
label = "Silah Ayarları",
action = function()
TriggerEvent('chat:addMessage', { args = { '^3[Menü]', 'Silah ayarları açılıyor...' } })
end
},
{
label = "Teleport Seçenekleri",
action = function()
TriggerEvent('chat:addMessage', { args = { '^4[Menü]', 'Teleport menüsü açılıyor...' } })
end
},
{
label = "Menüyü Kapat",
action = function()
menu.visible = false
end
},
}
-- Ana thread (sürekli çalışacak döngü)
Citizen.CreateThread(function()
while true do
Citizen.Wait(0) -- Her karede çalışmasını sağlar
-- Menüyü açma/kapatma tuşu (F8 varsayılan olarak konsolu açar, F5 kullanalım)
if IsControlJustReleased(0, 166) then -- F5 Tuşu
menu.visible = not menu.visible
end
-- Eğer menü görünür değilse, döngünün geri kalanını atla
if not menu.visible then
goto continue
end
-- Menü Başlığını Çizdirme
DrawRect(menu.x, menu.y, menu.width, menu.titleHeight, colors.titleBackground.r, colors.titleBackground.g, colors.titleBackground.b, colors.titleBackground.a)
DrawText("MACHO MENU", menu.x - 0.095, menu.y - 0.015, 1, 0.7, colors.titleText)
-- Menü seçeneklerini döngüye al ve çizdir
for i, option in ipairs(menu.options) do
local currentY = menu.y + menu.titleHeight + (i - 1) * menu.height
-- Arka planı çiz
DrawRect(menu.x, currentY, menu.width, menu.height, colors.background.r, colors.background.g, colors.background.b, colors.background.a)
-- Eğer seçenek o an seçili ise, farklı bir arka plan çiz
if i == menu.selectedIndex then
DrawRect(menu.x, currentY, menu.width, menu.height, colors.selectedBackground.r, colors.selectedBackground.g, colors.selectedBackground.b, colors.selectedBackground.a)
end
-- Seçenek metnini çiz
DrawText(option.label, menu.x - 0.09, currentY - 0.012, 0, 0.4, colors.text)
end
-- Menü Kontrolleri
-- Yukarı gitme
if IsControlJustReleased(0, 172) then -- Yukarı Ok Tuşu
if menu.selectedIndex > 1 then
menu.selectedIndex = menu.selectedIndex - 1
else
menu.selectedIndex = #menu.options -- En sona git
end
end
-- Aşağı gitme
if IsControlJustReleased(0, 173) then -- Aşağı Ok Tuşu
if menu.selectedIndex < #menu.options then
menu.selectedIndex = menu.selectedIndex + 1
else
menu.selectedIndex = 1 -- En başa dön
end
end
-- Seçeneği aktifleştirme
if IsControlJustReleased(0, 176) then -- Enter Tuşu
if menu.options[menu.selectedIndex].action then
menu.options[menu.selectedIndex].action()
end
end
::continue::
end
end)