From 26591b445527611af0cb5e35fa505aa870c96f3c Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Mon, 2 May 2016 19:57:25 -0400 Subject: Started work on a lazy file transfer module --- gamemode/shared/lazyfiletransfer.lua | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 gamemode/shared/lazyfiletransfer.lua diff --git a/gamemode/shared/lazyfiletransfer.lua b/gamemode/shared/lazyfiletransfer.lua new file mode 100644 index 0000000..4169911 --- /dev/null +++ b/gamemode/shared/lazyfiletransfer.lua @@ -0,0 +1,44 @@ +--Lazy file transfer, loads files after the client has connected! +--[[ +Uses: + GM.DebugLazyFileTransfer + Can be: true, false + GM.LazyFileTransferType + Can be: lua, http + GM.GAMEMODE_FOLDER_NAME + Should be the folder name for the gamemode +]] + +if(CLIENT) then + GAMEMODE.LazyFileTransferTable = {} +end +if(SERVER) then + GM.LazyFileTransferTable = {} + util.AddNetworkString("RequestLazyFile")--Called on the client + util.AddNetworkString("SendLazyFile")--Called on the server +end + +function requestLazyFile(name) + +end + +function addLazyFile(name) + if(CLIENT) then return end + if(GM.DebugLazyFileTransfer) then + print("Adding file to be lazily transfered:") + print(name) + end + table.insert(GM.LazyFileTransferTable,name) +end + +if(SERVER) then + net.Receive( "RequestLazyFile", function(len, ply) + local partialpath = net.ReadString() + local filepath = "gamemodes/" .. GM.GAMEMODE_FOLDER_NAME .. partialpath + if(GM.DebugLazyFileTransfer) then + print("Request for lazy file recived:") + print(filepath) + end + local filedata = file.Open( filepath, 'r', "MOD" ) + end) +end -- cgit v1.2.3-70-g09d2