View Single Post
Author Message
Backup
Senior Member
Join Date: Jul 2010
Location: Česká Republika
Old 02-09-2018 , 14:24   [EXTENSION] Late Downloads
Reply With Quote #1

Late Downloads


What is this?
This is a SourceMod extension that allows file transfers to players that are already in the game.


How to build this?
Just as any other AMBuild project:
  1. Install AMBuild
  2. Download Half-Life 2 SDK, Metamod:Source and SourceMod
  3. Code:
    mkdir build && cd build
  4. Code:
    python ../configure.py --hl2sdk-root=??? --mms-path=??? --sm-path=??? --sdks=csgo
  5. Code:
    ambuild


How to use this?
Simply copy the extension binary to the extensions folder and the include file into the scripting/include folder.

Now just create a new plugin and include latedl.inc.
Sample script
PHP Code:
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <latedl>

public Plugin myinfo 
{
    
name "My First Plugin"
    
author "Me"
    
description "My first plugin ever"
    
version "1.0"
    
url "http://www.sourcemod.net/"
};

public 
void OnPluginStart()
{
    
RegAdminCmd("testdl"Command_TestDLADMFLAG_SLAY);
}

public 
void OnDownloadSuccess(int iClientchar[] filename) {
    if (
iClient 0)
        return;
    
PrintToServer("All players successfully downloaded file '%s'!"filename);
}

public 
Action Command_TestDL(int clientint args)
{
    
//create arbitrary file
    
int time GetTime();
    
char tstr[64];
    
FormatEx(tstr64"%d.txt"time);
    
File file OpenFile(tstr"wt"trueNULL_STRING);
    
WriteFileString(filetstrfalse);
    
CloseHandle(file);
    
    
//send
    
AddLateDownload(tstr);
    return 
Plugin_Handled;

Extension configuration
The extension exposes following cvars:
  • latedl_minimalbandwidth (default = 64) - Kick clients with lower bandwidth (in kbps). Zero to disable.
  • latedl_maximaldelay (default = 500) - Acceptable additional delay (in ms) when sending files.
  • latedl_requireupload (default = 1) - Kick clients with "sv_allowupload" = 0. Zero to disable.

The first two cvars limit the maximal time that the download can take. The maximal duration (in seconds) is computed using following formula: maximalDelay / 1000 + (fileSizeInBytes * 8 ) / (minimalBandwidth * 1000)

If the player fails to download the file in time, he's kicked.

The last cvar kicks any player that rejects incoming files.
Additional information
  • This was tested only in CS:GO, but any modern Source game (OrangeBox+) should be ok.
  • This extension used to be a part of the Gorme project.
  • YESTERDAY Valve changed the default settings for sv_allowupload (now disabled by default), torpedoing this extension.


Sources and binaries
Latest sources are availabe at github:
https://github.com/jonatan1024/latedl
Binaries for windows and linux should be availabe at the github releases page:
https://github.com/jonatan1024/latedl/releases
__________________
Sorry for my english.

Last edited by Backup; 02-09-2018 at 14:25.
Backup is offline