local imgui = require 'mimgui'
local widget = require 'widgets'
local inicfg = require "inicfg"
local ini = inicfg.load({
cfg = {
showImages = true,
imageX = 200,
imageY = 200,
imageSizeX = 851,
imageSizeY = 409
}
}, "Vkey.ini")
local WinState1 = imgui.new.bool(true)
local WinState2 = imgui.new.bool(false)
local showImages = imgui.new.bool(ini.cfg.showImages)
local wImagePositions = {
x = imgui.new.int(ini.cfg.imageX),
y = imgui.new.int(ini.cfg.imageY),
sizeX = imgui.new.int(ini.cfg.imageSizeX),
sizeY = imgui.new.int(ini.cfg.imageSizeY)
}
local wTextureLoaded = false
local wTexture
local wDuplicateTextureLoaded = false
local wDuplicateTexture
local wDuplicateTextureLoadedA = false
local wDuplicateTextureA
local wDuplicateTextureLoadedS = false
local wDuplicateTextureS
local wDuplicateTextureLoadedSpa = false
local wDuplicateTextureSpa
local wDuplicateTextureLoadedD = false
local wDuplicateTextureD
local wDuplicateTextureLoadedF = false
local wDuplicateTextureF
local wImageVisible = false
local wImageVisibleA = false
local wImageVisibleS = false
local wImageVisibleSpa = false
local wImageVisibleD = false
local scaleFactor = imgui.new.float(1.0)
function renderImages()
if wTextureLoaded then
renderDrawTexture(wTexture, wImagePositions.x[0], wImagePositions.y[0], wImagePositions.sizeX[0], wImagePositions.sizeY[0], 0, 0xFFFFFFFF)
end
if wDuplicateTextureLoaded and wImageVisible then
renderDrawTexture(wDuplicateTexture, wImagePositions.x[0], wImagePositions.y[0], wImagePositions.sizeX[0], wImagePositions.sizeY[0], 0, 0xFFFFFFFF)
end
if wDuplicateTextureLoadedA and wImageVisibleA then
renderDrawTexture(wDuplicateTextureA, wImagePositions.x[0], wImagePositions.y[0], wImagePositions.sizeX[0], wImagePositions.sizeY[0], 0, 0xFFFFFFFF)
end
if wDuplicateTextureLoadedS and wImageVisibleS then
renderDrawTexture(wDuplicateTextureS, wImagePositions.x[0], wImagePositions.y[0], wImagePositions.sizeX[0], wImagePositions.sizeY[0], 0, 0xFFFFFFFF)
end
if wDuplicateTextureLoadedSpa and wImageVisibleSpa then
renderDrawTexture(wDuplicateTextureSpa, wImagePositions.x[0], wImagePositions.y[0], wImagePositions.sizeX[0], wImagePositions.sizeY[0], 0, 0xFFFFFFFF)
end
if wDuplicateTextureLoadedF and wImageVisibleF then
renderDrawTexture(wDuplicateTextureF, wImagePositions.x[0], wImagePositions.y[0], wImagePositions.sizeX[0], wImagePositions.sizeY[0], 0, 0xFFFFFFFF)
end
if wDuplicateTextureLoadedD and wImageVisibleD then
renderDrawTexture(wDuplicateTextureD, wImagePositions.x[0], wImagePositions.y[0], wImagePositions.sizeX[0], wImagePositions.sizeY[0], 0, 0xFFFFFFFF)
end
end
function loadTextures()
if not wTextureLoaded then
wTexture = renderLoadTextureFromFile("resource/Vkeys/1.png")
wTextureLoaded = true
end
if not wDuplicateTextureLoaded then
wDuplicateTexture = renderLoadTextureFromFile("resource/Vkeys/w.png")
wDuplicateTextureLoaded = true
end
if not wDuplicateTextureLoadedA then
wDuplicateTextureA = renderLoadTextureFromFile("resource/Vkeys/a.png")
wDuplicateTextureLoadedA = true
end
if not wDuplicateTextureLoadedS then
wDuplicateTextureS = renderLoadTextureFromFile("resource/Vkeys/S.png")
wDuplicateTextureLoadedS = true
end
if not wDuplicateTextureLoadedSpa then
wDuplicateTextureSpa = renderLoadTextureFromFile("resource/Vkeys/spa.png")
wDuplicateTextureLoadedSpa = true
end
if not wDuplicateTextureLoadedF then
wDuplicateTextureF = renderLoadTextureFromFile("resource/Vkeys/f.png")
wDuplicateTextureLoadedF = true
end
if not wDuplicateTextureLoadedD then
wDuplicateTextureD = renderLoadTextureFromFile("resource/Vkeys/d.png")
wDuplicateTextureLoadedD = true
end
end
local function saveSettings()
ini.cfg.showImages = showImages[0]
ini.cfg.imageX = wImagePositions.x[0]
ini.cfg.imageY = wImagePositions.y[0]
ini.cfg.imageSizeX = wImagePositions.sizeX[0]
ini.cfg.imageSizeY = wImagePositions.sizeY[0]
inicfg.save(ini, "Vkey.ini")
end
imgui.OnFrame(function() return WinState2[0] end, function(player)
imgui.Begin("Vkey by Little_ramZz", WinState2)
if imgui.Button(showImages[0] and "off" or "on", imgui.ImVec2(150, 30)) then
showImages[0] = not showImages[0]
saveSettings()
end
imgui.Text("posX")
imgui.SliderInt("##1ImageX", wImagePositions.x, 0, 2000)
imgui.Text("posY")
imgui.SliderInt("##1ImageY", wImagePositions.y, 0, 1080)
imgui.Text("scale")
imgui.SliderFloat("##WImageScale", scaleFactor, 0.1, 5.0)
wImagePositions.sizeX[0] = 851 * scaleFactor[0]
wImagePositions.sizeY[0] = 409 * scaleFactor[0]
saveSettings()
imgui.End()
end)
imgui.OnFrame(function() return WinState1[0] end, function(player)
loadTextures()
local playerPed = PLAYER_PED
if isCharInAnyCar(playerPed) then
if showImages[0] then
renderImages()
end
end
end)
function main()
while true do
wait(0)
if WIDGET_HORN ~= nil then
if isWidgetSwipedLeft(WIDGET_HORN) then
WinState2[0] = not WinState2[0]
wait(200)
end
else
print("WIDGET_HORN is nil!")
end
local playerPed = PLAYER_PED
if isCharInAnyCar(playerPed) then
if isWidgetPressed(WIDGET_ACCELERATE) then
wImageVisible = true
else
wImageVisible = false
end
if isWidgetPressed(WIDGET_VEHICLE_STEER_LEFT) then
wImageVisibleA = true
else
wImageVisibleA = false
end
if isWidgetPressed(WIDGET_BRAKE) then
wImageVisibleS = true
else
wImageVisibleS = false
end
if isWidgetPressed(WIDGET_ENTER_CAR) then
wImageVisibleF = true
else
wImageVisibleF = false
end
if isWidgetPressed(WIDGET_HANDBRAKE) then
wImageVisibleSpa = true
else
wImageVisibleSpa = false
end
if isWidgetPressed(WIDGET_VEHICLE_STEER_RIGHT) then
wImageVisibleD = true
else
wImageVisibleD = false
end
else
wImageVisible = false
wImageVisibleA = false
wImageVisibleS = false
wImageVisibleSpa = false
wImageVisibleD = false
end
end
end