RPC

Lucengen

Участник
Автор темы
52
0
Нужно, чтобы при нажатии на чекбокс включался рпс, как правильно это сделать?
Lua:
if imgui.CollapsingHeader('RPC') then
  if imgui.Checkbox('SetPlayerName', SetPlayerName) then -- 1
    if SetPlayerName.v then
  end
end
 

James Hawk

Известный
919
217
Нужно, чтобы при нажатии на чекбокс включался рпс, как правильно это сделать?
Lua:
if imgui.CollapsingHeader('RPC') then
  if imgui.Checkbox('SetPlayerName', SetPlayerName) then -- 1
    if SetPlayerName.v then
  end
end
Ну ты уже всё прописал. Дальше что тебе нужно сделать пиши
 
  • Нравится
Реакции: Lucengen

Lucengen

Участник
Автор темы
52
0
Как только я ввожу команду для открытия имгуи окна происходит краш

Lua:
function imgui.OnDrawFrame()
local sW, sH = getScreenResolution()
if main_window_state.v then
imgui.SetNextWindowSize(imgui.ImVec2(235, 350), imgui.Cond.FirstUseEver) -- размер
imgui.SetNextWindowPos(imgui.ImVec2(sW / 2 ,sH / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
imgui.Begin("RPC", main_window_state)
if imgui.CollapsingHeader('RPC') then
if imgui.Checkbox('SetPlayerName', SetPlayerName) then -- 1
if SetPlayerName.v then
--sampAddChatMessage(Test.v and "+" or "-", -1)
end
end
imgui.End()
end
end
end
 

James Hawk

Известный
919
217
Как только я ввожу команду для открытия имгуи окна происходит краш

Lua:
function imgui.OnDrawFrame()
local sW, sH = getScreenResolution()
if main_window_state.v then
imgui.SetNextWindowSize(imgui.ImVec2(235, 350), imgui.Cond.FirstUseEver) -- размер
imgui.SetNextWindowPos(imgui.ImVec2(sW / 2 ,sH / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
imgui.Begin("RPC", main_window_state)
if imgui.CollapsingHeader('RPC') then
if imgui.Checkbox('SetPlayerName', SetPlayerName) then -- 1
if SetPlayerName.v then
--sampAddChatMessage(Test.v and "+" or "-", -1)
end
end
imgui.End()
end
end
end
Для читабельности кода придумали табуляцию. Если бы пользовался табуляцией нормально, ошибку бы легко было увидеть
Lua:
function imgui.OnDrawFrame()
    local sW, sH = getScreenResolution()
    if main_window_state.v then
        imgui.SetNextWindowSize(imgui.ImVec2(235, 350), imgui.Cond.FirstUseEver) -- размер
        imgui.SetNextWindowPos(imgui.ImVec2(sW / 2 ,sH / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.Begin("RPC", main_window_state)
        if imgui.CollapsingHeader('RPC') then
            if imgui.Checkbox('SetPlayerName', SetPlayerName) then -- 1
                if SetPlayerName.v then
                --sampAddChatMessage(Test.v and "+" or "-", -1)
                end
            end
        end
        imgui.End()
    end
end
 
  • Нравится
Реакции: Lucengen

Lucengen

Участник
Автор темы
52
0
Для читабельности кода придумали табуляцию. Если бы пользовался табуляцией нормально, ошибку бы легко было увидеть
Lua:
function imgui.OnDrawFrame()
    local sW, sH = getScreenResolution()
    if main_window_state.v then
        imgui.SetNextWindowSize(imgui.ImVec2(235, 350), imgui.Cond.FirstUseEver) -- размер
        imgui.SetNextWindowPos(imgui.ImVec2(sW / 2 ,sH / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.Begin("RPC", main_window_state)
        if imgui.CollapsingHeader('RPC') then
            if imgui.Checkbox('SetPlayerName', SetPlayerName) then -- 1
                if SetPlayerName.v then
                --sampAddChatMessage(Test.v and "+" or "-", -1)
                end
            end
        end
        imgui.End()
    end
end
Окно открывается, но теперь как только жму на "RPC" опять краш
 

Lucengen

Участник
Автор темы
52
0
Lua:
require "lib.moonloader"
local sampev = require "lib.samp.events"
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

imgui.SwitchContext() -- цвет (стиль имгуи)
local style = imgui.GetStyle()
local colors = style.Colors
local clr = imgui.Col
local ImVec4 = imgui.ImVec4
local w, h = getScreenResolution()
colors[clr.Text] = ImVec4(1.00, 1.00, 1.00, 1.00)
colors[clr.TextDisabled] = ImVec4(0.60, 0.60, 0.60, 1.00)
colors[clr.WindowBg] = ImVec4(0.11, 0.10, 0.11, 1.00)
colors[clr.ChildWindowBg] = ImVec4(0.00, 0.00, 0.00, 0.00)
colors[clr.PopupBg] = ImVec4(0.00, 0.00, 0.00, 0.00)
colors[clr.Border] = ImVec4(0.86, 0.86, 0.86, 1.00)
colors[clr.BorderShadow] = ImVec4(0.00, 0.00, 0.00, 0.00)
colors[clr.FrameBg] = ImVec4(0.21, 0.20, 0.21, 0.60)
colors[clr.FrameBgHovered] = ImVec4(0.00, 0.46, 0.65, 1.00)
colors[clr.FrameBgActive] = ImVec4(0.00, 0.46, 0.65, 1.00)
colors[clr.TitleBg] = ImVec4(0.00, 0.46, 0.65, 1.00)
colors[clr.TitleBgCollapsed] = ImVec4(0.00, 0.46, 0.65, 1.00)
colors[clr.TitleBgActive] = ImVec4(0.00, 0.46, 0.65, 1.00)
colors[clr.MenuBarBg] = ImVec4(0.00, 0.46, 0.65, 1.00)
colors[clr.ScrollbarBg] = ImVec4(0.00, 0.46, 0.65, 0.00)
colors[clr.ScrollbarGrab] = ImVec4(0.00, 0.46, 0.65, 0.44)
colors[clr.ScrollbarGrabHovered] = ImVec4(0.00, 0.46, 0.65, 0.74)
colors[clr.ScrollbarGrabActive] = ImVec4(0.00, 0.46, 0.65, 1.00)
colors[clr.ComboBg] = ImVec4(0.15, 0.14, 0.15, 1.00)
colors[clr.CheckMark] = ImVec4(0.00, 0.46, 0.65, 1.00)
colors[clr.SliderGrab] = ImVec4(0.00, 0.46, 0.65, 1.00)
colors[clr.SliderGrabActive] = ImVec4(0.00, 0.46, 0.65, 1.00)
colors[clr.Button] = ImVec4(0.13, 0.55, 0.13, 0.75)
colors[clr.Header] = ImVec4(0.00, 0.46, 0.65, 1.00)
colors[clr.HeaderHovered] = ImVec4(0.00, 0.46, 0.65, 1.00)
colors[clr.HeaderActive] = ImVec4(0.00, 0.46, 0.65, 1.00)
colors[clr.ResizeGrip] = ImVec4(1.00, 1.00, 1.00, 0.30)
colors[clr.ResizeGripHovered] = ImVec4(1.00, 1.00, 1.00, 0.60)
colors[clr.ResizeGripActive] = ImVec4(1.00, 1.00, 1.00, 0.90)
colors[clr.PlotLines] = ImVec4(0.00, 0.00, 0.00, 0.00)
colors[clr.PlotLinesHovered] = ImVec4(0.00, 0.00, 0.00, 0.00)
colors[clr.PlotHistogram] = ImVec4(0.00, 0.00, 0.00, 0.00)
colors[clr.PlotHistogramHovered] = ImVec4(0.00, 0.00, 0.00, 0.00)
colors[clr.TextSelectedBg] = ImVec4(0.00, 0.00, 0.00, 0.00)
colors[clr.ModalWindowDarkening] = ImVec4(0.00, 0.00, 0.00, 0.00)

local main_window_state = imgui.ImBool(false)
Test = imgui.ImBool(false)

local SetPlayerName = imgui.ImBool(false)


function main()
  while not isSampAvailable() do wait(100) end
  sampRegisterChatCommand('rpc', cmd_rpc)
  wait(-1)
end

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

function imgui.OnDrawFrame()
  local sW, sH = getScreenResolution()
    if main_window_state.v then
      imgui.SetNextWindowSize(imgui.ImVec2(235, 350), imgui.Cond.FirstUseEver) -- размер
      imgui.SetNextWindowPos(imgui.ImVec2(sW / 2 ,sH / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
      imgui.Begin("RPC", main_window_state)
      if imgui.CollapsingHeader('RPC') then
        if imgui.Checkbox('SetPlayerName', SetPlayerName) then -- 1
          if SetPlayerName.v then
        end
      end
    end
    imgui.End()
  end
end
При активации чекбокса ноп не работает
 

James Hawk

Известный
919
217
Lua:
require "lib.moonloader"
local sampev = require "lib.samp.events"
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

imgui.SwitchContext() -- цвет (стиль имгуи)
local style = imgui.GetStyle()
local colors = style.Colors
local clr = imgui.Col
local ImVec4 = imgui.ImVec4
local w, h = getScreenResolution()
colors[clr.Text] = ImVec4(1.00, 1.00, 1.00, 1.00)
colors[clr.TextDisabled] = ImVec4(0.60, 0.60, 0.60, 1.00)
colors[clr.WindowBg] = ImVec4(0.11, 0.10, 0.11, 1.00)
colors[clr.ChildWindowBg] = ImVec4(0.00, 0.00, 0.00, 0.00)
colors[clr.PopupBg] = ImVec4(0.00, 0.00, 0.00, 0.00)
colors[clr.Border] = ImVec4(0.86, 0.86, 0.86, 1.00)
colors[clr.BorderShadow] = ImVec4(0.00, 0.00, 0.00, 0.00)
colors[clr.FrameBg] = ImVec4(0.21, 0.20, 0.21, 0.60)
colors[clr.FrameBgHovered] = ImVec4(0.00, 0.46, 0.65, 1.00)
colors[clr.FrameBgActive] = ImVec4(0.00, 0.46, 0.65, 1.00)
colors[clr.TitleBg] = ImVec4(0.00, 0.46, 0.65, 1.00)
colors[clr.TitleBgCollapsed] = ImVec4(0.00, 0.46, 0.65, 1.00)
colors[clr.TitleBgActive] = ImVec4(0.00, 0.46, 0.65, 1.00)
colors[clr.MenuBarBg] = ImVec4(0.00, 0.46, 0.65, 1.00)
colors[clr.ScrollbarBg] = ImVec4(0.00, 0.46, 0.65, 0.00)
colors[clr.ScrollbarGrab] = ImVec4(0.00, 0.46, 0.65, 0.44)
colors[clr.ScrollbarGrabHovered] = ImVec4(0.00, 0.46, 0.65, 0.74)
colors[clr.ScrollbarGrabActive] = ImVec4(0.00, 0.46, 0.65, 1.00)
colors[clr.ComboBg] = ImVec4(0.15, 0.14, 0.15, 1.00)
colors[clr.CheckMark] = ImVec4(0.00, 0.46, 0.65, 1.00)
colors[clr.SliderGrab] = ImVec4(0.00, 0.46, 0.65, 1.00)
colors[clr.SliderGrabActive] = ImVec4(0.00, 0.46, 0.65, 1.00)
colors[clr.Button] = ImVec4(0.13, 0.55, 0.13, 0.75)
colors[clr.Header] = ImVec4(0.00, 0.46, 0.65, 1.00)
colors[clr.HeaderHovered] = ImVec4(0.00, 0.46, 0.65, 1.00)
colors[clr.HeaderActive] = ImVec4(0.00, 0.46, 0.65, 1.00)
colors[clr.ResizeGrip] = ImVec4(1.00, 1.00, 1.00, 0.30)
colors[clr.ResizeGripHovered] = ImVec4(1.00, 1.00, 1.00, 0.60)
colors[clr.ResizeGripActive] = ImVec4(1.00, 1.00, 1.00, 0.90)
colors[clr.PlotLines] = ImVec4(0.00, 0.00, 0.00, 0.00)
colors[clr.PlotLinesHovered] = ImVec4(0.00, 0.00, 0.00, 0.00)
colors[clr.PlotHistogram] = ImVec4(0.00, 0.00, 0.00, 0.00)
colors[clr.PlotHistogramHovered] = ImVec4(0.00, 0.00, 0.00, 0.00)
colors[clr.TextSelectedBg] = ImVec4(0.00, 0.00, 0.00, 0.00)
colors[clr.ModalWindowDarkening] = ImVec4(0.00, 0.00, 0.00, 0.00)

local main_window_state = imgui.ImBool(false)
Test = imgui.ImBool(false)

local SetPlayerName = imgui.ImBool(false)


function main()
  while not isSampAvailable() do wait(100) end
  sampRegisterChatCommand('rpc', cmd_rpc)
  wait(-1)
end

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

function imgui.OnDrawFrame()
  local sW, sH = getScreenResolution()
    if main_window_state.v then
      imgui.SetNextWindowSize(imgui.ImVec2(235, 350), imgui.Cond.FirstUseEver) -- размер
      imgui.SetNextWindowPos(imgui.ImVec2(sW / 2 ,sH / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
      imgui.Begin("RPC", main_window_state)
      if imgui.CollapsingHeader('RPC') then
        if imgui.Checkbox('SetPlayerName', SetPlayerName) then -- 1
          if SetPlayerName.v then
        end
      end
    end
    imgui.End()
  end
end
При активации чекбокса ноп не работает
А ты где-то ноп прописал?
 
  • Нравится
Реакции: Lucengen

Lucengen

Участник
Автор темы
52
0

Akionka

akionka.lua
Проверенный
742
500
Последнее редактирование:
  • Нравится
Реакции: Lucengen