Hey leute wollte grade mal eine custom download bar machen aber diese latenEvents spinnen rum es kommt immer nur die downloadBar wen der download schon fertig ist also kurz da und weg oder es steht immer direkt 100% da egal wie groß der download ist.
Lua
-- Client --
downloadLabel = guiCreateLabel(717, 217, 166, 49, "Download: 1%\nTotalSize: 0/512 MB\n", false)
guiSetFont(downloadLabel, "default-bold-small")
guiLabelSetHorizontalAlign(downloadLabel, "center", false)
guiLabelSetVerticalAlign(downloadLabel, "center")
guiSetVisible( downloadLabel, false )
function downloadStatus( downloadStatus, downloadSize )
guiSetVisible( downloadLabel, true )
guiSetText( downloadLabel, "Download: "..tostring(downloadStatus).."\nTotalSize: 0/"..tostring(downloadSize).." \n" )
end
addEvent("downloadRender",true)
addEventHandler("downloadRender", localPlayer, downloadStatus)
function downloadFinish()
outputChatBox("Fertig")
guiSetVisible( downloadLabel, false )
end
addEvent("onClientDownloadFinish", true)
addEventHandler("onClientDownloadFinish", localPlayer, downloadFinish)
function onResourceStart()
triggerServerEvent( "onDownloadStart", localPlayer, localPlayer )
end
addEventHandler("onClientResourceStart", root, onResourceStart)
-- Server --
local playerDownload = {};
function downloadUpdateProgress( player )
local lastHandle = getLatentEventHandles(player)[#getLatentEventHandles(player)]
if lastHandle then
local status = getLatentEventStatus( player, lastHandle )
if ( status ) then
triggerClientEvent( player, "downloadRender", player, status.percentComplete, status.totalSize)-- status.percentComplete, status.totalSize )
else
if isTimer( playerDownload[player] ) then
killTimer( playerDownload[player] )
end
end
end
end
function sendDownload( player, resource )
playerDownload[player] = setTimer( downloadUpdateProgress, 50, 0, player, player )
triggerLatentClientEvent( player, "onClientDownloadFinish", 99999999999, false, player )
end
addEvent("onDownloadStart", true)
addEventHandler("onDownloadStart", getRootElement(), sendDownload)
Alles anzeigen
Danke schon mal für gute Antworten.