ShopSystem - RPFramework/RPFramework GitHub Wiki

ShopSystem

Description

ShopSystem module is highly customizable and allows players to buy both physical(Vehicles and furnitures) and virtual items(Arma Items). Starting from 6.0.0, the module supports real time prices updating,useful for implementing dynamic economies.


How to create a new shop?

Shops can be create both using configs (Which are well commented and easy to understand) and the Eden Editor. This means that you'll be able to extract premade compositions, or share yours, for easing the process of adding new shops to the map.

Let's take a look to the variables structure of a shop object:

Physical Shops

Variables:

! Make sure to set those variables with setVariable command !
object setVariable ['shopSystemShop',["MyClassName",200,2],true]

! Make sure to make those variables global !

  • buyableThing --> [_className,_price,_type]
         _className --> Class of the item <String>
         _price --> Price of the item <Int>
         _type --> Item's type <Int>
                            0 - Vehicle
                            1 - Virtual Item
                            2 - Physical Item (Furnitures)

  • MethLab <Bool> (object setVariable ['methLab',true,true])

You can download this custom composition for a few examples on how to setup properly a physical shop. (In this composition we do have a fishing nets sale)

Virtual Shop

Variables:

! Make sure to set those variables with setVariable command !
object setVariable ['shopSystemShop',[["MyClassName",20]],[["MyClassName",5]],true]

! Make sure to make those variables global !

  • shopSystemShop --> [_shopName,_buyItems,_sellItems]
         _shopName --> Shop's name <String>
         _buyItems --> Buyable Items list <Multi Dimensional Array>
          [["className", BUYprice], ["className1", BUYprice], ["className2", BUYprice]]
         _sellItems --> Soldable Items list <Multi Dimensional Array>
          [["className", sellPrice], ["className1", sellPrice], ["className2", sellPrice]]

  • policeStation --> Is this shop a police station? <Bool>

  • medicStation --> Is this shop only for medics?<Bool>

You can download this custom composition for a few examples on how to setup properly a virtual shop.

Dynamic Prices : What can I do?

Starting by taking a look at the server sided config.hpp, adding an item in the trackedItems section will make the price of the latter updatable , otherwise it will be treated as a normal item, and will be impossible to dynamically update its "properties".

Let's suppose we're adding the following entry to the trackedItems class
class ItemMap {
     buyPrice = 30;
     sellPrice = 10;
};
In this way, at the beginning of the mission, the item 'itemMap' will cost 30 and will be sellable at 10. Now, let's suppose we want to change the buy price of the item 'itemMap' to 50, nothing easier:

1 - Item Classname <String>
2 - New Price <Int>
3 - Buy or Sell price? <Binary> <0 - Buy | 1 - Sell>

["itemMap",50,0] call ServerModules_fnc_updateItemprice;

Our item will now cost 50, edits will be broadcasted to all players, so be careful while using this function.

⚠️ **GitHub.com Fallback** ⚠️