не работает имгуи

parkinson

Участник
Автор темы
33
1
Версия MoonLoader
Другое
1608204738085.png

хз чё не так, при открытии имгуи скрипт крашит, код ошибки
C:\Games\ARIZONA GAMES\bin\Arizona\moonloader\arzh.lua:72: in function 'OnDrawFrame'
C:\Games\ARIZONA GAMES\bin\Arizona\moonloader\lib\imgui.lua:1378: in function <C:\Games\ARIZONA GAMES\bin\Arizona\moonloader\lib\imgui.lua:1367>
[16:28:18.397206] (error) arzh.lua: Script died due to an error. (22DA916C)
 
Решение
Lua:
local keys = require "vkeys"
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local moonloader = require('moonloader')

local tag = '[My First Script]:'
local label = 0
local main_color = 0x5A90CE
local main_color_text = "{5A90CE}"
local white_color = "{FFFFFF}"
local main_window_state = imgui.ImBool(false)
arrSelectable = {false, false}
local text_buffer = imgui.ImBuffer(256)

function main()
  if not isSampLoaded() or not isSampfuncsLoaded() then return end
  while not isSampAvailable() do wait(100)
  end
  wait(3000)
  sampAddChatMessage("Arizona State Helper v.1.0", 0xADFF2F)
  sampRegisterChatCommand("gh", function() main_window_state.v = not main_window_state.v...

parkinson

Участник
Автор темы
33
1
Lua:
local keys = require "vkeys"
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local moonloader = require('moonloader')

local tag = '[My First Script]:' -- ��������� ����������
local label = 0
local main_color = 0x5A90CE
local main_color_text = "{5A90CE}"
local white_color = "{FFFFFF}"
local main_window_state = imgui.ImBool(false)
arrSelectable = {false, false}
local text_buffer = imgui.ImBuffer(256)

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100)
    end
    wait(3000)
    sampAddChatMessage("Arizona State Helper v.1.0", 0xADFF2F)

    
    sampRegisterChatCommand("gh", cmd_imgui)
 
    _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
    nick = sampGetPlayerNickname(id)
 
    imgui.Process = false
 
    while true do
    wait(0)
 
    if main_window_state.v == false then
        imgui.Process = false
    end
    
    if isKeyJustPressed(VK_F3) then
    sampAddChatMessage("�� ������ ������� {FFFFFF}F3. " ..main_color_text .. "��� ���: {FFFFFF}" .. nick .. ", " .. main_color_text .. "��� ID: {FFFFFF}" .. id, main_color)
    end
 
    if isKeyDown(VK_L) and isKeyJustPressed(VK_L) then
    sampSendChat('/lock')
    end
    
    if isKeyDown(VK_K) and isKeyJustPressed(VK_K) then
    sampSendChat('/key')
    end

end
end

function cmd_imgui(arg)
    main_window_state.v = not main_window_state.v
    imgui.Process = main_window_state.v
end

function imgui.OnDrawFrame()

if not main_window_state.v then
    imgui.Process = false
end

if main_window_state.v then
        local sw, sh = getScreenResolution()
        imgui.SetNextWindowSize(imgui.ImVec2(500, 300), imgui.Cond.FirstUseEver)
        imgui.SetNextWindowPos(imgui.ImVec2((sw / 2), sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))

        imgui.Begin('State Tools Helper', main_window_state, imgui.WindowFlags.NoResize)

            imgui.TextColoredRGB(u8"{F4A460}Добро пожаловать в State Helper", 2);
        
            imgui.BeginChild("ChildWindow22", imgui.ImVec2(300, 150), true)
        
                imgui.Text("111")
        
            imgui.EndChild()
        imgui.End()
    end
end
1. Код принято скидывать текстом, а не скриншотами.
2. Говорят, если правильно расставлять табуляцию, ошибки находятся сами собой
 

Albertio

Attention! Thanks for your attention.
887
717
Lua:
local keys = require "vkeys"
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local moonloader = require('moonloader')

local tag = '[My First Script]:'
local label = 0
local main_color = 0x5A90CE
local main_color_text = "{5A90CE}"
local white_color = "{FFFFFF}"
local main_window_state = imgui.ImBool(false)
arrSelectable = {false, false}
local text_buffer = imgui.ImBuffer(256)

function main()
  if not isSampLoaded() or not isSampfuncsLoaded() then return end
  while not isSampAvailable() do wait(100)
  end
  wait(3000)
  sampAddChatMessage("Arizona State Helper v.1.0", 0xADFF2F)
  sampRegisterChatCommand("gh", function() main_window_state.v = not main_window_state.v end)
  _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
  nick = sampGetPlayerNickname(id)
  imgui.Process = false
  while true do
    wait(0)
    if main_window_state.v == false then
      imgui.Process = false
    end
    if isKeyJustPressed(VK_F3) then
      sampAddChatMessage("   {FFFFFF}F3. " ..main_color_text .. " : {FFFFFF}" .. nick .. ", " .. main_color_text .. " ID: {FFFFFF}" .. id, main_color)
    end
    if isKeyDown(VK_L) and isKeyJustPressed(VK_L) then
      sampSendChat('/lock')
    end
    if isKeyDown(VK_K) and isKeyJustPressed(VK_K) then
      sampSendChat('/key')
    end
    imgui.Process = main_window_state.v
    if not main_window_state.v then
      imgui.Process = false
    end
  end
end

function imgui.OnDrawFrame()
  if main_window_state.v then
    imgui.SetNextWindowPos(imgui.ImVec2(imgui.GetIO().DisplaySize.x / 2, imgui.GetIO().DisplaySize.y / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
    imgui.SetNextWindowSize(imgui.ImVec2(267, 235), imgui.Cond.FirstUseEver)
    imgui.Begin('State Tools Helper', main_window_state, imgui.WindowFlags.NoResize)
    imgui.TextColoredRGB(u8"{F4A460}Добро пожаловать в State Helper")
    imgui.BeginChild("ChildWindow22", imgui.ImVec2(300, 150), true)
    imgui.Text("111")
    imgui.EndChild()
    imgui.End()
  end
end

function imgui.TextColoredRGB(text)
  local style = imgui.GetStyle()
  local colors = style.Colors
  local ImVec4 = imgui.ImVec4
  local explode_argb = function(argb)
    local a = bit.band(bit.rshift(argb, 24), 0xFF)
    local r = bit.band(bit.rshift(argb, 16), 0xFF)
    local g = bit.band(bit.rshift(argb, 8), 0xFF)
    local b = bit.band(argb, 0xFF)
    return a, r, g, b
  end
  local getcolor = function(color)
    if color:sub(1, 6):upper() == 'SSSSSS' then
      local r, g, b = colors[1].x, colors[1].y, colors[1].z
      local a = tonumber(color:sub(7, 8), 16) or colors[1].w * 255
      return ImVec4(r, g, b, a / 255)
    end
    local color = type(color) == 'string' and tonumber(color, 16) or color
    if type(color) ~= 'number' then return end
    local r, g, b, a = explode_argb(color)
    return imgui.ImColor(r, g, b, a):GetVec4()
  end
  local render_text = function(text_)
    for w in text_:gmatch('[^\r\n]+') do
      local text, colors_, m = {}, {}, 1
      w = w:gsub('{(......)}', '{%1FF}')
      while w:find('{........}') do
        local n, k = w:find('{........}')
        local color = getcolor(w:sub(n + 1, k - 1))
        if color then
          text[#text], text[#text + 1] = w:sub(m, n - 1), w:sub(k + 1, #w)
          colors_[#colors_ + 1] = color
          m = n
        end
        w = w:sub(1, n - 1) .. w:sub(k + 1, #w)
      end
      if text[0] then
        for i = 0, #text do
          imgui.TextColored(colors_[i] or colors[1], text[i])
          imgui.SameLine(nil, 0)
        end
        imgui.NewLine()
      else imgui.Text(w) end
    end
  end
  render_text(text)
end
 
  • Нравится
Реакции: Smeruxa

Похожие темы

  1. Ответы
    7
    Просмотры
    2K
    Помощь
    deleted-user-224036
    D