--АКТИВАЦИЯ МЕНЮ
-----------------------------------------------------
local first_key = 66 -- 66 - B (https://filesd.net/kibor/codekeys.php)
local second_key = 1 -- 1 - ПКМ, 2 - СКМ
-----------------------------------------------------
--КЛАВИШИ
-----------------------------------------------------
local hotkey_lock = 'l'
local hotkey_jlock = 'lj'
local hotkey_olock = 'lo'
local hotkey_key = 'k'
local hotkey_style = 'k'
-----------------------------------------------------
--------------------------------------------------
local author = 'Chapo' --автор скрипта -- IMGUI delal ya :D Glade
local name = '(ARZ) In-Car Menu' --название скрипта
local link = 'https://www.blast.hk/threads/76761/' --ссылка на первоисточник
local color = '{ab0062}' --основной цвет текста(-ов)
--------------------------------------------------
local imgui = require 'imgui'
local pie = require 'imgui_piemenu'
local main_window = imgui.ImBool(false)
local show_pie = imgui.ImBool(false)
local fa = require 'faIcons'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local sampev = require 'lib.samp.events'
local cruise_enabled = false
local cruise_speed = 50
local is_doors_opened = nil
local is_tt_active = nil
local is_key_in = nil
local eject_seat_1 = '-'
local eject_seat_2 = '-'
local eject_seat_3 = '-'
local fa_font = nil
local fa_glyph_ranges = imgui.ImGlyphRanges({ fa.min_range, fa.max_range })
function imgui.BeforeDrawFrame()
if fa_font == nil then
local font_config = imgui.ImFontConfig() -- to use 'imgui.ImFontConfig.new()' on error
font_config.MergeMode = true
fa_font = imgui.GetIO().Fonts:AddFontFromFileTTF('moonloader/resource/fonts/fontawesome-webfont.ttf', 14.0, font_config, fa_glyph_ranges)
end
end
function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end
while not isSampAvailable() do wait(100) end
sampAddChatMessage(color..'['..name..']: {ffffff}Загружен.', -1)
sampAddChatMessage(color..'['..name..']: {ffffff}Автор: '..color..author, -1)
sampAddChatMessage(color..'['..name..']: {ffffff}Активация: зажать B, затем нажать ПКМ', -1)
sampRegisterChatCommand('imgui', function() main_window.v = not main_window.v end)
sampRegisterChatCommand('getdoor', function(id)
local res, carHandle = sampGetCarHandleBySampVehicleId(id)
if res then
local doorStatus = getCarDoorLockStatus(carHandle)
sampAddChatMessage(doorStatus > 0 and 'Машина закрыта' or 'Машина открыта', -1)
end
end)
while true do
wait(0)
if cruise_enabled and isCharInAnyCar(PLAYER_PED) then
myCarHandle = storeCarCharIsInNoSave(PLAYER_PED)
setCarForwardSpeed(myCarHandle, cruise_speed)
end
if not sampIsChatInputActive() and not sampIsDialogActive() then
if testCheat(hotkey_lock) then sampSendChat('/lock 1') end
if testCheat(hotkey_jlock) then sampSendChat('/lock 2') end
if testCheat(hotkey_olock) then sampSendChat('/lock 3') end
if testCheat(hotkey_key) then sampSendChat('/lock 4') end
end
if isKeyDown(first_key) and isCharInAnyCar(PLAYER_PED) then -- X
if not show_pie.v == true then
show_pie.v = true
end
--showCursor(true)
--sampAddChatMessage(show_pie.v and 'Вы включили PieMenu, для его показа зажмите ПКМ' or 'Вы выключили PieMenu', -1)
end
if not isKeyDown(first_key) and isCharInAnyCar(PLAYER_PED) then -- X
if not show_pie.v == false then
show_pie.v = false
end
--showCursor(true)
--sampAddChatMessage(show_pie.v and 'Вы включили PieMenu, для его показа зажмите ПКМ' or 'Вы выключили PieMenu', -1)
end
--if not isKeyJustPressed(2) then imgui.Process = false end
imgui.Process = main_window.v or show_pie.v
end
end
function imgui.OnDrawFrame()
if main_window.v then
ScreenX, ScreenY = getScreenResolution()
imgui.SetNextWindowSize(imgui.ImVec2(10, 10), imgui.Cond.FirstUseEver)
imgui.SetNextWindowPos(imgui.ImVec2(ScreenX / 2, ScreenY / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
imgui.Begin("Main Window", main_window, imgui.WindowFlags.NoResize + imgui.WindowFlags.AlwaysAutoResize)
imgui.Text('Some text\nSome text2')
imgui.End()
end
if show_pie.v then
local res, carHandle = sampGetCarHandleBySampVehicleId(id)
if res then
local doorStatus = getCarDoorLockStatus(carHandle)
if doorsStatus == 0 then
is_doors_opened = false
elseif doorStatus > 0 then
is_doors_opened = true
end
end
if not show_pie.v == true then
show_pie.v = false
end
if imgui.IsMouseClicked(second_key) and isCharInAnyCar(PLAYER_PED) then imgui.OpenPopup('PieMenu') end -- RButton
--imgui.OpenPopup('PieMenu')
if pie.BeginPiePopup('PieMenu', 1) then
--if pie.PieMenuItem(fa.ICON_REFRESH..'Test1') then sampAddChatMessage('Test1', -1) end
--if pie.PieMenuItem('Test2') then sampAddChatMessage('Test2', -1) end
--lock
if is_doors_opened == nil then
if pie.PieMenuItem(fa.ICON_UNLOCK..u8' Открыть\n'..fa.ICON_LOCK..u8' Закрыть') then sampSendChat('/lock') end
elseif is_doors_opened == true then
if pie.PieMenuItem(fa.ICON_LOCK..u8' Закрыть') then sampSendChat('/lock') end
elseif is_doors_opened == false then
if pie.PieMenuItem(fa.ICON_UNLOCK..u8' Открыть') then sampSendChat('/lock') end
end
if pie.PieMenuItem(fa.ICON_KEY..u8' /key') then sampSendChat('/key') end
if is_engine_active == nil then
if pie.PieMenuItem(fa.ICON_COGS..u8' /engine') then sampSendChat('/engine') end
elseif is_engine_active == true then
if pie.PieMenuItem(fa.ICON_COGS..u8' Заглушить') then sampSendChat('/engine') end
elseif is_engine_active == false then
if pie.PieMenuItem(fa.ICON_COGS..u8' Завести') then sampSendChat('/engine') end
end
--ЛАГАННАЯ ХУЕТЕНЬ
--[[
if pie.PieMenuItem(fa.ICON_CAR..u8' Круиз-Контроль') then
if not cruise_enabled then
speed = getCarSpeed(storeCarCharIsInNoSave(PLAYER_PED))
cruise_enabled = true
cruise_speed = speed
else
cruise_enabled = false
end
end
]]
if is_tt_active == nil then
if pie.PieMenuItem(fa.ICON_WRENCH..u8' Откл TT\n'..fa.ICON_LOCK..u8' Вкл TT') then sampSendChat('/style') end
elseif is_tt_active == true then
if pie.PieMenuItem(fa.ICON_WRENCH..u8' Откл TT') then sampSendChat('/style') end
elseif is_tt_active == false then
if pie.PieMenuItem(fa.ICON_WRENCH..u8' Вкл TT') then sampSendChat('/style') end
end
--[[
if pie.BeginPieMenu('Sub') then
if pie.BeginPieMenu('Sub sub\nmenu') then pie.EndPieMenu() end
--pie.EndPieMenu()
if pie.PieMenuItem('TestSub') then end
if pie.PieMenuItem('TestSub2') then end
end
]]
pie.EndPiePopup()
end
end
end
function getPassenger(seat)
if isCharInAnyCar(PLAYER_PED) then
--result, carHandle = sampGetCarHandleBySampVehicleId(id)
carHandle = storeCarCharIsInNoSave(PLAYER_PED)
if seat == 1 then
--1
eject_1_seat_state = isCarPassengerSeatFree(carHandle, 1)
if eject_1_seat_state then
eject_seat_1 = '-'
return false
else
eject_1_handle = getCharInCarPassengerSeat(carHandle, 1)
_, eject_seat_1 = sampGetPlayerIdByCharHandle(eject_1_handle)
return true
end
elseif seat == 2 then
--2
eject_2_seat_state = isCarPassengerSeatFree(carHandle, 2)
if eject_2_seat_state then
eject_seat_2 = '-'
return false
else
eject_2_handle = getCharInCarPassengerSeat(carHandle, 2)
_, eject_seat_2 = sampGetPlayerIdByCharHandle(eject_2_handle)
return true
end
elseif seat == 3 then
--3
eject_3_seat_state = isCarPassengerSeatFree(carHandle, 3)
if eject_3_seat_state then
eject_seat_3 = '-'
return false
else
eject_3_handle = getCharInCarPassengerSeat(carHandle, 3)
_, eject_seat_3 = sampGetPlayerIdByCharHandle(eject_3_handle)
return true
end
else
sampAddChatMessage('unknown seat', -1)
end
end
end
function sampev.onDisplayGameText(style, time, text)
print('Gametext')
print('Style: '..style)
print('time: '..time)
print('text: '..text)
if text == '~w~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~CAR~r~ LOCK~n~/lock' then
is_doors_opened = false
elseif text == '~w~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~CAR~g~ UNLOCK~n~/lock' then
is_doors_opened = true
end
if text == '~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~w~Style: ~r~Sport!' then
is_tt_active = true
elseif text == '~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~w~Style: ~g~Comfort!' then
is_tt_active = false
end
end
function sampev.onServerMessage(color, text)
nick = sampGetPlayerNickname(select(2, sampGetPlayerIdByCharHandle(PLAYER_PED)))
if text:find('вытащил(а) ключи из замка зажигания') and color == -1029514497 then
sampAddChatMessage('+', -1)
is_key_in = true
elseif text:find('вставил(а) ключи в замок зажигания') and color == -1029514497 then
sampAddChatMessage('-', -1)
is_key_in = false
end
end
function onSendEnterVehicle(playerId, pessanger)
print(playerid)
print(pessanger)
is_doors_opened = true
end
--DARK by lemonager https://www.blast.hk/threads/25442/post-473803
--[[]]
function apply_custom_style()
imgui.SwitchContext()
local style = imgui.GetStyle()
local colors = style.Colors
local clr = imgui.Col
local ImVec4 = imgui.ImVec4
local ImVec2 = imgui.ImVec2
style.WindowPadding = ImVec2(15, 15)
style.WindowRounding = 15.0
style.FramePadding = ImVec2(5, 5)
style.ItemSpacing = ImVec2(12, 8)
style.ItemInnerSpacing = ImVec2(8, 6)
style.IndentSpacing = 25.0
style.ScrollbarSize = 15.0
style.ScrollbarRounding = 15.0
style.GrabMinSize = 15.0
style.GrabRounding = 7.0
style.ChildWindowRounding = 8.0
style.FrameRounding = 6.0
colors[clr.Text] = ImVec4(0.95, 0.96, 0.98, 1.00)
colors[clr.TextDisabled] = ImVec4(0.36, 0.42, 0.47, 1.00)
colors[clr.WindowBg] = ImVec4(0.11, 0.15, 0.17, 1.00)
colors[clr.ChildWindowBg] = ImVec4(0.15, 0.18, 0.22, 1.00)
colors[clr.PopupBg] = ImVec4(0.08, 0.08, 0.08, 0.94)
colors[clr.Border] = ImVec4(0.43, 0.43, 0.50, 0.50)
colors[clr.BorderShadow] = ImVec4(0.00, 0.00, 0.00, 0.00)
colors[clr.FrameBg] = ImVec4(0.20, 0.25, 0.29, 1.00)
colors[clr.FrameBgHovered] = ImVec4(0.12, 0.20, 0.28, 1.00)
colors[clr.FrameBgActive] = ImVec4(0.09, 0.12, 0.14, 1.00)
colors[clr.TitleBg] = ImVec4(0.09, 0.12, 0.14, 0.65)
colors[clr.TitleBgCollapsed] = ImVec4(0.00, 0.00, 0.00, 0.51)
colors[clr.TitleBgActive] = ImVec4(0.08, 0.10, 0.12, 1.00)
colors[clr.MenuBarBg] = ImVec4(0.15, 0.18, 0.22, 1.00)
colors[clr.ScrollbarBg] = ImVec4(0.02, 0.02, 0.02, 0.39)
colors[clr.ScrollbarGrab] = ImVec4(0.20, 0.25, 0.29, 1.00)
colors[clr.ScrollbarGrabHovered] = ImVec4(0.18, 0.22, 0.25, 1.00)
colors[clr.ScrollbarGrabActive] = ImVec4(0.09, 0.21, 0.31, 1.00)
colors[clr.ComboBg] = ImVec4(0.20, 0.25, 0.29, 1.00)
colors[clr.CheckMark] = ImVec4(0.28, 0.56, 1.00, 1.00)
colors[clr.SliderGrab] = ImVec4(0.28, 0.56, 1.00, 1.00)
colors[clr.SliderGrabActive] = ImVec4(0.37, 0.61, 1.00, 1.00)
colors[clr.Button] = ImVec4(0.20, 0.25, 0.29, 1.00)
colors[clr.ButtonHovered] = ImVec4(0.28, 0.56, 1.00, 1.00)
colors[clr.ButtonActive] = ImVec4(0.06, 0.53, 0.98, 1.00)
colors[clr.Header] = ImVec4(0.20, 0.25, 0.29, 0.55)
colors[clr.HeaderHovered] = ImVec4(0.26, 0.59, 0.98, 0.80)
colors[clr.HeaderActive] = ImVec4(0.26, 0.59, 0.98, 1.00)
colors[clr.ResizeGrip] = ImVec4(0.26, 0.59, 0.98, 0.25)
colors[clr.ResizeGripHovered] = ImVec4(0.26, 0.59, 0.98, 0.67)
colors[clr.ResizeGripActive] = ImVec4(0.06, 0.05, 0.07, 1.00)
colors[clr.CloseButton] = ImVec4(0.40, 0.39, 0.38, 0.16)
colors[clr.CloseButtonHovered] = ImVec4(0.40, 0.39, 0.38, 0.39)
colors[clr.CloseButtonActive] = ImVec4(0.40, 0.39, 0.38, 1.00)
colors[clr.PlotLines] = ImVec4(0.61, 0.61, 0.61, 1.00)
colors[clr.PlotLinesHovered] = ImVec4(1.00, 0.43, 0.35, 1.00)
colors[clr.PlotHistogram] = ImVec4(0.90, 0.70, 0.00, 1.00)
colors[clr.PlotHistogramHovered] = ImVec4(1.00, 0.60, 0.00, 1.00)
colors[clr.TextSelectedBg] = ImVec4(0.25, 1.00, 0.00, 0.43)
colors[clr.ModalWindowDarkening] = ImVec4(1.00, 0.98, 0.95, 0.73)
end
apply_custom_style()
--RED by Albertio https://www.blast.hk/threads/25442/post-503553
--[[
function theme()
imgui.SwitchContext()
local style = imgui.GetStyle()
local colors = style.Colors
local clr = imgui.Col
local ImVec4 = imgui.ImVec4
local ImVec2 = imgui.ImVec2
style.WindowPadding = imgui.ImVec2(8, 8)
style.WindowRounding = 6
style.ChildWindowRounding = 5
style.FramePadding = imgui.ImVec2(5, 3)
style.FrameRounding = 3.0
style.ItemSpacing = imgui.ImVec2(5, 4)
style.ItemInnerSpacing = imgui.ImVec2(4, 4)
style.IndentSpacing = 21
style.ScrollbarSize = 10.0
style.ScrollbarRounding = 13
style.GrabMinSize = 8
style.GrabRounding = 1
style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
style.ButtonTextAlign = imgui.ImVec2(0.5, 0.5)
colors[clr.Text] = ImVec4(0.95, 0.96, 0.98, 1.00);
colors[clr.TextDisabled] = ImVec4(0.29, 0.29, 0.29, 1.00);
colors[clr.WindowBg] = ImVec4(0.14, 0.14, 0.14, 1.00);
colors[clr.ChildWindowBg] = ImVec4(0.12, 0.12, 0.12, 1.00);
colors[clr.PopupBg] = ImVec4(0.08, 0.08, 0.08, 0.94);
colors[clr.Border] = ImVec4(0.14, 0.14, 0.14, 1.00);
colors[clr.BorderShadow] = ImVec4(1.00, 1.00, 1.00, 0.10);
colors[clr.FrameBg] = ImVec4(0.22, 0.22, 0.22, 1.00);
colors[clr.FrameBgHovered] = ImVec4(0.18, 0.18, 0.18, 1.00);
colors[clr.FrameBgActive] = ImVec4(0.09, 0.12, 0.14, 1.00);
colors[clr.TitleBg] = ImVec4(0.14, 0.14, 0.14, 0.81);
colors[clr.TitleBgActive] = ImVec4(0.14, 0.14, 0.14, 1.00);
colors[clr.TitleBgCollapsed] = ImVec4(0.00, 0.00, 0.00, 0.51);
colors[clr.MenuBarBg] = ImVec4(0.20, 0.20, 0.20, 1.00);
colors[clr.ScrollbarBg] = ImVec4(0.02, 0.02, 0.02, 0.39);
colors[clr.ScrollbarGrab] = ImVec4(0.36, 0.36, 0.36, 1.00);
colors[clr.ScrollbarGrabHovered] = ImVec4(0.18, 0.22, 0.25, 1.00);
colors[clr.ScrollbarGrabActive] = ImVec4(0.24, 0.24, 0.24, 1.00);
colors[clr.ComboBg] = ImVec4(0.24, 0.24, 0.24, 1.00);
colors[clr.CheckMark] = ImVec4(1.00, 0.28, 0.28, 1.00);
colors[clr.SliderGrab] = ImVec4(1.00, 0.28, 0.28, 1.00);
colors[clr.SliderGrabActive] = ImVec4(1.00, 0.28, 0.28, 1.00);
colors[clr.Button] = ImVec4(1.00, 0.28, 0.28, 1.00);
colors[clr.ButtonHovered] = ImVec4(1.00, 0.39, 0.39, 1.00);
colors[clr.ButtonActive] = ImVec4(1.00, 0.21, 0.21, 1.00);
colors[clr.Header] = ImVec4(1.00, 0.28, 0.28, 1.00);
colors[clr.HeaderHovered] = ImVec4(1.00, 0.39, 0.39, 1.00);
colors[clr.HeaderActive] = ImVec4(1.00, 0.21, 0.21, 1.00);
colors[clr.ResizeGrip] = ImVec4(1.00, 0.28, 0.28, 1.00);
colors[clr.ResizeGripHovered] = ImVec4(1.00, 0.39, 0.39, 1.00);
colors[clr.ResizeGripActive] = ImVec4(1.00, 0.19, 0.19, 1.00);
colors[clr.CloseButton] = ImVec4(0.40, 0.39, 0.38, 0.16);
colors[clr.CloseButtonHovered] = ImVec4(0.40, 0.39, 0.38, 0.39);
colors[clr.CloseButtonActive] = ImVec4(0.40, 0.39, 0.38, 1.00);
colors[clr.PlotLines] = ImVec4(0.61, 0.61, 0.61, 1.00);
colors[clr.PlotLinesHovered] = ImVec4(1.00, 0.43, 0.35, 1.00);
colors[clr.PlotHistogram] = ImVec4(1.00, 0.21, 0.21, 1.00);
colors[clr.PlotHistogramHovered] = ImVec4(1.00, 0.18, 0.18, 1.00);
colors[clr.TextSelectedBg] = ImVec4(1.00, 0.32, 0.32, 1.00);
colors[clr.ModalWindowDarkening] = ImVec4(0.26, 0.26, 0.26, 0.60);
end
theme()
]]