skszikri
Member
- Joined
- Apr 20, 2023
- Messages
- 18
- Reaction score
- 1
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
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