Forum
CS2D Servers mp_luamap and server.lua togethermp_luamap and server.lua together
9 replies 1
go to lua folder, make a new folder and name it "autorun", and put the scripts you want in it
Then check wether one of these maps has been loaded. ( mapchange)
Then you do luareset and then dofile the map´s lua. There are probably better ways
parse('mp_luaserver ""')to the head of the map script would probably do the trick however I don't know whether the map scripts run firstly or not. You have to try it yourself in order to see if there's an easier way to do so.
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
mapnames = {} NOTMATCH = false for a in io.popen([[dir "D:\SteamLibrary\steamapps\common\CS2D\maps\" /b /o:e]]):lines() do 	if string.sub(a, -3) == "lua" then table.insert(mapnames, a) 	else break end end for i = 1, #mapnames do if map("name")..".lua" == mapnames[i] then NOTMATCH = true break end end if NOTMATCH == false then 	msg("OH FUCK YOU NO LUA FOR THIS MAP?") endd
Here you go. Do note that the directory needs to be an absolute path.
edited 1×, last 16.05.18 11:28:30 am
@ Quattro: Put a
msgin the map Lua file and
server.lua, see which one appears first. If the map one appears first just set a variable and return at the top of the
server.luaif the variable is set.
mapname.lua:
1
eyy = true
server.lua:
1
2
3
4
5
2
3
4
5
if eyy then return end -- your code
If that doesn't work because
server.luais loaded before the map Lua, use a timeout to check the value and luareset
I believe in the autorun folder
edited 1×, last 16.05.18 03:23:53 pm
sys/lua/autorun/Readme.txt has written
Execution order of Lua scripts is
Server Lua file (default: "sys/lua/server.lua")
All Lua files in "sys/lua/autorun" (in alphabetic order)
Map Lua file (default: "maps/<NAME OF MAP>.lua")
Server Lua file (default: "sys/lua/server.lua")
All Lua files in "sys/lua/autorun" (in alphabetic order)
Map Lua file (default: "maps/<NAME OF MAP>.lua")
Yates has written
@ Talented Doge: What are you doing? Just check the current map. Why build a table with all maps in the map directory?
@ Quattro: Put a
mapname.lua:
server.lua:
If that doesn't work because
@ Quattro: Put a
msgin the map Lua file and
server.lua, see which one appears first. If the map one appears first just set a variable and return at the top of the
server.luaif the variable is set.
mapname.lua:
1
eyy = true
server.lua:
1
2
3
4
5
2
3
4
5
if eyy then return end -- your code
If that doesn't work because
server.luais loaded before the map Lua, use a timeout to check the value and luareset
How to use the timeout method? That is the case according to load sequence
1