require "lib.moonloader"
local keys = require "vkeys"
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local tag = "[My First Script]:"
local label = 0
local main_color = 0x5A90CE
local main_color_text = "{5A90CE}"
local white_color = "{FFFFFF}"
local menu = 1
local main_window_state = imgui.ImBool(false)
local text_buffer = imgui.ImBuffer(256)
local checkbox1 = imgui.ImBool(false)
local checkbox2 = imgui.ImBool(false)
local checkbox3 = imgui.ImBool(false)
local selected_item = imgui.ImInt(1)
local items = {'Начало собеседования.', 'Конец собеседования.', 'В разработке.'}
-- for combo
local combo_select = imgui.ImInt(1)
local arr_str = {"test1", "test2", "test3"}
function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end
while not isSampAvailable() do wait(100) end
sampRegisterChatCommand("mclv", cmdimgui)
handle, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
nick = sampGetPlayerNickname(id)
imgui.Process = false
while true do
wait(0)
if checkbox1.v then
for handle, v in pairs(getAllObjects()) do
local asd
if sampGetObjectSampIdByHandle(v) ~= -1 then
asd = sampGetObjectSampIdByHandle(v)
end
if isObjectOnScreen(v) then
local result, oX, oY, oZ = getObjectCoordinates(v)
local x1, y1 = convert3DCoordsToScreen(oX,oY,oZ)
local objmodel = getObjectModel(v)
local x2,y2,z2 = getCharCoordinates(PLAYER_PED)
local x10, y10 = convert3DCoordsToScreen(x2,y2,z2)
distance = string.format("%.0f", getDistanceBetweenCoords3d(oX,oY,oZ, x2, y2, z2))
if objmodel == 3930 then renderDrawLine(x10, y10, x1, y1, 2, 0xFFFFFF) renderFontDrawText(font,"{FFFF00}Resource:FF0000}"..distance, x1, y1, -1) end
end
end
end
end -- function
end
if main_window_state.v == false then
imgui.Process = false
end
function cmdimgui()
main_window_state.v = not main_window_state.v
imgui.Process = main_window_state.v
end
function imgui.OnDrawFrame()
if main_window_state.v then
imgui.ShowCursor = true
imgui.Begin("Helper to MCLV.", main_window_state)
imgui.BeginChild("##left", imgui.ImVec2(200, 85), true)
if imgui.Button('Menu', imgui.ImVec2(180, 20)) then menu = 1 end
if imgui.Button('Settings', imgui.ImVec2(180, 20)) then menu = 2 end
if imgui.Button('Author', imgui.ImVec2(180, 20)) then menu = 3 end
imgui.EndChild()
imgui.SameLine()
imgui.BeginChild("##right", imgui.ImVec2(400, 150), true)
if menu == 1 then
imgui.Text('Основные функции скрипта:')
imgui.Combo('Подача гос. волны.', selected_item, items, #items)
if imgui.Button('Подать гос. волну.') then
if selected_item.v == 0 then
sampAddChatMessage(u8'Вы запустили подачу гос. волны.', -1)
end
if selected_item.v == 1 then
sampAddChatMessage(u8'Вы запустили подачу гос. волны.', -1)
end
if selected_item.v == 2 then
sampAddChatMessage(u8'Данная функция в разработке..', -1)
end
end
end
if menu == 2 then
imgui.Text('Settings')
imgui.Combo("", combo_select, arr_str, #arr_str)
end
if menu == 3 then
imgui.Text('Автор скрипта - han(Handerson_Onfroy)')
end
imgui.EndChild()
imgui.End()
end
end