Skip to content

Commit

Permalink
Added setCMoney to spawnStoreObject.sqf
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentRev committed Aug 3, 2018
1 parent 3753481 commit 199f532
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 52 deletions.
23 changes: 9 additions & 14 deletions client/systems/generalStore/buyItems.sqf
Expand Up @@ -440,26 +440,21 @@ storePurchaseHandle = _this spawn

if (!isNil "_price" && {_price > -1}) then
{
_playerMoney = player getVariable ["cmoney", 0];

// Re-check for money after purchase
if (_price > _playerMoney) then
if (isNil "_requestKey" && _price > player getVariable ["cmoney", 0]) exitWith
{
if (!isNil "_requestKey" && {!isNil _requestKey}) then
{
deleteVehicle objectFromNetId (missionNamespace getVariable _requestKey);
};

[_itemText] call _showInsufficientFundsError;
}
else
};

//player setVariable ["cmoney", _playerMoney - _price, true];
if (isNil "_requestKey") then // baseparts price now handled in spawnStoreObject.sqf
{
//player setVariable ["cmoney", _playerMoney - _price, true];
[player, -_price] call A3W_fnc_setCMoney;
_playerMoneyText ctrlSetText format ["Cash: $%1", [player getVariable ["cmoney", 0]] call fn_numbersText];
if (_successHint) then { hint "Purchase successful!" };
playSound "FD_Finish_F";
};

_playerMoneyText ctrlSetText format ["Cash: $%1", [player getVariable ["cmoney", 0]] call fn_numbersText];
if (_successHint) then { hint "Purchase successful!" };
playSound "FD_Finish_F";
};

if (!isNil "_requestKey" && {!isNil _requestKey}) then
Expand Down
23 changes: 9 additions & 14 deletions client/systems/gunStore/buyGuns.sqf
Expand Up @@ -219,26 +219,21 @@ storePurchaseHandle = _this spawn

if (!isNil "_price" && {_price > -1}) then
{
_playerMoney = player getVariable ["cmoney", 0];

// Re-check for money after purchase
if (_price > _playerMoney) then
if (isNil "_requestKey" && _price > player getVariable ["cmoney", 0]) exitWith
{
if (!isNil "_requestKey" && {!isNil _requestKey}) then
{
deleteVehicle objectFromNetId (missionNamespace getVariable _requestKey);
};

[_itemText] call _showInsufficientFundsError;
}
else
};

//player setVariable ["cmoney", _playerMoney - _price, true];
if (isNil "_requestKey") then // static gun price now handled in spawnStoreObject.sqf
{
//player setVariable ["cmoney", _playerMoney - _price, true];
[player, -_price] call A3W_fnc_setCMoney;
_playerMoneyText ctrlSetText format ["Cash: $%1", [player getVariable ["cmoney", 0]] call fn_numbersText];
if (_successHint) then { hint "Purchase successful!" };
playSound "FD_Finish_F";
};

_playerMoneyText ctrlSetText format ["Cash: $%1", [player getVariable ["cmoney", 0]] call fn_numbersText];
if (_successHint) then { hint "Purchase successful!" };
playSound "FD_Finish_F";
};

if (!isNil "_requestKey" && {!isNil _requestKey}) then
Expand Down
29 changes: 7 additions & 22 deletions client/systems/vehicleStore/buyVehicles.sqf
Expand Up @@ -164,32 +164,17 @@ storePurchaseHandle = _this spawn
};
};

if (!isNil "_price" && {_price > -1}) then
if (!isNil "_price" && {_price > -1}) then // vehicle price now handled in spawnStoreObject.sqf
{
_playerMoney = player getVariable ["cmoney", 0];
vehicleStore_lastPurchaseTime = diag_tickTime;

// Re-check for money after purchase
if (_price > _playerMoney) then
{
if (!isNil "_requestKey" && {!isNil _requestKey}) then
{
deleteVehicle objectFromNetId (missionNamespace getVariable _requestKey);
};
//player setVariable ["cmoney", _playerMoney - _price, true];
//[player, -_price] call A3W_fnc_setCMoney;
_playerMoneyText ctrlSetText format ["Cash: $%1", [player getVariable ["cmoney", 0]] call fn_numbersText];

[_itemText] call _showInsufficientFundsError;
}
else
if (["A3W_playerSaving"] call isConfigOn) then
{
vehicleStore_lastPurchaseTime = diag_tickTime;

//player setVariable ["cmoney", _playerMoney - _price, true];
[player, -_price] call A3W_fnc_setCMoney;
_playerMoneyText ctrlSetText format ["Cash: $%1", [player getVariable ["cmoney", 0]] call fn_numbersText];

if (["A3W_playerSaving"] call isConfigOn) then
{
[] spawn fn_savePlayerData;
};
[] spawn fn_savePlayerData;
};
};

Expand Down
5 changes: 3 additions & 2 deletions server/functions/spawnStoreObject.sqf
Expand Up @@ -23,7 +23,7 @@ _isVehStore = ["VehStore", _npcName] call fn_startsWith;
private _storeNPC = missionNamespace getVariable [_npcName, objNull];
private _marker = _npcName;

if (_key != "" && isPlayer _player && {_isGenStore || _isGunStore || _isVehStore}) then
if (_key != "" && _player isKindOf "Man" && {_isGenStore || _isGunStore || _isVehStore}) then
{
_timeoutKey = _key + "_timeout";
_objectID = "";
Expand Down Expand Up @@ -203,8 +203,9 @@ if (_key != "" && isPlayer _player && {_isGenStore || _isGunStore || _isVehStore
};
};

if (isPlayer _player && !(_player getVariable [_timeoutKey, true])) then
if !(_player getVariable [_timeoutKey, true]) then
{
[_player, -_itemPrice] call A3W_fnc_setCMoney;
_player setVariable [_key, _objectID, true];
}
else // Timeout
Expand Down

0 comments on commit 199f532

Please sign in to comment.