an easy way to fix the player duping would be to include a script on the script which drops money
so when the player drops money, the save script gets executed and the server tells the database that the player has no money and that gets saved
so when the player rejoins, he no longer has the money that he dropped
also, my money saving on my server doesn't seem to be working, here is my c_savePlayerToServer.sqf
private["_uid"];
if(playerSetupComplete) then
{
_uid = getPlayerUID player;
[_uid, _uid, "Health", damage player] call fn_SaveToServer;
[_uid, _uid, "Side", str(side player)] call fn_SaveToServer;
[_uid, _uid, "Account Name", name player] call fn_SaveToServer;
{
_keyName = _x select 0;
_value = _x select 1;
[_uid, _uid, _keyName, _value] call fn_SaveToServer;
} forEach call mf_inventory_all;
[_uid, _uid, "Vest", vest player] call fn_SaveToServer;
[_uid, _uid, "Uniform", uniform player] call fn_SaveToServer;
[_uid, _uid, "Backpack", backpack player] call fn_SaveToServer;
[_uid, _uid, "Goggles", goggles player] call fn_SaveToServer;
[_uid, _uid, "HeadGear", headGear player] call fn_SaveToServer;
[_uid, _uid, "UniformItems", uniformItems player] call fn_SaveToServer;
[_uid, _uid, "VestItems", vestItems player] call fn_SaveToServer;
[_uid, _uid, "BackpackItems", backpackItems player] call fn_SaveToServer;
[_uid, _uid, "Position", getPosATL vehicle player] call fn_SaveToServer;
[_uid, _uid, "Direction", direction vehicle player] call fn_SaveToServer;
[_uid, _uid, "PrimaryWeapon", primaryWeapon player] call fn_SaveToServer;
[_uid, _uid, "PrimaryWeaponItems", primaryWeaponItems player] call fn_SaveToServer;
//[_uid, _uid, "PrimaryWeaponMagazine", primaryWeaponMagazine player] call fn_SaveToServer;
[_uid, _uid, "SecondaryWeapon", SecondaryWeapon player] call fn_SaveToServer;
[_uid, _uid, "SecondaryWeaponItems", secondaryWeaponItems player] call fn_SaveToServer;
//[_uid, _uid, "SecondaryWeaponMagazine", secondaryWeaponMagazine player] call fn_SaveToServer;
[_uid, _uid, "HandgunWeapon", handgunWeapon player] call fn_SaveToServer;
[_uid, _uid, "HandgunItems", handgunItems player] call fn_SaveToServer;
//[_uid, _uid, "HandgunMagazine", handgunMagazine player] call fn_SaveToServer;
[_uid, _uid, "Items", items player] call fn_SaveToServer;
[_uid, _uid, "AssignedItems", assignedItems player] call fn_SaveToServer;
magsWithAmmoCounts = [];
{
_class = _x select 0;
_count = _x select 1;
_elem = [_class, _count];
magsWithAmmoCounts set [count magsWithAmmoCounts, _elem];
} forEach (magazinesAmmoFull player);
[_uid, _uid, "MagazinesWithAmmoCount", magsWithAmmoCounts] call fn_SaveToServer;
//[_uid, _uid, "Weapons", Weapons player] call fn_SaveToServer;
moneyLevel = player getVariable "cmoney";
[_uid, _uid, "Money", moneyLevel] call fn_SaveToServer;
player globalChat "Player saved! DO NOT SAVE EXTRA GUN IN BACKPACK!";
};
// Possible new methods
and here is my c_playerDBSetup.sqf
//===========================================================================
applyPlayerDBValues =
{
private ["_array","_varName","_varValue","_i","_in","_exe","_backpack","_sendToServer","_uid"];
diag_log format["applyPlayerDBValues called with %1", _this];
_array = _this;
_uid = _array select 0;
_varName = _array select 1;
if (count _array == 3) then {
_varValue = _array select 2;
} else {
//diag_log format["applyPlayerDBValues failed to get a value for %1", _varName];
};
// Donation error catch
if(((getPlayerUID player) != _uid) AND ((getPlayerUID player) + "_donation" != _uid)) exitWith {if(_varName == 'DonationMoney') then {donationMoneyLoaded = 1;};};
//if there is not a value for items we care about exit early
if(isNil '_varValue') exitWith
{
//diag_log format["applyPlayerDBValues early termination with nil value for %1", _varName];
if(_varName == 'Position') then {positionLoaded = 1;};
if(_varName == 'DonationMoney') then {donationMoneyLoaded = 1;};
if(_varName == 'PrimaryWeapon') then {primaryLoaded = 1;};
if(_varName == 'HandgunWeapon') then {handgunLoaded = 1;};
if(_varName == 'SecondaryWeapon') then {secondaryLoaded = 1;};
if(_varName == 'Backpack') then { backpackLoaded = 1;};
if(_varName == 'Vest') then { vestLoaded = 1;};
if(_varName == 'Uniform') then { uniformLoaded = 1;};
if(_varName == 'Items') then { itemsLoaded = 1;};
};
if(_varName == 'DonationMoney') then {player setVariable["donationMoney",_varValue,true]; donationMoneyLoaded = 1;};
// Inventory item section. Use mf_inventory_all as set up by the mf_inv system
{
_itemID = _x select 0;
if (_varName == _itemID) then {
// Special call to mf_inventory_add specifying an absolute value
[_varName, _varValue, true] call mf_inventory_add;
};
} forEach call mf_inventory_all;
if(_varName == 'Health') then {player setDamage _varValue;};
//if(_varName == 'Magazines') then {{player addMagazine _x;}foreach _varValue;};
if (_varName == 'MagazinesWithAmmoCount') then {
{
_className = _x select 0; // eg. 30Rnd_65x39_caseless_mag
_ammoCount = _x select 1; // Magazine current ammo count
if ([player, _className] call fn_fitsInventory) then
{
player addMagazine [_className, _ammoCount];
};
} forEach _varValue;
};
if((_varName == 'Items')) then
{
for "_i" from 0 to (count _varValue) - 1 do
{
_name = _varValue select _i;
_backpack = unitBackpack player;
_inCfgWeapons = isClass (configFile >> "cfgWeapons" >> _name);
// Optics seems to denote an 'item' if 1 or 'weapon' is 0
_cfgOptics = getNumber (configFile >> "cfgWeapons" >> _name >> "optics");
if (_inCfgWeapons && _cfgOptics == 0 && (!isNil '_backpack')) then {_backpack addWeaponCargoGlobal [_name,1];}
else
{
if ([player, _name] call fn_fitsInventory) then
{
player addItem _name;
};
};
};
if(_varName == 'Items') then {itemsLoaded = 1;};
};
if(_varName == 'PrimaryWeaponItems') then
{
{
if (_x != "") then
{
player addPrimaryWeaponItem _x;
};
}foreach _varValue;
};
if(_varName == 'SecondaryWeaponItems') then
{
{
if (_x != "") then
{
player addSecondaryWeaponItem _x;
};
}foreach _varValue;
};
if(_varName == 'HandgunItems') then
{
{
if (_x != "") then
{
player addHandgunItem _x;
};
}foreach _varValue;
};
if(_varName == 'Uniform') then {removeUniform player; player addUniform _varValue; uniformLoaded = 1;};
if(_varName == 'Vest') then {removeVest player; player addVest _varValue; vestLoaded = 1;};
if(_varName == 'Backpack') then {removeBackpack player; player addBackpack _varValue; backpackLoaded = 1;};
if(_varName == 'HeadGear') then {removeHeadgear player; player addHeadgear _varValue;};
if(_varName == 'Goggles') then {player addGoggles _varValue};
if(_varName == 'Position') then {player setPos _varValue; player setVariable["playerWasMoved",1,true]; positionLoaded = 1;};
if(_varName == 'Direction') then {player setDir _varValue;};
if(_varName == 'PrimaryWeapon') then{player addWeapon _varValue; primaryLoaded = 1;};
if(_varName == 'HandgunWeapon') then{player addWeapon _varValue; handgunLoaded = 1;};
if(_varName == 'SecondaryWeapon') then {player addWeapon _varValue; secondaryLoaded = 1;};
if(_varName == 'Money') then {
moneyLevel = _varValue;
_player setVariable ["cmoney", _varValue, true];
moneyLoaded = 1;
};
if(_varName == 'AssignedItems') then {
{
_inCfgWeapons = isClass (configFile >> "cfgWeapons" >> _x);
if (_inCfgWeapons) then {
// Its a 'weapon'
player addWeapon _x;
} else {
player linkItem _x;
};
} foreach _varValue;
};
};
//===========================================================================
_sendToServer =
"
accountToServerLoad = _this;
publicVariableServer 'accountToServerLoad';
";
sendToServer = compile _sendToServer;
//===========================================================================
"accountToClient" addPublicVariableEventHandler
{
(_this select 1) spawn applyPlayerDBValues;
};
//===========================================================================
statFunctionsLoaded = 1;
i've looked over all the changes and made sure that its right, for a new arma 3 dev i'm a bit lost as to if i did anything wrong on the implementation.
EDIT: i found the little bugger, in the code you mentioned (c_playerDBSetup.sqf) there was a "_" attached before the player, so this was the fix (using this)
if(_varName == 'Money') then {
moneyLevel = _varValue;
player setVariable ["cmoney", _varValue, true];
moneyLoaded = 1;
};
this could be the fix for those having problems with the code.