Advertisement
Guest User

Untitled

a guest
Aug 14th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. #include "..\..\script_macros.hpp"
  2. /*
  3. File: fn_virt_sell.sqf
  4. Author: Bryan "Tonic" Boardwine
  5.  
  6. Description:
  7. Sell a virtual item to the store / shop
  8. */
  9. private ["_type","_index","_price","_amount","_name"];
  10. if ((lbCurSel 2402) isEqualTo -1) exitWith {};
  11. _type = lbData[2402,(lbCurSel 2402)];
  12. _price = lbValue[2402,(lbCurSel 2402)];
  13. [] call life_fnc_virt_update;
  14. if ((LIFE_SETTINGS(getNumber, "dynamic_market")) isEqualTo 1) then {
  15. [0,player,life_shop_type,_amount,_price,_type] remoteExec ["TON_fnc_adjustPrices",RSERV];
  16. };
  17. };
  18. if (_price isEqualTo -1) exitWith {};
  19.  
  20. _amount = ctrlText 2405;
  21. if (!([_amount] call TON_fnc_isnumber)) exitWith {hint localize "STR_Shop_Virt_NoNum";};
  22. _amount = parseNumber (_amount);
  23. if (_amount > (ITEM_VALUE(_type))) exitWith {hint localize "STR_Shop_Virt_NotEnough"};
  24. if ((time - life_action_delay) < 0.2) exitWith {hint localize "STR_NOTF_ActionDelay";};
  25. life_action_delay = time;
  26.  
  27. _price = (_price * _amount);
  28. _name = M_CONFIG(getText,"VirtualItems",_type,"displayName");
  29. if ([false,_type,_amount] call life_fnc_handleInv) then {
  30. hint format [localize "STR_Shop_Virt_SellItem",_amount,(localize _name),[_price] call life_fnc_numberText];
  31. CASH = CASH + _price;
  32. [0] call SOCK_fnc_updatePartial;
  33. [] call life_fnc_virt_update;
  34. };
  35.  
  36. if (life_shop_type isEqualTo "drugdealer") then {
  37. private ["_array","_ind","_val"];
  38. _array = life_shop_npc getVariable ["sellers",[]];
  39. _ind = [getPlayerUID player,_array] call TON_fnc_index;
  40. if (!(_ind isEqualTo -1)) then {
  41. _val = ((_array select _ind) select 2);
  42. _val = _val + _price;
  43. _array set[_ind,[getPlayerUID player,profileName,_val]];
  44. life_shop_npc setVariable ["sellers",_array,true];
  45. } else {
  46. _array pushBack [getPlayerUID player,profileName,_price];
  47. life_shop_npc setVariable ["sellers",_array,true];
  48. };
  49. };
  50.  
  51. if (life_shop_type isEqualTo "gold" && (LIFE_SETTINGS(getNumber,"noatm_timer")) > 0) then {
  52. [] spawn {
  53. life_use_atm = false;
  54. sleep ((LIFE_SETTINGS(getNumber,"noatm_timer")) * 60);
  55. life_use_atm = true;
  56. };
  57. };
  58.  
  59. [3] call SOCK_fnc_updatePartial;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement