AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [STOCK] Smart Download Manager (https://forums.alliedmods.net/showthread.php?t=206496)

Zephyrus 01-23-2013 07:29

[STOCK] Smart Download Manager
 
1 Attachment(s)
This is a small snippet that can automatically detect all the files related to an .mdl/.vmt and add them to the downloads table automatically. It also works with other file types, it will just skip the extra code for those. To use it simply include the inc file and change AddFileToDownloadsTable function calls to Downloader_AddFileToDownloadsTable. It also has caching so it should only parse the files once and on next function call it will just use the cache. Let me know if it doesn't work with some .mdl/.vmt so I can fix it.

Changelog:
1.0 - Initial release
1.1 - Fixed bug with models that have mulitple VMT files
1.2 - Fixed bug that 1.1 caused, lmao
1.5 - Quite a lot of fixes, support for files inside the "custom" directory
1.6 - Added missing define

Peace-Maker 01-23-2013 13:18

Re: [STOCK] Smart Download Manager
 
That's an awesome idea! Perfectly dynamic.

Mitchell 01-23-2013 13:34

Re: [STOCK] Smart Download Manager
 
I'm sure this checks if a file doesn't exist and doesn't add to the download table right?
Very useful indeed for plugins that require certain files.

Zephyrus 01-23-2013 13:46

Re: [STOCK] Smart Download Manager
 
Quote:

Originally Posted by Mitchell (Post 1878778)
I'm sure this checks if a file doesn't exist and doesn't add to the download table right?
Very useful indeed for plugins that require certain files.

once its cached it assumes the files havent got removed but at first it does a check yes

necavi 01-23-2013 16:56

Re: [STOCK] Smart Download Manager
 
Very nice, sounds almost exactly like what I had been planning to make!

Despirator 01-30-2013 09:59

Re: [STOCK] Smart Download Manager
 
fix the code in Downloader_GetMaterialsFromMDL, .vtf to .vmt. MDL file handles only vmt materials

Zephyrus 01-30-2013 13:33

Re: [STOCK] Smart Download Manager
 
Quote:

Originally Posted by Despirator (Post 1883454)
fix the code in Downloader_GetMaterialsFromMDL, .vtf to .vmt. MDL file handles only vmt materials

1.2 - Fixed bug that 1.1 caused, lmao

i fixed it alraedy :p

Despirator 01-30-2013 14:42

Re: [STOCK] Smart Download Manager
 
oh, sorry fro bothering you here. Didn't notice at 26

shavit 01-30-2013 15:17

Re: [STOCK] Smart Download Manager
 
Please add a stock to download a whole directory and its sub directories. :)
Amazing.

berni 01-31-2013 12:40

Re: [STOCK] Smart Download Manager
 
Quote:

Originally Posted by shavit (Post 1883644)
Please add a stock to download a whole directory and its sub directories. :)
Amazing.

That already exists in smlib:

PHP Code:

stock File_AddToDownloadsTable(const String:path[], bool:recursive=true, const String:ignoreExts[][]=_smlib_empty_twodimstring_arraysize=0); 

Code

mcpan313 01-31-2013 13:28

Re: [STOCK] Smart Download Manager
 
Quote:

Originally Posted by berni (Post 1884128)

You cant get "ztmp", should be:
Code:

new String:fileExtension[5];

Zephyrus 01-31-2013 13:29

Re: [STOCK] Smart Download Manager
 
Quote:

Originally Posted by berni (Post 1884128)
That already exists in smlib:

PHP Code:

stock File_AddToDownloadsTable(const String:path[], bool:recursive=true, const String:ignoreExts[][]=_smlib_empty_twodimstring_arraysize=0); 

Code

well if its a folder of models that wont really do what hes probably looking for

berni 01-31-2013 18:48

Re: [STOCK] Smart Download Manager
 
Quote:

Originally Posted by Zephyrus (Post 1884168)
well if its a folder of models that wont really do what hes probably looking for

He didn't mention models, that's why I wrote it.

Quote:

Originally Posted by mcpan313 (Post 1884167)
You cant get "ztmp", should be:
Code:

new String:fileExtension[5];

It's magic code that works without null terminators :P
ztmp is not a critical thing, I'll fix it.

Despirator 02-25-2013 11:33

Re: [STOCK] Smart Download Manager
 
i have these errors in the log
Quote:

L 02/25/2013 - 22:31:51: [SM] Native "GetArrayString" reported: Invalid index -4 (count: 47)
L 02/25/2013 - 22:31:51: [SM] Displaying call stack trace for plugin "personal_skins.smx":
L 02/25/2013 - 22:31:51: [SM] [0] Line 144, D:\Games\Servers\CSS-Public_Server\css\cstrike\addons\sourcemod\sc ripting\include\smartdm.inc::Downloader_AddFi leToDownloadsTable()
L 02/25/2013 - 22:31:51: [SM] [1] Line 101, D:\Games\Servers\CSS-Public_Server\css\cstrike\addons\sourcemod\sc ripting\personal_skins.sp::Command_Reload()
L 02/25/2013 - 22:31:51: [SM] [2] Line 56, D:\Games\Servers\CSS-Public_Server\css\cstrike\addons\sourcemod\sc ripting\personal_skins.sp::OnMapStart()

Zephyrus 07-22-2014 13:27

Re: [STOCK] Smart Download Manager
 
i just updated this include finally, got quite a few fixes and new features too, there are 2 stocks that might be useful outside of this include too:

FileExists2 - checks if a file exists either on disk or somewhere inside the custom folder
OpenFile2 - capable of opening files inside the custom folder, for example if the path of the file is: "custom/my_plugin/test.txt" then you can just open that like this: OpenFile2("test.txt", "r");
If the file doesn't exist it will just work as the original OpenFile function

DoPe^ 07-25-2014 10:11

Re: [STOCK] Smart Download Manager
 
I am getting this when I try to compile a plugin with smartdm included :)

Code:

/sourcemod/scripting/include\smartdm.inc(39) : error 017: undefined symbol "STRING"
/sourcemod/scripting/include\smartdm.inc(48) : error 017: undefined symbol "STRING"
/sourcemod/scripting/include\smartdm.inc(61) : error 017: undefined symbol "STRING"
/sourcemod/scripting/include\smartdm.inc(62) : error 017: undefined symbol "STRING"
/sourcemod/scripting/include\smartdm.inc(182) : error 017: undefined symbol "STRING"
/sourcemod/scripting/include\smartdm.inc(182) : error 035: argument type mismatch (argument 4)
/sourcemod/scripting/include\smartdm.inc(239) : error 017: undefined symbol "STRING"
/sourcemod/scripting/include\smartdm.inc(265) : error 017: undefined symbol "STRING"
/sourcemod/scripting/include\smartdm.inc(267) : error 017: undefined symbol "STRING"
/sourcemod/scripting/include\smartdm.inc(279) : error 017: undefined symbol "STRING"


Zephyrus 07-25-2014 10:30

Re: [STOCK] Smart Download Manager
 
ive reuploaded the fixed inc, STRING was defined in my own stocks that i always include so i totally forgot about it

DoPe^ 07-25-2014 10:31

Re: [STOCK] Smart Download Manager
 
Quote:

Originally Posted by Zephyrus (Post 2173555)
ive reuploaded the fixed smx, STRING was defined in my own stocks that i always include so i totally forgot about it

Ah alright :D thanks!

NeoxX 03-19-2015 03:54

Re: [STOCK] Smart Download Manager
 
Quote:

[SM] Native "GetArrayString" reported: Invalid index -42 (count: 645)
[SM] Displaying call stack trace for plugin "store/store-skins.smx":
[SM] [0] Line 159, C:\Users\Panda\Dropbox\Projects\Store\include \smartdm.inc:: Downloader_AddFileToDownloadsTable()
[SM] [1] Line 178, store-skins.sp::LoadItem()
Can anyone help me to fix it?

Alienmario 11-19-2015 15:45

Re: [STOCK] Smart Download Manager
 
1 Attachment(s)
I've discovered a bug with model's materials that are inside custom folder not downloading. Turns out FileExists2 compares cached files by names but doesn't correctly format the filenames/paths to match.

So I did a quick fix by replacing "\" with "/" and turning filenames lowercase before comparing.

Great Stock Btw, very useful:)!

Edit: added fix for some uppercase paths that still weren't downloading
Edit2: everything is now converted lowercase before adding to the downloads table (due to linux issues). It might not be very efficient but I'm done with this for now. Someone could probably rewrite this to use new syntax and streamline it a bit more but it appears to be working finally.

mrkos9i4ok 08-30-2017 17:32

Re: [STOCK] Smart Download Manager
 
not work for https://gamebanana.com/skins/145956

guard1
-guard1.dx90.vtx
-guard1.phy
-and all textures
prisoner2
-prisoner2.dx90.vtx
-prisoner2.phy
-prisoner2_arms.dx90.vtx
-prisoner2_arms.vvd
-and all textures
prisoner3
-prisoner3_arms.dx90.vtx
-prisoner3_arms.vvd
-gi_head_14.vtf
-gi_head_nml.vtf

Ermert1992 10-28-2017 16:02

Re: [STOCK] Smart Download Manager
 
Really useful. Thank you!

Alienmario 11-17-2022 17:26

Re: [STOCK] Smart Download Manager
 
Has anyone expanded on this since? If not, I may have another look at it.
I recall having occasional issues with it back in 2015, though I could be wrong.

I think this is still the best solution for downloads. You could use full folder downloaders, but still have to specify the files somewhere (some config or in code) anyways.
With this include, a plugin actually using a resource, model for example, automagically parses all its dependencies without any fluff getting through. At least, that's what it should do.

sviridov_artem 12-10-2022 10:10

Re: [STOCK] Smart Download Manager
 
Quote:

Originally Posted by Alienmario (Post 2364585)
I've discovered a bug with model's materials that are inside custom folder not downloading. Turns out FileExists2 compares cached files by names but doesn't correctly format the filenames/paths to match.

So I did a quick fix by replacing "" with "/" and turning filenames lowercase before comparing.

Great Stock Btw, very useful:)!

Edit: added fix for some uppercase paths that still weren't downloading
Edit2: everything is now converted lowercase before adding to the downloads table (due to linux issues). It might not be very efficient but I'm done with this for now. Someone could probably rewrite this to use new syntax and streamline it a bit more but it appears to be working finally.



Hello everyone, there is no downloading of files, in capital case. Can you help fix include ?


All times are GMT -4. The time now is 22:39.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.