ue30oli 10 Posted March 8, 2016 Hi, i have a problem with coding it write and cant fix it out. i just want to save the player kills and load it at the begin and show it the player in globalchat. so i modified this scripts... loadAccount.sqf //ADD STATS THAT NEED TO BE LOADED HERE. ["playerkills"] call fn_LoadStat; //=========================================================================== //END statsLoaded = 1; player globalChat format ["Stats loaded..."]; saveFuncs.sqf fn_SaveStat = { _varName = _this select 0; _varValue = _this select 1; profileNameSpace setVariable [_varName + serverID,_varValue]; }; fn_LoadStat = { _varName = _this select 0; _varValue = profileNameSpace getVariable (_varName + serverID); if(isNil "_varValue") exitWith {}; [_varName,_varValue] call fn_SetStat; }; //=========================================================================== //ADD VARIABLES TO THIS ARRAY THAT NEED SPECIAL SCRIPTING TO LOAD specialVarLoads = [ "playerkills" ]; //THIS FUNCTIONS HANDLES HOW STATS ARE LOADED fn_SetStat = { _varName = _this select 0; _varValue = _this select 1; if(isNil '_varValue') exitWith {}; if(_varName in specialVarLoads) then { if(_varName == 'playerkills') then {player globalChat format "Your Kills ", playerkills}; } else { call compile format ["%1 = %2",_varName,_varValue]; }; }; //================================================================================================================================================================================================== saveFuncsLoaded = true; and saveLoop.sql //ADD STATS YOU WANT TO CONTINUOUSLY SAVE, HERE waitUntil {!isNil "statsLoaded"}; while {true} do { sleep 1; ["playerkills", profileNameSpace getVariable "var_kills"] call fn_SaveStat; }; and init it all with... init.sqf enableSaving [FALSE,FALSE]; //ADD THIS TO YOUR MISSION'S INIT FILE waitUntil {time > 0}; execVM "statSave\saveFuncs.sqf"; waitUntil {!isNil "saveFuncsLoaded"}; 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(!isDedicated) then { execVM "statSave\loadAccount.sqf"; execVM "statSave\saveLoop.sqf"; }; //======================================================================== iam just learning scripting but i cant fix the problem. any ideas ? Share this post Link to post Share on other sites