local imgui = require 'imgui'
imgui.ToggleButton = require('imgui_addons').ToggleButton
local encoding = require("encoding")
encoding.default = 'CP1251'
u8 = encoding.UTF8
local imBool = imgui.ImBool(false)
local window = imgui.ImBool(false)
function main()
if not isSampLoaded() then
return
end
while not isSampAvailable() do
wait(0)
end
_, id = sampGetPlayerIdByCharHandle(PLAYER_PED) -- в начало кода
nick = sampGetPlayerNickname(id) ---- в начало кода
score = sampGetPlayerScore(id) -- тоже в начало
sampRegisterChatCommand("test", function ()
window.v = not window.v
imgui.Process = window.v
end)
while true do
wait(0)
end
end
function imgui.OnDrawFrame()
local iScreenWidth, iScreenHeight = getScreenResolution()
local tLastKeys = {}
imgui.SetNextWindowPos(imgui.ImVec2(iScreenWidth / 2, iScreenHeight / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
imgui.SetNextWindowSize(imgui.ImVec2(400, 200), imgui.Cond.FirstUseEver)
imgui.Begin("Test Window", window)
imgui.Text(u8'Показывать информацию: ')
imgui.SameLine()
if imgui.ToggleButton("##1", imBool) then--записываем данные в ImBool переменную
sampAddChatMessage("Вы переключили статус, новое значение: " .. tostring(imBool.v), -1)
end
if imBool.v then--если кнопка равняется true
if nick and id and score then--проверяем, если все значения не равняются nil
imgui.Text(u8'Ваш ник: '..nick..'['..id..']')--не знаю зачем ты поставил там кавычки
imgui.Text(u8'Ваш ID: '..score)
end
else--если imBool.v не равняется true
--твой код
end
imgui.End()
end