Forum Jump :

Author Message


Posts: 2
Rank:


Level: Member

Country: nz
Location:
Occupation:
Age:
In-game name:

 
#1 Posted at 2016-06-23 13:38        
     
Hey Guys SO I am Trying To Get Stat Save To Work On My Server I am Trying To use iniDB like it wont save when we join get money out send it and relog to see if it has saved with no money but it wont save it

Here Are The Scripts I Use
I Put This Code In The Init.sqf

call compile preProcessFile "\iniDB\init.sqf";

and this is below the compile
if(isServer) then
{
execVM "Scripts\statSave\serverGather.sqf";
};


if(!isDedicated) then
{
	execVM "Scripts\statSave\saveToServer.sqf";
	waitUntil {!isNil "fn_SaveToServer"};
	execVM "Scripts\statSave\loadStats.sqf";
	waitUntil {!isNil "statFunctionsLoaded"};
	execVM "Scripts\statSave\saveLoop.sqf";
};

then we have a file called statssave in the scripts folder and in there we have 8 scripts what are

serverGather.sqf
_saveToDB =
"
	_array = _this;
	_uid = _array select 1;
	_varName = _array select 2;
	_varValue = _array select 3;
	_saveArray = [_uid, _uid, _varName, _varValue];
	_saveArray call iniDB_write;
";

saveToDB = compile _saveToDB;


_loadFromDB =
"
	_array = _this;
	_uid = _array select 1;
	_varName = _array select 2;
	_type = _array select 3;
	_loadArray = [_uid, _uid, _varName, _type];
	accountToClient = [_uid,_varName,_loadArray call iniDB_read];
	publicVariable 'accountToClient';
";

loadFromDB = compile _loadFromDB;



"accountToServerSave" addPublicVariableEventHandler 
{
	(_this select 1) spawn saveToDB;
};

"accountToServerLoad" addPublicVariableEventHandler 
{
	(_this select 1) spawn loadFromDB;
};    

saveToServer.sqf
_save =
"
	accountToServerSave = _this;
	publicVariableServer 'accountToServerSave';
";

fn_SaveToServer = compile _save;

saveLoop.sqf
while {true} do
{
	sleep 120;
	
	[getPlayerUID player, getPlayerUID player, "Account Name", name player] call fn_SaveToServer;
    [getPlayerUID player, getPlayerUID player, "moneyAccount", bnkgeld] call fn_SaveToServer;
	
	_pistol = (saveWeaponPistol select 0);
	if(isNil "_pistol") then {_pistol = "";};
	_rifle = (saveWeaponRifle select 0);
	if(isNil "_rifle") then {_rifle = "";};
	if(playerSide == west) then
	{
		[getPlayerUID player, getPlayerUID player, "WeaponsPlayerWest", (weapons player) + [_pistol] + [_rifle]] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "MagazinesPlayerWest", magazines player] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "LicenseswWest", INV_LizenzOwner] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "InventoryWest", INV_InventarArray] call fn_SaveToServer;
	};
	if(playerSide == resistance) then
	{
		[getPlayerUID player, getPlayerUID player, "WeaponsPlayerRes", (weapons player) + [_pistol] + [_rifle]] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "MagazinesPlayerRes", magazines player] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "LicensesRes", INV_LizenzOwner] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "InventoryRes", INV_InventarArray] call fn_SaveToServer;
	};
	if(playerSide == civilian) then
	{
		[getPlayerUID player, getPlayerUID player, "WeaponsPlayerCiv", (weapons player) + [_pistol] + [_rifle]] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "MagazinesPlayerCiv", magazines player] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "LicensesCiv", INV_LizenzOwner] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "InventoryCiv", INV_InventarArray] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "savedVehiclesCiv", INV_SavedVeh] call fn_SaveToServer;
	    [getPlayerUID player, getPlayerUID player, "privateStorageCiv", private_storage] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "StreetRep", streetrep] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "INV_Fabrikowner", INV_Fabrikowner] call fn_SaveToServer;
	};
	
	player groupChat "Stats saved...";
	
};

saveFunction.sqf
if (true) exitWith {};
	[getPlayerUID player, getPlayerUID player, "Account Name", name player] call fn_SaveToServer;
    [getPlayerUID player, getPlayerUID player, "moneyAccount", bnkgeld] call fn_SaveToServer;
	
	_pistol = (saveWeaponPistol select 0);
	if(isNil "_pistol") then {_pistol = "";};
	_rifle = (saveWeaponRifle select 0);
	if(isNil "_rifle") then {_rifle = "";};
	
	if(playerSide == west) then
	{
		[getPlayerUID player, getPlayerUID player, "WeaponsPlayerWest", (weapons player) + [_pistol] + [_rifle]] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "MagazinesPlayerWest", magazines player] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "LicenseswWest", INV_LizenzOwner] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "InventoryWest", INV_InventarArray] call fn_SaveToServer;
	};
	
	if(playerSide == resistance) then
	{
		[getPlayerUID player, getPlayerUID player, "WeaponsPlayerRes", (weapons player) + [_pistol] + [_rifle]] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "MagazinesPlayerRes", magazines player] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "LicensesRes", INV_LizenzOwner] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "InventoryRes", INV_InventarArray] call fn_SaveToServer;
	};
	
	if(playerSide == civilian) then
	{
		[getPlayerUID player, getPlayerUID player, "WeaponsPlayerCiv", (weapons player) + [_pistol] + [_rifle]] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "MagazinesPlayerCiv", magazines player] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "LicensesCiv", INV_LizenzOwner] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "InventoryCiv", INV_InventarArray] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "savedVehiclesCiv", INV_SavedVeh] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "StreetRep", streetrep] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "INV_Fabrikowner", INV_Fabrikowner] call fn_SaveToServer;
	};[s][/s]


loadStats.sqf
//===========================================================================
_loadFromDBClient =
"
	_array = _this;
	_uid = _array select 0;
	if((getPlayerUID player) != _uid) exitWith {};
	_varName = _array select 1;
	_varValue = _array select 2;
	if(isNil '_varValue') exitWith {};
	if(_varName == 'moneyPlayer') then {Mishy = _varValue;};
	if(_varName == 'moneyAccount') then {bnkgeld = _varValue;};

	
	if(playerSide == west) then
	{
		if(_varName == 'WeaponsPlayerWest') then {{player addWeapon _x} forEach _varValue;};	
		if(_varName == 'MagazinesPlayerWest') then {{player addMagazine _x} forEach _varValue;};	
		if(_varName == 'LicensesWest') then {INV_LizenzOwner = _varValue;};
		if(_varName == 'InventoryWest') then {INV_InventarArray = _varValue;};
		};
	if(playerSide == civilian) then
	{
		if(_varName == 'WeaponsPlayerCiv') then {{player addWeapon _x} forEach _varValue;};	
		if(_varName == 'MagazinesPlayerCiv') then {{player addMagazine _x} forEach _varValue;};	
		if(_varName == 'LicensesCiv') then {INV_LizenzOwner = _varValue;};
		if(_varName == 'InventoryCiv') then {INV_InventarArray = _varValue;};
		if(_varName == 'savedVehiclesCiv') then {INV_SavedVeh = _varValue;};
	    if(_varName == 'privateStorageCiv') then {private_storage = _varValue;};
		if(_varName == 'StreetRep') then {streetrep = _varValue;};
		if(_varName == 'INV_Fabrikowner') then {INV_Fabrikowner = _varValue;};
	};
	if(playerSide == resistance) then
	{
		if(_varName == 'WeaponsPlayerRes') then {{player addWeapon _x} forEach _varValue;};	
		if(_varName == 'MagazinesPlayerRes') then {{player addMagazine _x} forEach _varValue;};	
		if(_varName == 'LicensesRes') then {INV_LizenzOwner = _varValue;};
		if(_varName == 'InventoryRes') then {INV_InventarArray = _varValue;};
	};
";

loadFromDBClient = compile _loadFromDBClient;
//===========================================================================
_sendToServer =
"
	accountToServerLoad = _this;
	publicVariableServer 'accountToServerLoad';
";

sendToServer = compile _sendToServer;
//===========================================================================
"accountToClient" addPublicVariableEventHandler 
{
	(_this select 1) spawn loadFromDBClient;
};
//===========================================================================

statFunctionsLoaded = 1;

loadAccount.sqf
player groupChat "Loading stats, You will be temporarily frozen and will not be able to move until stats load.";
player groupChat "Please wait while your stats load...";
hintSilent "Stats Loading 0%";
//player groupChat "Loading";
//Requests info from server in order to download stats
[getPlayerUID player, getPlayerUID player, "moneyPlayer", "NUMBER"] call sendToServer;
sleep 3;
hintSilent "Stats Loading 20%";
//player groupChat "Loading. .";
[getPlayerUID player, getPlayerUID player, "moneyAccount", "NUMBER"] call sendToServer;
hintSilent "Stats Loading 40%";
//player groupChat "Loading. . .";
if(playerSide == west) then
{
	[getPlayerUID player, getPlayerUID player, "WeaponsPlayerWest", "ARRAY"] call sendToServer;
	[getPlayerUID player, getPlayerUID player, "MagazinesPlayerWest", "ARRAY"] call sendToServer;
	[getPlayerUID player, getPlayerUID player, "LicensesWest", "ARRAY"] call sendToServer;
	[getPlayerUID player, getPlayerUID player, "InventoryWest", "ARRAY"] call sendToServer;
};

hintSilent "Stats Loading 60%";
//player groupChat "Loading. . . .";
if(playerSide == resistance) then
{
	[getPlayerUID player, getPlayerUID player, "WeaponsPlayerRes", "ARRAY"] call sendToServer;
	[getPlayerUID player, getPlayerUID player, "MagazinesPlayerRes", "ARRAY"] call sendToServer;
	[getPlayerUID player, getPlayerUID player, "LicensesRes", "ARRAY"] call sendToServer;
	[getPlayerUID player, getPlayerUID player, "InventoryRes", "ARRAY"] call sendToServer;
};

hintSilent "Stats Loading 80%";
//player groupChat "Loading. . . . .";
if(playerSide == civilian) then
{
	[getPlayerUID player, getPlayerUID player, "WeaponsPlayerCiv", "ARRAY"] call sendToServer;
	[getPlayerUID player, getPlayerUID player, "MagazinesPlayerCiv", "ARRAY"] call sendToServer;
	[getPlayerUID player, getPlayerUID player, "LicensesCiv", "ARRAY"] call sendToServer;
	[getPlayerUID player, getPlayerUID player, "InventoryCiv", "ARRAY"] call sendToServer;
	[getPlayerUID player, getPlayerUID player, "savedVehiclesCiv", "ARRAY"] call sendToServer;
    [getPlayerUID player, getPlayerUID player, "privateStorageCiv", "ARRAY"] call sendToServer;
	[getPlayerUID player, getPlayerUID player, "StreetRep", "NUMBER"] call fn_SaveToServer;
	[getPlayerUID player, getPlayerUID player, "INV_Fabrikowner", "ARRAY"] call fn_SaveToServer;
};

hintSilent "Stats Loading 100%";
sleep 2;
disableUserInput false;
//player groupChat "Loading. . . . . .";

//===========================================================================

sleep 3;
//END
statsLoaded = 1;
statsAreLoadedForReal = true;
hint "Stats Load Complete!";
player groupChat "Player Stats Loading Complete If your stats have not yet loaded please relog immediately or risk losing your previous stats";
player groupChat "If your stats have not yet loaded please relog immediately or risk losing your previous stats";
sleep 4;
player groupChat "RELOG IMMEDIATELY IF YOUR STATS HAVE NOT LOADED YET!!";
player groupChat "RELOG IMMEDIATELY IF YOUR STATS HAVE NOT LOADED YET!!";
player groupChat "RELOG IMMEDIATELY IF YOUR STATS HAVE NOT LOADED YET!!";
player groupChat "If your stats have not yet loaded please relog immediately or risk losing your previous stats";

jaysmanual.sqf
	player groupChat "-|ILU Player Stats Saved |-";
	[getPlayerUID player, getPlayerUID player, "Account Name", name player] call fn_SaveToServer;
    [getPlayerUID player, getPlayerUID player, "moneyAccount", bnkgeld] call fn_SaveToServer;
	
	_pistol = (saveWeaponPistol select 0);
	if(isNil "_pistol") then {_pistol = "";};
	_rifle = (saveWeaponRifle select 0);
	if(isNil "_rifle") then {_rifle = "";};
	if(playerSide == west) then
	{
		[getPlayerUID player, getPlayerUID player, "WeaponsPlayerWest", (weapons player) + [_pistol] + [_rifle]] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "MagazinesPlayerWest", magazines player] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "LicenseswWest", INV_LizenzOwner] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "InventoryWest", INV_InventarArray] call fn_SaveToServer;
	};
	if(playerSide == resistance) then
	{
		[getPlayerUID player, getPlayerUID player, "WeaponsPlayerRes", (weapons player) + [_pistol] + [_rifle]] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "MagazinesPlayerRes", magazines player] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "LicensesRes", INV_LizenzOwner] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "InventoryRes", INV_InventarArray] call fn_SaveToServer;
	};
	if(playerSide == civilian) then
	{
		[getPlayerUID player, getPlayerUID player, "WeaponsPlayerCiv", (weapons player) + [_pistol] + [_rifle]] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "MagazinesPlayerCiv", magazines player] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "LicensesCiv", INV_LizenzOwner] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "InventoryCiv", INV_InventarArray] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "savedVehiclesCiv", INV_SavedVeh] call fn_SaveToServer;
	    [getPlayerUID player, getPlayerUID player, "privateStorageCiv", private_storage] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "StreetRep", streetrep] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "INV_Fabrikowner", INV_Fabrikowner] call fn_SaveToServer;
	};
jaysantiglitch.sqf
	[getPlayerUID player, getPlayerUID player, "Account Name", name player] call fn_SaveToServer;
    [getPlayerUID player, getPlayerUID player, "moneyAccount", bnkgeld] call fn_SaveToServer;
	
	_pistol = (saveWeaponPistol select 0);
	if(isNil "_pistol") then {_pistol = "";};
	_rifle = (saveWeaponRifle select 0);
	if(isNil "_rifle") then {_rifle = "";};
	
	if(playerSide == west) then
	{
		[getPlayerUID player, getPlayerUID player, "WeaponsPlayerWest", (weapons player) + [_pistol] + [_rifle]] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "MagazinesPlayerWest", magazines player] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "LicenseswWest", INV_LizenzOwner] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "InventoryWest", INV_InventarArray] call fn_SaveToServer;
	};
	
	if(playerSide == resistance) then
	{
		[getPlayerUID player, getPlayerUID player, "WeaponsPlayerRes", (weapons player) + [_pistol] + [_rifle]] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "MagazinesPlayerRes", magazines player] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "LicensesRes", INV_LizenzOwner] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "InventoryRes", INV_InventarArray] call fn_SaveToServer;
	};
	
	if(playerSide == civilian) then
	{
		[getPlayerUID player, getPlayerUID player, "WeaponsPlayerCiv", (weapons player) + [_pistol] + [_rifle]] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "MagazinesPlayerCiv", magazines player] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "LicensesCiv", INV_LizenzOwner] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "InventoryCiv", INV_InventarArray] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "savedVehiclesCiv", INV_SavedVeh] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "StreetRep", streetrep] call fn_SaveToServer;
		[getPlayerUID player, getPlayerUID player, "INV_Fabrikowner", INV_Fabrikowner] call fn_SaveToServer;
	};