Everything stay where they were after server restart.

Hello everyone,

I simply want something to make everything spawned (Props, entities, npc’s etc.) on a multiplayer server stay where it was after turning off server or when the server crash. It would a good feature if stuff was saved on map where they were spawned, something like if I built a small forest on gm_construct and gone to gm_flatgrass and built a huge house they would be kept on maps they were created.

Yea, so when the server crashes because of a huge amount of props (Doesn’t need to be spam) and it restarts it’s unstable right away. That sounds like a good idea!

It doesn’t always have to crash because of huge amount of props.

I use this script to log when my server crashes. You could use a similar method but instead store data about entities and recreate the entities instead of creating a crash log.

[lua]local crashed = false
local lastspawn , lastconnect

hook.Add(“InitPostEntity” , “CheckForCrashes” , function()
if RealTime() < 30 then
crashed = true

	if file.Exists("game_temp.txt") then
		local precrashtbl = KeyValuesToTable(file.Read("game_temp.txt"))
		local update = os.date()
		
		precrashtbl.update = update
		filex.Append("CrashLogs/"..string.Explode(" " , os.date())[1]:gsub("/" , "_").."/"..string.Explode(":" , string.Explode(" "  , os.date())[2])[1]..".txt" , "

"…TableToKeyValues(precrashtbl))
end
end
end )

timer.Create(“UpdateTempInfo” , 10 , 0 , function()
local ret = {}

local numplayers = #player.GetAll()
local players = {}

for k , v in ipairs(player.GetAll()) do
	table.insert(players , {name = v:Nick() , id = v:SteamID()})
end

ret.numplayers = numplayers
ret.players = players
ret.map = game.GetMap()
ret.downdate = os.date()
ret.lastconnect = lastconnect or {}
ret.lastspawn = lastspawn or {}
ret.roundduration = CurTime()
ret.gamemode = GAMEMODE.Name

file.Write("game_temp.txt" , TableToKeyValues(ret))

end )[/lua]

I wrote this years ago so it’s pretty shitty code, but the concept is fine.