--[[
@region: script information
* @ Drag system.
* @ Created by shelzy#6665.
* @ Version: 1.0.0
@endregion
]]
--- @region: drag system
local draggables = {
screen_size = EngineClient.GetScreenSize(),
menu = {},
drag = {},
current_drugging_item = nil,
items = {"logo"}, --здесь вы должны прописать названия елементов, пример: {"keybinds", "spectators"}
in_bounds = function(vec1, vec2) --проверка на то, что ваш курсор находится в зоне от первого вектора(vec1) до второго(vec2)
local mouse_pos = Cheat.GetMousePos()
return mouse_pos.x >= vec1.x and mouse_pos.x <= vec2.x and mouse_pos.y >= vec1.y and mouse_pos.y <= vec2.y
end
}
for i = 1, #draggables.items do --здесь создаются слайдеры в меню
draggables.menu[i] =
{
pos_x = Menu.SliderInt("Main", draggables.items[i].."_pos_x", math.floor(0.1*draggables.screen_size.x), 0, draggables.screen_size.x),
pos_y = Menu.SliderInt("Main", draggables.items[i].."_pos_y", math.floor(0.2*i*draggables.screen_size.y), 0, draggables.screen_size.y),
}
end
draggables.update = function() --слайдеры которые мы создали ранее, скрываются из меню
for k, v in ipairs(draggables.menu) do
v.pos_x:SetVisible(false)
v.pos_y:SetVisible(false)
end
end
draggables.update()
draggables.drag_handle = function(x, y, w, h, item, box)
if draggables.drag[item] == nil then
draggables.drag[item] = {}
draggables.drag[item].drag_position = Vector2.new(0,0)
draggables.drag[item].is_dragging = false
end
if draggables.in_bounds(Vector2.new(x:Get(), y:Get()), Vector2.new(x:Get() + w, y:Get() + h)) and draggables.in_bounds(Vector2.new(0, 0), draggables.screen_size) then
if Cheat.IsKeyDown(0x01) and draggables.drag[item].is_dragging == false and (draggables.current_drugging_item == nil or draggables.current_drugging_item == item) then
draggables.drag[item].is_dragging = true
draggables.current_drugging_item = item
draggables.drag[item].drag_position = Vector2.new(x:Get() - Cheat.GetMousePos().x, y:Get() - Cheat.GetMousePos().y)
end
end
if not draggables.in_bounds(Vector2.new(0, 0), draggables.screen_size) then
draggables.drag[item].is_dragging = false
end
if not Cheat.IsKeyDown(0x01) then
draggables.drag[item].is_dragging = false
draggables.current_drugging_item = nil
end
if draggables.drag[item].is_dragging == true and Cheat.IsMenuVisible() then
x:Set(Cheat.GetMousePos().x + draggables.drag[item].drag_position.x)
y:Set(Cheat.GetMousePos().y + draggables.drag[item].drag_position.y)
end
if box then
Render.Box(Vector2.new(x:Get(), y:Get()), Vector2.new(x:Get() + w, y:Get() + h), Color.new(1, 1, 1, 1))
end
end
--- @endregion
--- @region: logo
local logo = {}
-- здесь рендерится картинка для примера
logo.image = nil
logo.image_size = Vector2.new(150, 150)
logo.update = function()
if logo.image ~= nil then
return
end
Http.GetAsync("[MEDIA=imgur]32eIvMx[/MEDIA]", function(url)
logo.image = Render.LoadImage(url, logo.image_size)
end)
end
Render.Logo = function(vector)
logo.update()
if logo.image == nil then
return
end
Render.Image(logo.image, vector, logo.image_size)
end
--- @endregion
--- @region: draw
Cheat.RegisterCallback("draw", function()
local x, y = draggables.menu[1].pos_x, draggables.menu[1].pos_y
Render.Logo(Vector2.new(x:Get(), y:Get()))
draggables.drag_handle(x, y, logo.image_size.x, logo.image_size.y, draggables.items[1], true)
end)
--- @endregion
Drag system, используется для того что бы перемещать те же кейбинды не по слайдерам а курсорома че это
только вот с созданием элементов проблемы)достойно
[/i][/i][/i]Drag system:--[[ @region: script information * @ Drag system. * @ Created by shelzy#6665. * @ Version: 1.0.0 @endregion ]] --- @region: drag system local draggables = { screen_size = EngineClient.GetScreenSize(), menu = {}, drag = {}, current_drugging_item = nil, items = {"logo"}, --здесь вы должны прописать названия елементов, пример: {"keybinds", "spectators"} in_bounds = function(vec1, vec2) --проверка на то, что ваш курсор находится в зоне от первого вектора(vec1) до второго(vec2) local mouse_pos = Cheat.GetMousePos() return mouse_pos.x >= vec1.x and mouse_pos.x <= vec2.x and mouse_pos.y >= vec1.y and mouse_pos.y <= vec2.y end } for i = 1, #draggables.items do --здесь создаются слайдеры в меню draggables.menu[i] = { pos_x = Menu.SliderInt("Main", draggables.items[i].."_pos_x", math.floor(0.1*draggables.screen_size.x), 0, draggables.screen_size.x), pos_y = Menu.SliderInt("Main", draggables.items[i].."_pos_y", math.floor(0.2*i*draggables.screen_size.y), 0, draggables.screen_size.y), } end draggables.update = function() --слайдеры которые мы создали ранее, скрываются из меню for k, v in ipairs(draggables.menu) do v.pos_x:SetVisible(false) v.pos_y:SetVisible(false) end end draggables.update() draggables.drag_handle = function(x, y, w, h, item, box) if draggables.drag[item] == nil then draggables.drag[item] = {} draggables.drag[item].drag_position = Vector2.new(0,0) draggables.drag[item].is_dragging = false end if draggables.in_bounds(Vector2.new(x:Get(), y:Get()), Vector2.new(x:Get() + w, y:Get() + h)) and draggables.in_bounds(Vector2.new(0, 0), draggables.screen_size) then if Cheat.IsKeyDown(0x01) and draggables.drag[item].is_dragging == false and (draggables.current_drugging_item == nil or draggables.current_drugging_item == item) then draggables.drag[item].is_dragging = true draggables.current_drugging_item = item draggables.drag[item].drag_position = Vector2.new(x:Get() - Cheat.GetMousePos().x, y:Get() - Cheat.GetMousePos().y) end end if not draggables.in_bounds(Vector2.new(0, 0), draggables.screen_size) then draggables.drag[item].is_dragging = false end if not Cheat.IsKeyDown(0x01) then draggables.drag[item].is_dragging = false draggables.current_drugging_item = nil end if draggables.drag[item].is_dragging == true and Cheat.IsMenuVisible() then x:Set(Cheat.GetMousePos().x + draggables.drag[item].drag_position.x) y:Set(Cheat.GetMousePos().y + draggables.drag[item].drag_position.y) end if box then Render.Box(Vector2.new(x:Get(), y:Get()), Vector2.new(x:Get() + w, y:Get() + h), Color.new(1, 1, 1, 1)) end end --- @endregion --- @region: logo local logo = {} -- здесь рендерится картинка для примера logo.image = nil logo.image_size = Vector2.new(150, 150) logo.update = function() if logo.image ~= nil then return end Http.GetAsync("[MEDIA=imgur]32eIvMx[/MEDIA]", function(url) logo.image = Render.LoadImage(url, logo.image_size) end) end Render.Logo = function(vector) logo.update() if logo.image == nil then return end Render.Image(logo.image, vector, logo.image_size) end --- @endregion --- @region: draw Cheat.RegisterCallback("draw", function() local x, y = draggables.menu[1].pos_x, draggables.menu[1].pos_y Render.Logo(Vector2.new(x:Get(), y:Get())) draggables.drag_handle(x, y, logo.image_size.x, logo.image_size.y, draggables.items[1], true) end) --- @endregion