View Single Post
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, 1231 views)
File Type: inc filenetmessages.inc (2.7 KB, 1080 views)
__________________

Last edited by dordnung; 10-29-2017 at 19:37.
dordnung is offline