FANDOM


--SOLUTION FOR ADDING FUNDS--
I just reversed the process from F2 scripts. I first took the value, then increased it and returned it to funds, here is the code for adding:

private ["_coin","_coinOp","_coinFunds","_str_coin","_str_coinOp","_oldFunds"];

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

// SET KEY VARIABLES
// The Construct Module Name, Construct Operator, Type of Funds and Funds amount are passed from the script call

_coin = MyCOIN;
_coinOp = "MyEngineer";
_coinFunds = 5000;
_str_coin = str _coin;
_str_coinOp = str _coinOp;
	
if (isNull (call compile format ["%1", _coinOP]))exitWith{}; 
_coinOP = call compile format ["%1",  _coinOP]; 
if (player != _coinOp) exitWith {};

call compile format ["_coin setvariable [""BIS_COIN_funds"",[""%1Var""]];",_str_coin];

_oldFunds = 0; //set it as number

call compile format ["_oldFunds = 0 + %1Var",_str_coin];

_coinFunds = _coinFunds + _oldFunds; //here we add requisition points

call compile format ["%1Var = _coinFunds",_str_coin]; //sets new amount of requisition points
_coin setvariable ["BIS_COIN_fundsDescription",[""]];
_coin setvariable ["BIS_COIN_areasize",[30,30]];

_null = [nil,nil,rHINT,"Reward : requisition points added."] call RE;

I used adding to zero since it gave me scalar instead of number. This way it works without any doubt.

It uses the same parameters as original script -- without preset parameter (_coinType).This will add 5000 to funds. Use sandbox template / ultimate tasking!!!


-- RE-SYNC COIN SOLUTION FOR F2 --

here is some temporary solution for re-sync COIN after the player is revived / respawned, I found it here thanx to McArcher, but I modified it a little bit, the way I felt it would work better.

I've created GameLogic object and in init line I've put this:

group_MyCOIN = createGroup west;  
"ConstructionManager" createUnit [getPos p1, group_MyCOIN, "MyCOIN = this;"]; 
MyCOIN synchronizeObjectsAdd [p1];

By the way this reference is wrong.

The code above creates a group and places Construction Manager as a unit. Be sure that you have center already created, if you don't have use this:

Side_MyCOIN = createCenter west;

Now, I've made a trigger that is called by radio and player can call it to re-sync with COIN module like this:

null = [] spawn 
{
	deleteVehicle MyCOIN; 
	sleep 5; 
	deleteGroup group_MyCOIN; 
	sleep 5; 
	group_MyCOIN = createGroup west;  
	"ConstructionManager" createUnit [getPos p1, group_MyCOIN, "MyCOIN = this;"]; 
	MyCOIN synchronizeObjectsAdd [p1];
	null = [MyCOIN,"p1",1,500] execVM "f\common\f_COINpresets.sqf";
};

This code will delete old unit "MyCOIN", then it will delete old group. And the process repeats -- creating new group and creating new unit and sync with player p1.

By empirical testings I've found that you cannot call only MyCOIN synchronizeObjectsAdd [p1]; , but it has to be connected i.e. in the same script with commands for creating group and creating unit (it is a block of commands).
Moreover, I've found that for some reason this script needs time to delete the unit and to delete the group, so 10 sec seamed reasonable and showed to be good during multiple testings.

After re-sync player will have 0 funds, therefore the last command will add some small amount.
This is not the perfect solution, but it has advantage --- it forces players to stay alive and to protect the leader, so that they don't loose funds.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.