Помогите, пожалуйста. Как сделать так, чтобы айтем в инвентаре не выходил за рамки dxDrawRectangle?
local sW, sH = guiGetScreenSize()
local bW, bH = (sW/2), (sH/2)
local offset = 0
local gRender = dxCreateRenderTarget(80,100)
local showInv = false
bindKey("TAB","up",function()
if showInv == false then
showInv = true
else
showInv = false
end
showCursor(showInv)
end)
addEventHandler('onClientRender', root,function ()
if showInv == true then
-- INVENTORY
dxDrawBox(bW+191, bH-280, 319, 560, tocolor(0, 0, 0, 70))
dxDrawLine(bW+500, bH-280, bW+500, bH+279, tocolor(200, 200, 200, 100), 1)
dxDrawRectangle(bW+190, bH-300, 320, 20, tocolor(0, 0, 0, 255))
dxDrawText("INVENTORY", bW+195, bH-300, bW+510, bH-280, tocolor(160, 160, 160, 255), 1, 'default', 'left', 'center', false, false, true, false, false)
-- PLAYER
dxDrawBox(bW - 140, bH-280, 319, 380)
dxDrawRectangle(bW - 140, bH-300, 320, 20, tocolor(0, 0, 0, 255))
dxDrawText("PLAYER",bW - 135, bH-300, bW+510, bH-280, tocolor(160, 160, 160, 255), 1, 'default', 'left', 'center', false, false, true, false, false)
-- VICINITY
dxDrawBox(bW - 470, bH-280, 319, 560)
dxDrawRectangle(bW - 470, bH-300, 320, 20, tocolor(0, 0, 0, 255))
dxDrawText("VICINITY",bW - 465, bH-300, bW+510, bH-280, tocolor(160, 160, 160, 255), 1, 'default', 'left', 'center', false, false, true, false, false)
-- SCROLL
dxDrawScroll(bW+503, bH-279+offset, 5, 170)
-- ITEMS
dxDrawRectangle(bW+191, bH-345+65*1-offset, 309, 60, tocolor(100, 100, 100, 200))
dxDrawImage(bW+191, bH-345+65*1-offset, 60, 60, '571858.png', 0, 0, 0, tocolor(255, 255, 255, 255))
dxDrawText("Горный рюкзак", bW+261, bH-326+65*1-offset, bW+499, bH-306+65*1-offset, tocolor(255, 255, 255, 255), 1, 'default-bold', 'left', 'center', false, false, true, false, false)
dxDrawText("Слоты: 0/38", bW+451, bH-346+65*1-offset, bW+499, bH-326+65*1-offset, tocolor(255, 255, 255, 255), 1, 'default-bold', 'right', 'center', false, false, true, false, false)
end
end)
function Scroll(key, state)
if (state == 'down') then
if (key == 'mouse_wheel_up') then
if (offset > 0) then
offset = offset-97
else
offset = 0
end
elseif (key == 'mouse_wheel_down') then
if (offset < 388) then
offset = offset+97
else
offset = 388
end
end
end
end
bindKey('mouse_wheel_up', 'down', Scroll)
bindKey('mouse_wheel_down', 'down', Scroll)
function dxDrawBox(x, y, w, h)
dxDrawLine(x - 1, y - 1, x - 1, y + h, tocolor(200, 200, 200, 100), 1)
dxDrawLine(x + w, y - 1, x + w, y + h, tocolor(200, 200, 200, 100), 1)
dxDrawLine(x - 1, y + h, x + w, y + h, tocolor(200, 200, 200, 100), 1)
dxDrawLine(x - 1, y - 1, x + w, y - 1, tocolor(200, 200, 200, 100), 1)
dxDrawRectangle(x, y, w, h, tocolor(0, 0, 0, 100))
end
function dxDrawScroll(x, y, w, h)
dxDrawLine(x - 1, y - 1, x - 1, y + h, tocolor(200, 200, 200, 100), 1)
dxDrawLine(x + w, y - 1, x + w, y + h, tocolor(200, 200, 200, 100), 1)
dxDrawLine(x - 1, y + h, x + w, y + h, tocolor(200, 200, 200, 100), 1)
dxDrawLine(x - 1, y - 1, x + w, y - 1, tocolor(200, 200, 200, 100), 1)
dxDrawRectangle(x, y, w, h, tocolor(0, 0, 0, 10))
end