local key_log = {}
key_log.state = imgui.ImBool(true)
key_log.syncType = "onFoot" -- \\ also "inCar" and "passenger"
key_log.joystick = {
old = { x = 0, y = 0 },
new = { x = 0, y = 0 },
timer = -1
}
function ev.onPlayerSync(playerId, data)
if key_log.state.v and playerId == SPEC.playerId then
for key, v in pairs(key_log.keys) do
local X, Y = data.leftRightKeys, data.upDownKeys
if os.clock() - key_log.joystick.timer > 0.1 then
key_log.joystick.timer = os.clock()
key_log.joystick.old.x = key_log.joystick.new.x
key_log.joystick.old.y = key_log.joystick.new.y
key_log.joystick.new.x = X == nil and 0 or (X > 128 and X - 0xFFFF or X)
key_log.joystick.new.y = Y == nil and 0 or (Y > 128 and Y - 0xFFFF or Y)
end
-- \\ Another keys..
end
end
end
do -- \\ OnFrame
imgui.Begin("##KeysLogger", _, 1 + 8 + 64 + 4096 + 8192)
if not sampGetCharHandleBySampPlayerId(SPEC.playerId) then
imgui.TextDisabled(u8"Поиск игрока...")
else
if key_log.syncType ~= "passenger" then
if SPEC.client == "mobile" then
imgui.AddCursorPos(5, 0)
imgui.Dummy(imgui.ImVec2(65, 65))
local DL = imgui.GetWindowDrawList()
local ip = imgui.GetItemRectMin()
local radius_1 = 30
local radius_2 = 10
local c = imgui.ImVec2(ip.x + 65/2, ip.y + 65/2)
local col = imgui.GetStyle().Colors[imgui.Col.ButtonActive]
local bg_col = imgui.ColorConvertFloat4ToU32(imgui.ImVec4(col.x, col.y, col.z, 0.30))
local it_col = imgui.ColorConvertFloat4ToU32(imgui.ImVec4(col.x, col.y, col.z, col.w))
DL:AddCircleFilled(c, radius_1, bg_col, 48)
DL:AddCircle(c, radius_1, it_col, 48, 1)
local oX_old = (key_log.joystick.old.x / 100) * (radius_1 - radius_2 / 2)
local oX_new = (key_log.joystick.new.x / 100) * (radius_1 - radius_2 / 2)
local oY_old = (key_log.joystick.old.y / 100) * (radius_1 - radius_2 / 2)
local oY_new = (key_log.joystick.new.y / 100) * (radius_1 - radius_2 / 2)
local oX = bringFloatTo(oX_old, oX_new, key_log.joystick.timer, 0.1)
local oY = bringFloatTo(oY_old, oY_new, key_log.joystick.timer, 0.1)
DL:AddCircleFilled(imgui.ImVec2(c.x + oX, c.y + oY), radius_2, it_col, 16)
else
imgui.BeginGroup()
imgui.SetCursorPosX(10 + 30 + 5)
KeyRender("W", imgui.ImVec2(30, 30))
KeyRender("A", imgui.ImVec2(30, 30)); imgui.SameLine()
KeyRender("S", imgui.ImVec2(30, 30)); imgui.SameLine()
KeyRender("D", imgui.ImVec2(30, 30))
imgui.EndGroup()
end
end
-- \\ Another keys..
end
imgui.End()
end