Closed IceEagle132 closed 4 years ago
I already came accross that to. I wondered why I only picked up "0" as I died with more than 100k and it should had been the max 100k. After I picked up the "0" the cash no longer worked. I had not just to relog to the lobby but completely disconnect from the server to get it fix after re-joining it.
The client uses life_cash five times in the whole PBO - otherwise the macro CASH is used instead. CASH is used quite a lot more often for all the calculations. So, as I didn't found any spot where neither CASH nor life_cash is set to nil or null I guess this happens when one of the calculations is done. As I checked where CASH is used it seem the issue happens either in fn_packupMoney or in one of the scripts within the chain.
The chain goes like this:
init.sqf
(findDisplay 46) displayAddEventHandler ["KeyDown", "_this call life_fnc_keyHandler"];
fn_keyHandler.sqf
case _interactionKey: {
if (!life_action_inUse) then {
[] spawn {
private _handle = [] spawn life_fnc_actionKeyHandler;
waitUntil {scriptDone _handle};
life_action_inUse = false;
};
};
};
fn_actionKeyHandler.sqf
//It wasn't a misc item so is it money?
if ((typeOf _curObject) isEqualTo "Land_Money_F" && {!(_curObject getVariable ["inUse",false])}) then {
[_curObject,player,true] remoteExecCall ["TON_fnc_pickupAction",RSERV];
};
fn_pickupAction.sqf (server)
if (_cash) then {
_obj remoteExecCall ["life_fnc_pickupMoney",_client];
} else {
fn_pickupMoney.sqf
private _value = (_money getVariable "item") select 1;
if (!isNil "_value") exitWith {
deleteVehicle _money;
_value = switch (true) do {
case (_value > 20000000) : {100000}; //VAL>20mil->100k
case (_value > 5000000) : {250000}; //VAL>5mil->250k
default {};
};
player playMove "AinvPknlMstpSlayWrflDnon";
titleText[format [localize "STR_NOTF_PickedMoney",[_value] call life_fnc_numberText],"PLAIN"];
CASH = CASH + _value;
[0] call SOCK_fnc_updatePartial;
life_action_delay = time;
if (LIFE_SETTINGS(getNumber,"player_moneyLog") isEqualTo 1) then {
if (LIFE_SETTINGS(getNumber,"battlEye_friendlyLogging") isEqualTo 1) then {
money_log = format [localize "STR_DL_ML_pickedUpMoney_BEF",[_value] call life_fnc_numberText,[BANK] call life_fnc_numberText,[CASH] call life_fnc_numberText];
} else {
money_log = format [localize "STR_DL_ML_pickedUpMoney",profileName,(getPlayerUID player),[_value] call life_fnc_numberText,[BANK] call life_fnc_numberText,[CASH] call life_fnc_numberText];
};
publicVariableServer "money_log";
};
};
The money is dropped in fn_dropItems.sqf like this:
case "life_cash": {
if (CASH > 0) then {
_pos = _unit modelToWorld[0,3,0];
_pos = [(_pos select 0),(_pos select 1),0];
_obj = "Land_Money_F" createVehicle _pos;
_obj setVariable ["item",["money",missionNamespace getVariable [_item,0]],true];
_obj setPos _pos;
[_obj] remoteExecCall ["life_fnc_simDisable",RANY];
missionNamespace setVariable ["CASH",0];
};
};
Maybe I can do some testing on this to see if either the dropped money already itself is the issue or if something goes wrong while picking it up.
Found the issue:
_value = switch (true) do {
case (_value > 20000000) : {100000}; //VAL>20mil->100k
case (_value > 5000000) : {250000}; //VAL>5mil->250k
default {};
};
In my test using the debug console the emtpy default {};
causes value become "nil". A quick and dirty but easy solution seems to just set _value to _value again in the default:
_value = switch (true) do {
case (_value > 20000000) : {100000}; //VAL>20mil->100k
case (_value > 5000000) : {250000}; //VAL>5mil->250k
default {_value};
};
Also: Is there any reason why someone with 20m only get 100k back but someone with only 5m gets a refund of 250k?
Expected behaviour: Pick up money to get money.
Actual behaviour: Picks up money and get 0 and life_cash no longer defined.
Steps to reproduce the behaviour: Have money on yourself Die Get revived or respawn Pick up dropped cash life_cash returns as "ANY"
Mission version: 6.0