Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2021-12-09, 08:43


Unkownxyz







Wiek: 23
Na forum: 1303 dni
Posty: 17
Nick w MP: Unkownxyz

Piwa: 40

Respekt: 50


Wie ktos czemu jak u?ywam tej funckij to skacze w takim sensie ze sie cofa i idzie do przodu

Kod:

local unlerp = function(from,to,lerp) return (lerp-from)/(to-from) end

function dxDrawProgressBar( startX, startY, width, height, progress, color, backColor )
local progress = math.max( 0, (math.min( 100, progress) ) )
local wBar = width*.18
for i = 0, 4 do
--back
local startPos = (wBar*i + (width*.0)*i) + startX
dxDrawRectangle( startPos, startY, wBar, height, backColor )
--progress
local eInterval = (i*20)
local localProgress = math.min( 1, unlerp( eInterval, eInterval + 20, progress ) )
if localProgress > 0 then
dxDrawRectangle( startPos, startY, wBar*localProgress, height, color )
end
end
end


a je?li u?ywam tej funckij to albo sie zaczyna od poczatku albo od ?rodka lub ju? jest na ko?cu

Kod:

local start = getTickCount()
function dxDrawLoading (x, y, width, height, x2, y2, size, color, color2, second)
local now = getTickCount()
local seconds = second or 5000
local color = color or tocolor(0,0,0,170)
local color2 = color2 or tocolor(255,255,0,170)
local size = size or 1.00
local with = interpolateBetween(0,0,0,width,0,0, (now - start) / ((start + seconds) - start), "Linear")
local text = interpolateBetween(0,0,0,100,0,0,(now - start) / ((start + seconds) - start),"Linear")
dxDrawText ( "Loading ... "..math.floor(text).."%", x2, y2 , width, height, tocolor ( 0, 255, 0, 255 ), size, "pricedown" )
dxDrawRectangle(x, y ,width ,height -10, color)
dxDrawRectangle(x, y, with ,height -10, color2)
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2021-12-09, 15:38


kamison

Przyszły programista .lua






Wiek: 22
Na forum: 2391 dni
Posty: 384
Nick w MP: kamison

Piwa: 438

Respekt: 205,3
Respekt: 205,3Respekt: 205,3


To pierwsze ustawia na "sztywno" dane zape?nienie progress baru. To drugie przer?b pod tabele i b?dzie dzia?a?

[ Dodano: 2021-12-09, 16:11 ]
Dzia?aj?cy kod
Kod:

local table_progres_bar = {}

function dxDrawProgressBar()-- startX, startY, width, height, progress, color, backColor )
--x, y, width, height, x2, y2, size, color, color2, second)
for i=1, #table_progres_bar do
local v = table_progres_bar[i]
if v then
local x, y, width, height, x2, y2, size, color, color2, second = v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[8], v[9], v[10]
local now = getTickCount()
local start = v[11]
local seconds = second or 5000
local color = color or tocolor(0,0,0,170)
local color2 = color2 or tocolor(255,255,0,170)
local size = size or 1.00
local with = interpolateBetween(0,0,0,width,0,0, (now - start) / ((start + seconds) - start),"Linear") --(now - start)/second, "Linear")-- / ((start + seconds) - start), "Linear")
local text = interpolateBetween(0,0,0,100,0,0,(now - start) / ((start + seconds) - start),"Linear")
dxDrawText ( "Loading ... "..math.floor(text).."%", x2, y2 , width, height, tocolor ( 0, 255, 0, 255 ), size, "pricedown" )
dxDrawRectangle(x, y+i*30 ,width ,height -10, color)
dxDrawRectangle(x, y+i*30, with ,height -10, color2)
if (now - start) >= second then
table.remove(table_progres_bar, i)
end
end
end
end
addEventHandler("onClientRender", root, dxDrawProgressBar)

addCommandHandler("dxdraw", function()
local x, y, width, height, x2, y2, size, color, color2, second = 100, 200, 600, 25, 100, 100, 1, tocolor(100, 200, 50, 100), tocolor(100, 200, 50, 255), 2000
local tick = getTickCount()
table_progres_bar[#table_progres_bar+1] = {x, y, width, height, x2, y2, size, color, color2, second, tick}
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2021-12-10, 12:00


Unkownxyz







Wiek: 23
Na forum: 1303 dni
Posty: 17
Nick w MP: Unkownxyz

Piwa: 40

Respekt: 50


"kamison" napisał/a:

To pierwsze ustawia na "sztywno" dane zape?nienie progress baru. To drugie przer?b pod tabele i b?dzie dzia?a?

[ Dodano: 2021-12-09, 16:11 ]
Dzia?aj?cy kod
Kod:

local table_progres_bar = {}

function dxDrawProgressBar()-- startX, startY, width, height, progress, color, backColor )
--x, y, width, height, x2, y2, size, color, color2, second)
for i=1, #table_progres_bar do
local v = table_progres_bar[i]
if v then
local x, y, width, height, x2, y2, size, color, color2, second = v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[8], v[9], v[10]
local now = getTickCount()
local start = v[11]
local seconds = second or 5000
local color = color or tocolor(0,0,0,170)
local color2 = color2 or tocolor(255,255,0,170)
local size = size or 1.00
local with = interpolateBetween(0,0,0,width,0,0, (now - start) / ((start + seconds) - start),"Linear") --(now - start)/second, "Linear")-- / ((start + seconds) - start), "Linear")
local text = interpolateBetween(0,0,0,100,0,0,(now - start) / ((start + seconds) - start),"Linear")
dxDrawText ( "Loading ... "..math.floor(text).."%", x2, y2 , width, height, tocolor ( 0, 255, 0, 255 ), size, "pricedown" )
dxDrawRectangle(x, y+i*30 ,width ,height -10, color)
dxDrawRectangle(x, y+i*30, with ,height -10, color2)
if (now - start) >= second then
table.remove(table_progres_bar, i)
end
end
end
end
addEventHandler("onClientRender", root, dxDrawProgressBar)

addCommandHandler("dxdraw", function()
local x, y, width, height, x2, y2, size, color, color2, second = 100, 200, 600, 25, 100, 100, 1, tocolor(100, 200, 50, 100), tocolor(100, 200, 50, 255), 2000
local tick = getTickCount()
table_progres_bar[#table_progres_bar+1] = {x, y, width, height, x2, y2, size, color, color2, second, tick}
end)


jak doda?em swoje kordy gdzie ma byc ten progress to niby dziala tylko problem jest taki ze tworzy kilkanascie takich samych pod sob?.

zrobilem teraz sobie cos takiego:

Kod:

function dxDrawLoading (x, y, width, height, x2, y2, size, color, color2, second)
local now = getTickCount()
local seconds = second or 3000
local color = color or tocolor(0,0,0,113)
local color2 = color2 or tocolor(183, 0, 0, 113)
local size = size or 1.00
local with = interpolateBetween(0,0,0,width,0,0, (now - start) / ((start + seconds) - start), "Linear")
dxDrawRectangle(x, y ,width ,height -10, color)
dxDrawRectangle(x, y, with ,height -10, color2)
end

function aptekaGui()
local now = getTickCount()
dxDrawLoading(screenW * 0.3770, screenH * 0.7969, screenW * 0.2471, screenH * 0.0651, screenW * 0.3770, screenW * 0.3770, 0, 0, tocolor(0, 0, 0, 113),tocolor(183, 0, 0, 113), 3000)
if now > start + 3000 then
start = getTickCount()
end
dxDrawText("U?ywasz apteczki...", screenW * 0.3770, screenH * 0.7969, screenW * 0.6340, screenH * 0.8500, tocolor(255, 255, 255, 255), 1.00, dxfont1_normal, "center", "center", false, false, false, false, false)
end


tylko problem w tym ze zakazdym razem zaczyna od srodka

Postaw piwo autorowi tego posta
 

 
Wysłany: 2021-12-11, 16:34


kamison

Przyszły programista .lua






Wiek: 22
Na forum: 2391 dni
Posty: 384
Nick w MP: kamison

Piwa: 438

Respekt: 205,3
Respekt: 205,3Respekt: 205,3


Poka? ca?y kod inaczej nic nie zdzia?amy

Postaw piwo autorowi tego posta
 

 
Tagi: progressbar
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:








Wyświetl posty z ostatnich:   

Odpowiedz do tematu

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku

Skocz do: