set g_sandbox 0 "allow players to spawn and edit objects around the map"
set g_sandbox_info 1 "print object information to the server. 1 prints info about spawned / removed objects, 2 also prints info about edited objects"
set g_sandbox_storage_autosave 10 "storage is automatically saved every specified number of seconds"
+set g_sandbox_storage_autoload 1 "if a storage file exists for the given map, automatically load it at startup"
set g_sandbox_editor_maxobjects 1000 "maximum number of objects that may exist at a time"
set g_sandbox_editor_free 0 "when enabled, players can edit any object on the map, not just the objects they've spawned"
set g_sandbox_editor_distance_spawn 200 "distance at which objects spawn in front of the player"
float autocvar_g_loituma;
float autocvar_g_sandbox_info;
float autocvar_g_sandbox_storage_autosave;
+float autocvar_g_sandbox_storage_autoload;
float autocvar_g_sandbox_editor_maxobjects;
float autocvar_g_sandbox_editor_free;
float autocvar_g_sandbox_editor_distance_spawn;
void sandbox_Storage_DatabaseLoad()
{
+ // loads all objects from the database file
+ string fn, rf;
+ float fh;
+ fn = strcat("sandbox/storage_", GetMapname(), ".txt");
+ fh = fopen(fn, FILE_READ);
+ if(fh < 0)
+ { } // message comes here
+ else
+ {
+ for(;;)
+ {
+ rf = fgets(fh);
+ if(!rf)
+ break;
+ if(substring(rf, 0, 2) == "//")
+ continue;
+ if(substring(rf, 0, 1) == "#")
+ continue;
+ dprint(strcat(rf, " --------\n"));
+ }
+ }
}
MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand)
MUTATOR_HOOK(PlayerPreThink, sandbox_PlayerPreThink, CBC_ORDER_ANY);
MUTATOR_HOOK(ClientDisconnect, sandbox_ClientDisconnect, CBC_ORDER_ANY);
+ MUTATOR_ONADD
+ {
+ if(autocvar_g_sandbox_storage_autoload)
+ sandbox_Storage_DatabaseLoad();
+ }
+
return FALSE;
}