Raised This Month: $51 Target: $400
 12% 

[EXTENSION] Send / Request Files from clients


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dordnung
Veteran Member
Join Date: Apr 2010
Old 01-16-2014 , 12:20   [EXTENSION] Send / Request Files from clients
Reply With Quote #1

While i search for a way to send files to the client while he is playing, i found two little functions to send a file to a client and request a file from a client.

The natives work pretty well, but the bad thing is: There are no real callbacks that work.

Because of that i just leave that here. If you find anything to improve this, just tell me!

Here is the include file, which should be self-explanatory

PHP Code:
/*
 * The natives work quite pretty.
 * But the forwards are really tricky, no idea when they really fire. 
 */


/**
 * Called when a file was received from a client to the server.
 * Was fired when requesting a file and it doesn't exist and was succesfulled downloaded.
 *
 * @param client          Client index.
 * @param file            File that was received.
 * @param transferID      transfer ID.
 */
forward FNM_OnFileReceived(client, const String:file[], transferID);

/**
 * Called when a client requests a file from the server.
 *
 * @param client          Client index.
 * @param file            File that was requested.
 * @param transferID      transfer ID.
 *
 * @return                Plugin_Stop to deny the request, Plugin_Continue otherwise.
 */
forward Action:FNM_OnFileRequested(client, const String:file[], transferID);

/**
 * Called when a client denies a file request from the server.
 * Was fired when requesting a file, but filed doesn't exist.
 *
 * @param client          Client index.
 * @param file            File that was denied.
 * @param transferID      transfer ID.
 */
forward FNM_OnFileDenied(client, const String:file[], transferID);

/**
 * Called when a file was sent to a client.
 * Was never fired :/
 *
 * @param client          Client index.
 * @param file            File that was sent.
 * @param transferID      transfer ID.
 */
forward FNM_OnFileSent(client, const String:file[], transferID);




/**
 * Sends a file to a client
 *
 * @param client          Client to send file.
 * @param file            File to send.
 * @param ...             Variable number of format parameters.
 *
 * @return                TransferID on success, otherwise 0.
 */
native FNM_SendFile(client, const String:file[], any:...);



/**
 * Requests a file from a client
 *
 * @param client          Client to get file from.
 * @param file            File to request.
 * @param ...             Variable number of format parameters.
 *
 * @return                TransferID of the request.
 */
native FNM_RequestFile(client, const String:file[], any:...); 
Sourcecode can be found on Github
Attached Files
File Type: zip binarys.zip (560.5 KB, 1236 views)
File Type: inc filenetmessages.inc (2.7 KB, 1086 views)
__________________

Last edited by dordnung; 10-29-2017 at 19:37.
dordnung is offline
Oshizu
Veteran Member
Join Date: Nov 2012
Location: Warsaw
Old 01-16-2014 , 12:39   Re: [EXTENSION] Send / Request Files from clients
Reply With Quote #2

Listen up folks that thing doesn't it looks a bit too harmful?
We miight be able to send files. that damn sure might override existing stuff like config.cfg
Or download files we shouldn't like C://Windows
__________________
...

Last edited by Oshizu; 01-16-2014 at 12:47.
Oshizu is offline
dordnung
Veteran Member
Join Date: Apr 2010
Old 01-16-2014 , 12:48   Re: [EXTENSION] Send / Request Files from clients
Reply With Quote #3

No, config and other stuff isn't downloadable, only things that are also with the string table "downloadables" downloadable
This is a public build in valve Function, so no fear
__________________

Last edited by dordnung; 01-16-2014 at 12:58.
dordnung is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 01-16-2014 , 13:43   Re: [EXTENSION] Send / Request Files from clients
Reply With Quote #4

So can we send materials and have them precached, and be able to show them to players with out having to reconnect?
Mitchell is offline
Oshizu
Veteran Member
Join Date: Nov 2012
Location: Warsaw
Old 01-16-2014 , 13:52   Re: [EXTENSION] Send / Request Files from clients
Reply With Quote #5

Quote:
Originally Posted by Mitchell View Post
So can we send materials and have them precached, and be able to show them to players with out having to reconnect?
Quite userful for something like Jukebox
Player's dont have to download all 250+ songs at once
They will just download it 15 sec before song plays
__________________
...
Oshizu is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 01-16-2014 , 15:04   Re: [EXTENSION] Send / Request Files from clients
Reply With Quote #6

I was under the impression that files could only be sent/received from clients when they're not actually playing (i.e. changing maps).
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
VoiDeD
AlliedModders Donor
Join Date: Mar 2009
Location: Illinois, USA
Old 01-16-2014 , 16:40   Re: [EXTENSION] Send / Request Files from clients
Reply With Quote #7

Quote:
Originally Posted by Powerlord View Post
I was under the impression that files could only be sent/received from clients when they're not actually playing (i.e. changing maps).
Files can be sent and received whenever you like, see: sprays.

The usefulness of this extension is limited though; there's a (somewhat) strict blacklist of what files and directories can be used. Additionally, any transfers here will be rate limited to the server's file channel so you wouldn't be able to make use of a server's downloadurl.

Quote:
Originally Posted by Oshizu View Post
Quite userful for something like Jukebox
Player's dont have to download all 250+ songs at once
They will just download it 15 sec before song plays
I don't think this can be done either, any files transferred will be stored as <file and extension>.ztmp, and it'll be renamed by the engine upon completion.

Personally, I can't see any use cases for this extension at all.
__________________
VoiDeD is offline
dordnung
Veteran Member
Join Date: Apr 2010
Old 01-16-2014 , 17:55   Re: [EXTENSION] Send / Request Files from clients
Reply With Quote #8

I also don't know if it's usefull or not, just left that here, open for discussion.


@VoiDeD

The downloaded files are not compressed.
I tested to download a map from the server, then changed the map and it worked without loading the map again.
__________________
dordnung is offline
VoiDeD
AlliedModders Donor
Join Date: Mar 2009
Location: Illinois, USA
Old 01-16-2014 , 20:32   Re: [EXTENSION] Send / Request Files from clients
Reply With Quote #9

Quote:
Originally Posted by Popoklopsi View Post
The downloaded files are not compressed.
I tested to download a map from the server, then changed the map and it worked without loading the map again.
Downloaded, perhaps? During downloads, I'm fairly certain it uses the ztmp temporary files. However my experience is limited to the behavior of the client with FastDL, but I don't see why it would be much different from compressed fragments sent via the net channel.

Your post did bring up one potentially interesting use case, though: stuffing maps onto clients while they play. You'll be limited to the seriously sluggish pace of the net channel, but if you've got enough time inbetween maps in your rotation, full downloads might be able to be accomplished.
__________________
VoiDeD is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 01-16-2014 , 19:18   Re: [EXTENSION] Send / Request Files from clients
Reply With Quote #10

-snip-
voided said the same thing before me.

Last edited by Mitchell; 01-16-2014 at 19:19.
Mitchell is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:06.


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