Closed Fuzzik closed 9 years ago
If I'm not mistaken persisting entities only works in single player or on listen servers.
I am pretty sure your convar is being reset to 0.
After a restart the server console says its set to 1.
Add print(PersistPage)
and see what it prints ( BEFORE the if then return end
bit )
Alright, one moment.
A bit confused, should that print something to the server console on startup or do I execute it in game, or something else?
Add it to the file, restart your server and look for server console output.
hook.Add( "InitPostEntity", "PersistenceInit", function()
local PersistPage = GetConVarString( "sbox_persist" )
print("DONT MISS ME: ------------------------------------- ", PersistPage)
if ( PersistPage == "0" ) then return end
hook.Run( "PersistenceLoad", PersistPage );
end )
DONT MISS ME: ------------------------------------- 1
Dedicated server?
Yes
server.cfg is executed AFTER or WHILE InitPostEntity, so it is too late.
You can see PersistPage in console before the sbox_persist prints in red from the server.cfg, which is for me:
sbox_persist
sbox_persist "1"
sbox_persist
Would you recommend setting it in the batch file that opens the server or somewhere else so it is set to 1 before InitPostEntity?
sbox_persist "1" is in my server.cfg, thus being set before the map loads. Making an entity persistent and using changelevel to see if it is still there works fine, but even after using changelevel to load the same map, persistent entities are gone after a server restart.
The persist file for the map "data/persist/mapname_1.txt" is still there, but it's as if it's being ignored by the game.