local imgui = require('mimgui')
local ffi = require('ffi')
local window = imgui.new.bool(false)
local buff = imgui.new.char[4096]('')
imgui.OnInitialize(function()
imgui.GetStyle().WindowPadding = imgui.ImVec2(5, 5)
end)
local frame = imgui.OnFrame(
function() return window[0] end,
function(this)
local size, res = imgui.ImVec2(300, 300), imgui.ImVec2(getScreenResolution())
imgui.SetNextWindowPos(imgui.ImVec2(res.x / 2, res.y / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
imgui.SetNextWindowSize(size, imgui.Cond.FirstUseEver)
if imgui.Begin('run code', window) then
local size = imgui.GetWindowSize()
imgui.InputTextMultiline('##code', buff, ffi.sizeof(buff), imgui.ImVec2(size.x - 10, size.y - imgui.GetCursorPosY() - 5 - 24 - 5))
if imgui.Button('RUN', imgui.ImVec2(size.x - 10, 24)) then
local status, result = pcall(loadstring(ffi.string(buff)))
sampAddChatMessage(status and 'Done!' or 'Error running code: '..result, status and 0xFF00ff00 or 0xFFff0000)
end
imgui.End()
end
end
)
function main()
while not isSampAvailable() do wait(0) end
sampRegisterChatCommand('runlua', function()
window[0] = not window[0]
end)
wait(-1)
end