Forum

> > CS2D > Scripts > Particular file transfer for Particular Lua!
Forums overviewCS2D overview Scripts overviewLog in to reply

English Particular file transfer for Particular Lua!

5 replies
To the start Previous 1 Next To the start

old Particular file transfer for Particular Lua!

Ajmin
User Off Offline

Quote
I made a Multigame server!
Each map have each lua.
Theres many gfx/sfx used within the lua!
So i added all the files in the servertransfer.
But its too long!
While a player joins he need to download all the files.
(its just enough to download a small part)

Example:
Mg is a map and it uses a lua mg.lua!
It contains some gfx.
Another map is mu and it uses a lua mu.lua

A player enters the server while playing in Mg map.
But then too he need to download mu.lua's files.
cuz i add all of the files in server transfer,

So what i need is when a player joins the server,he need to get only the files which the server used. (if player joins while playing in map "mg" then only mg.lua's files should be transfered)

Hope u understand!

old Re: Particular file transfer for Particular Lua!

_Yank
User Off Offline

Quote
@user Rainoth: : It is.
Here's a simple way to do it. (didn't tested it tho, you may want to apprimorate it or something)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
servertransfer = {
	de_dust2 = {
		"sfx/path/example";
		"sfx/path/example2";
		"sfx/path/example3";
	};

	de_arbore = {
		"sfx/path/example4";
		"sfx/path/example5";
		"sfx/path/example6";
	}
}

local file = io.open("sys/servertransfer.lst","r")
local content = file:read("*a")
local current = tostring(content)
local original = io.open("sys/servertransfer_original","r")
if original then content = original:read("*a"); original:close()
else original = io.open("sys/servertransfer_original","w"); original:write(content); original:close() end

content = content.."\n"..table.concat(servertransfer[game("sv_map")], "\n")

if current ~= content then
	parse("map "..game("sv_map"))
	newFile = io.open("sys/servertransfer.lst","w")
	newFile:write(content)
	newFile:close()
end
edited 1×, last 17.01.15 08:50:20 pm

old Re: Particular file transfer for Particular Lua!

Flacko
User Off Offline

Quote
You should use a different 'sys' folder for every server

Quote
-sys PATH (Use alternative "sys"-folder for settings)


Edit: nvm, i think i misunderstood your question

You can write the contents of servertransfer.lst when you change map using 'map.lua' files.

1
2
3
4
5
6
7
--mu.lua
local servertransfer = io.open("sys/servertransfer.lst", "w")
servertransfer:write([[
	gfx/file1.bmp
	sfx/file2.ogg
]])
servertransfer:close()
edited 1×, last 18.01.15 12:22:47 am
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview