require "lib.moonloader"
local keys = require "vkeys"
local imgui = require "imgui"
local encoding = require "encoding"
local memory = require "memory"
encoding.default = "CP1251"
u8 = encoding.UTF8
local sampev = require 'lib.samp.events'
local themes = import "resource/imgui_themes.lua"
local tag = "[admin tools script]: "
local main_window_state = imgui.ImBool(false)
local text_buffer = imgui.ImBuffer(256)
local pages = {
{
name = "1 вкладка", render = function()
imgui.Text("вкладка номер один")
end
},
{
name = "2 вкладка", render = function()
imgui.Button("кнопка во второй вкладке")
end
}
}
local currentPage = 1
function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end
while not isSampAvailable() do wait(100) end
sampAddChatMessage(tag .. "{FFFFFF}успешно загружен!", 0xB23AD4)
sampRegisterChatCommand("cmenu", cmd_cmenu)
imgui.Process = false
imgui.SwitchContext()
themes.SwitchColorTheme(8)
while true do
wait(0)
if main_window_state.v == false then
imgui.Process = false
end
_, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
nick = sampGetPlayerNickname(id)
fps = memory.getfloat(0xB7CB50, true)
if isKeyJustPressed(VK_DELETE) then
sampAddChatMessage(tag .. "{FFFFFF}Ваш ID: " .. id, 0xB23AD4)
sampAddChatMessage(tag .. "{FFFFFF}Ваш NickName: " .. nick, 0xB23AD4)
sampAddChatMessage(tag .. "{FFFFFF}Ваш Fps: " .. fps, 0xB23AD4)
end
end
end
function cmd_cmenu(arg)
main_window_state.v = not main_window_state.v
imgui.Process = main_window_state.v
end
function imgui.OnDrawFrame()
local X, Y = getScreenResolution()
imgui.SetNextWindowSize(imgui.ImVec2(630, 320), imgui.Cond.FirstUseEver)
imgui.SetNextWindowPos(imgui.ImVec2(X / 2, Y / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
imgui.Begin("Admin Tools", main_window_state)
for i, page in ipairs(pages) do
if imgui.Button(page.name) then currentPage = i end
if (i ~= #pages) then imgui.SameLine() end -- для того, чтобы все кнопки со вкладками отображались горизонтально
pages[currentPage]:render()
imgui.End()
end