Strike27208 Posted November 6, 2016 Share Posted November 6, 2016 (edited) How i can create a new download bar becasue the original one are not triggered if i use "downloadFile " . I have this code for convert size : i need some help , what i need to use to make a download bar. function sizeFormat(size) local size = tostring(size) if size:len() >= 4 then if size:len() >= 7 then if size:len() >= 9 then local returning = size:sub(1, size:len()-9) if returning:len() <= 1 then returning = returning.."."..size:sub(2, size:len()-7) end return returning.." GB"; else local returning = size:sub(1, size:len()-6) if returning:len() <= 1 then returning = returning.."."..size:sub(2, size:len()-4) end return returning.." MB"; end else local returning = size:sub(1, size:len()-3) if returning:len() <= 1 then returning = returning.."."..size:sub(2, size:len()-1) end return returning.." KB"; end else return size.." B"; end end : Edited November 6, 2016 by Strike27208 Link to comment
Bonsai Posted November 6, 2016 Share Posted November 6, 2016 I don't think you can get the current progress when using downloadFile function. If you see servers with a custom downloadbar, they mostly use triggerLatentClientEvent to send data to the client. And since you can get the state of a latent event handle, you always know how much % of the download is done. 1 Link to comment
Strike27208 Posted November 6, 2016 Author Share Posted November 6, 2016 Soo , how to do more exactly ? Link to comment
Dealman Posted November 7, 2016 Share Posted November 7, 2016 (edited) Use triggerLatentClientEvent to transfer data(see fileOpen, fileRead, fileWrite, fileClose), since this is a latent event handler - it will not pause other traffic. Use getLatentEventStatus to get the progress, and then use dxDrawText and/or dxDrawRectangle as you please. You can probably find some already made on the community, but I sincerely doubt you'll learn much if you try and salvage those for code. Start simple, go from there. Edited November 7, 2016 by Dealman 2 Link to comment
Dzsozi (h03) Posted November 7, 2016 Share Posted November 7, 2016 https://community.multitheftauto.com/index.php?p=resources&s=details&id=12000 Check out this scipts' client file, I think you can get the part you need from it. Link to comment
Strike27208 Posted November 7, 2016 Author Share Posted November 7, 2016 Thanks Dzsozi , i will try. Link to comment
Strike27208 Posted November 9, 2016 Author Share Posted November 9, 2016 On 11/7/2016 at 2:42 PM, Dealman said: Use triggerLatentClientEvent to transfer data(see fileOpen, fileRead, fileWrite, fileClose), since this is a latent event handler - it will not pause other traffic. Use getLatentEventStatus to get the progress, and then use dxDrawText and/or dxDrawRectangle as you please. You can probably find some already made on the community, but I sincerely doubt you'll learn much if you try and salvage those for code. Start simple, go from there. Thansk Man ! Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now