timsk 10 Posted October 9, 2013 (edited) Hi everyone I have done a lot of searching and can't find anything that answers my question. I've been investigating saving and loading information for each player. Using profileNamespace is fine, until the map is reset. This led me to the mission namespace. This works perfectly in singleplayer, but it seems the mission namespace is cleared for players who aren't the server upon disconnect (or server shutdown). I found a "stat saving system" on armaholic that uses the following method: if(isServer) then { _serverHasID = profileNameSpace getVariable ["ss_ServerID",nil]; if(isNil "_serverHasID") then { _serverID = str(round((random(100000)) + random 10000)); profileNameSpace setVariable ["ss_ServerID",_serverID]; }; serverID = profileNameSpace getVariable "ss_ServerID"; publicVariable "serverID"; }; waitUntil {!isNil "serverID"}; if(!isNil "serverID") then { if(!isDedicated) then { execVM "persistent\serverSpecific\loadAccount.sqf"; }; }; However, the above code will obviously not clear the information when the map is reset (by pressing the restart button when hosting) if the map is recreated by the same payer. Is there a solution to storing arbitrary data, for the current profile in the current mission session, across all players? edit: Here's my test of the mission namespace code. The else block is only ever hit for the host player. _testVar = missionNamespace getVariable "testVariable"; if(isNil ("_testVar")) then { missionNamespace setVariable ["testVariable", 123]; hint "Test var was null, we have now set it"; } else { hint format["TEST: %1", _testVar]; }; Edited October 9, 2013 by timsk Share this post Link to post Share on other sites
tonic-_- 53 Posted October 9, 2013 missionNamespace is the same as using testVariable = 123; In short terms missionNamespace (or just regular variables) clear when the mission is loaded. profileNamespace saves into the the clients .vars profile file and is there until they change profiles or it becomes corrupted or of course you override it. Sadly profileNamespace does not work on dedicated servers as every time the dedicated server is launched it resets the profileNamespace so keeping data on the server on reset/crash isn't possible without using external extensions/addons such as iniDB or arma2NETMySQL. There seems to be a mix of what you are trying to achieve between but from what I figure you would like to keep stuff stored on a client for when they crash so they can restore information on the current server session. Doing that could work like this. if(isServer) then { sessionID = str(round((random(100000)) + random 10000)); publicVariable "sessionID"; }; if(!isDedicated && !isNull player) then { if(isNil "sessionID") then { //This is for when the mission starts, we set the profileNamespace variable ss_sessionID when its broadcasted over the network. "sessionID" addPublicVariableEventHandler {profileNamespace setVariable["ss_sessionID",_this select 1];}; } else { if((profileNamespace getVariable["ss_sessionID",-1]) != sessionID) then { //This client doesn't match the current sessionID, Do what you must. profileNamespace setVariable["ss_sessionID",sessionID]; } else { //This client matches the current sessionID, Do whatever you need to do. }; }; }; Share this post Link to post Share on other sites
timsk 10 Posted October 9, 2013 Ah, I didn't realize the missionNamespace is just the the global scope. Good to know, thanks. you would like to keep stuff stored on a client for when they crash so they can restore information on the current server session. Not really.... In fact, just writing out the issue in more detail has led me to a solution I think. The host just needs to store the values for each player, then assign them on load. I would just reset them at the start of the init.sqf, the init.sqf is only called when a mission is started from fresh (not pressing the 'continue' button). Thanks a lot for your help, it seems just talking out the problem has led me to the solution :). Share this post Link to post Share on other sites
loki 1 Posted October 12, 2013 (edited) Sadly profileNamespace does not work on dedicated servers as every time the dedicated server is launched it resets the profileNamespace so that is why that is causing that error on my dedi.. tyvm! http://community.bistudio.com/wiki/profileNamespace Return the global namespace attached to the active user profile. global namesspace doesn't work globally.. would would have thought... :/ Edited October 12, 2013 by Loki Share this post Link to post Share on other sites