Help Lua Help Keybinder

skszikri

New member
Joined
Apr 20, 2023
Messages
3
Reaction score
0
soo this is my script for keybind using imgui in lua, but it wont work in game, even I press "K", When I delete function events.onServerMessage, it work perfectly but I cant costum keybind in game
here is

local imgui = require 'imgui'
local key = require 'vkeys'
local sampev = require 'samp.events'

local window_state = imgui.ImBool(false)
local input_text_buffer = imgui.ImBuffer(256)
local input_text_buffer2 = imgui.ImBuffer(256)

function imgui.OnDrawFrame()
if window_state.v then
imgui.SetNextWindowSize(imgui.ImVec2(400, 150), imgui.Cond.FirstUseEver)
imgui.Begin('Window', window_state)

imgui.Text('Input1:')
if imgui.InputText('##InputText1', input_text_buffer) then
print('Input1:', input_text_buffer.v)
end

imgui.Text('Input2:')
if imgui.InputText('##InputText2', input_text_buffer2) then
print('Input2:', input_text_buffer2.v)
end

local s = input_text_buffer.v
local a = input_text_buffer2.v

if onServerMessage(color, text) then
if text:find(s) then
sampSendChat(string.format('%a ', a))
end
end

imgui.End()
end
end

function main()
while true do
wait(0)

if wasKeyPressed(key.VK_K) then
window_state.v = not window_state.v
end

imgui.Process = window_state.v
end
end
 

skszikri

New member
Joined
Apr 20, 2023
Messages
3
Reaction score
0
source code
soo this is my script for keybind using imgui in lua, but it wont work in game, even I press "K", When I delete function events.onServerMessage, it work perfectly but I cant costum keybind in game
here is

local imgui = require 'imgui'
local key = require 'vkeys'
local sampev = require 'samp.events'

local window_state = imgui.ImBool(false)
local input_text_buffer = imgui.ImBuffer(256)
local input_text_buffer2 = imgui.ImBuffer(256)

function imgui.OnDrawFrame()
if window_state.v then
imgui.SetNextWindowSize(imgui.ImVec2(400, 150), imgui.Cond.FirstUseEver)
imgui.Begin('Window', window_state)

imgui.Text('Input1:')
if imgui.InputText('##InputText1', input_text_buffer) then
print('Input1:', input_text_buffer.v)
end

imgui.Text('Input2:')
if imgui.InputText('##InputText2', input_text_buffer2) then
print('Input2:', input_text_buffer2.v)
end

local s = input_text_buffer.v
local a = input_text_buffer2.v

if onServerMessage(color, text) then
if text:find(s) then
sampSendChat(string.format('%a ', a))
end
end

imgui.End()
end
end

function main()
while true do
wait(0)

if wasKeyPressed(key.VK_K) then
window_state.v = not window_state.v
end

imgui.Process = window_state.v
end
end
 

Attachments

  • moon-imgui-1.1.5.zip
    1,000.8 KB · Views: 4
  • samp-lua-v2.3.0.zip
    18 KB · Views: 3

Tuzas

Active member
Joined
Nov 1, 2019
Messages
120
Reaction score
67
Location
null
JavaScript:
local imgui = require 'imgui'
local key = require 'vkeys'
local sampev = require 'samp.events'

local window_state = imgui.ImBool(false)
local input_text_buffer = imgui.ImBuffer(256)
local input_text_buffer2 = imgui.ImBuffer(256)

local s = ''
local a = ''

function imgui.OnDrawFrame()
    if window_state.v then
        imgui.SetNextWindowSize(imgui.ImVec2(400, 150), imgui.Cond.FirstUseEver)
        imgui.Begin('Window', window_state)

        imgui.Text('Input1:')
        imgui.InputText('##InputText1', input_text_buffer)

        imgui.Text('Input2:')
        imgui.InputText('##InputText2', input_text_buffer2)

        if input_text_buffer.v and input_text_buffer2.v ~= '' then
            print('Input1:', input_text_buffer.v)
            print('Input2:', input_text_buffer2.v)

            s = input_text_buffer.v
            a = input_text_buffer2.v
        end

        imgui.End()
    end
end

function main()
    while true do
        wait(0)

        if wasKeyPressed(key.VK_K) then
            window_state.v = not window_state.v
        end

        imgui.Process = window_state.v
    end
end

function sampev.onServerMessage(color, text)
    if text:find(s) then
        sampSendChat(string.format('%a ', a))
    end
end
 
Top