Jump to content

[REL] pDownloader (better looking progress bar)


Recommended Posts

Posted (edited)

pDownloader
version 1.1

8TeCgBZ.png

Better looking progress bar and players can play while downloading files.

Video: https://streamable.com/bedf40

How to use
If you want to enable pDownloader for a resource. (for example for the vehiclemodels)
1) Open vehiclemodels/meta.xml.
2) Add <pDownloader>true</pDownloader> tag to enable it.
3) Disable downloading for every file, which you want to download with pDownloader, instead of the default one.

Example: (vehiclemodels/meta.xml)

<meta>
    <pDownloader>true</pDownloader> <!-- STEP 2 - enable pDownloader -->
    
    <script src="client.Lua" type="client" />
    
    <!-- STEP 3 - disable downloading with  download="false"  attribute -->
    <file src="files/infernus.txd" download="false" />
    <file src="files/infernus.dff" download="false" />
</meta>

 

(IMPORTANT) You can load models just after when every file was downloaded. (when pOnDownloadComplete called)
Example: (vehiclemodels/client.Lua)
Note: use resouceRoot for event's source

addEvent("pOnDownloadComplete", true)
addEventHandler("pOnDownloadComplete", resourceRoot, function()
    local txd = engineLoadTXD("files/infernus.txd")
    engineImportTXD(txd, 411)
    local dff = engineLoadDFF("files/infernus.dff")
    engineReplaceModel(dff, 411)
end)

Thats all, now if somebody connect to your server, selected files are downloaded by pDownloader.

 

How to use model-loader
You can load your models with pDownloader, so you don't need to care about it.
Just set the model ID in meta.xml, and loads automatically after download.

Example: (vehiclemodels/meta.xml)

<meta>
    <pDownloader>true</pDownloader> <!-- STEP 2 - enable pDownloader -->
  
    <!-- script file isn't needed -->
  
    <!-- STEP 3 - disable downloading with  download="false"  attribute -->
    <!-- and set model ID for the model-loader with  model="ID"  attribute-->
    <file src="files/infernus.txd" download="false" model="411" />
    <file src="files/infernus.dff" download="false" model="411" />
</meta>

 

Events
pOnFileDownloaded (client)
Called when: file downloaded successfully.
Event's source is: root element of the resource that downloaded file.
Parameters:
    - path:  File's path.
 

pOnDownloadComplete (client)
Called when: every file downloaded successfully inside a resource.
Event's source is: root element of the resource that downloaded file.
 

pOnDownloadFailed (server)
Called when: file download failed and player get kicked.
Event's source is: player who can't download the file.
Parameters:
    - path: File's path.

Download Priority
You can set the priority in meta.xml by replace true to a number.
Resources with higher priority are downloaded before others.
Note: default priority is 1 (when value is just `true`)
<pDownloader>10<pDownloader>

 

⬇️ Download from Community
Please rate the resource on community.

Edited by Patrick
  • Like 6
  • Thanks 1
Link to post
  • Patrick changed the title to [REL] pDownloader (better looking progress bar)
  • 3 weeks later...

Can I only disable default download and not use your event handlers? I just want to use the nice looking download bar for all of my server's resources but i can't edit each script to include the custom events in it - they're just too many :s

Link to post
Posted (edited)
On 02/07/2020 at 09:13, koragg said:

Also does this work for Lua files as well or only for models etc? 

No, only with <files/>. Scripts are different, and hard to load them well.

 

On 02/07/2020 at 08:44, koragg said:

Can I only disable default download and not use your event handlers?

No, but here is a modified version, to load files easier.
Just set model ID in meta, and its load for you.

Available in latest version.

Edited by Patrick
  • Thanks 1
Link to post
  • 2 weeks later...
Posted (edited)
2 hours ago, Maruchan said:

Background download system?

Yes, something similar.

Edited by Patrick
Link to post

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...