Jump to content
7erra

[Release] Virtual Arsenal Shop System

Recommended Posts

So, it has been around 19785600 seconds since my last update and I think it's time to release a new version. Well not really a new version but an entirely new system. From the creator of the Arsenal Shop:

VASS - Virtual Arsenal Shop System

The main post will contain all information regarding the new system. The old Arsenal Shop will remain as a seperate branch on GitHub but will not be maintained anymore.  I am not going to list all the changes and improvements compared to the Arsenal Shop as this would be way too much. Most importantly though is the way that changes in the Arsenal are handled. The code should now be reliable and is also easier to maintain. Another great addition is the accompanying mod: https://steamcommunity.com/sharedfiles/filedetails/?id=1760193128. This addon will remove the hassle of creating a cost table.

 

The system as of now remains untested in MP environment and may contain bugs and other problems. This is why the current release is a prerelease version until I am sure that there are no major bugs around. If you have the opportunity to test it in MP then please do so and report back the result :smile_o:.

 

I think I forgot something...

 

Have fun!

7erra

 

Also having ASS in the name is going to make it ten times better :S

 

EDIT: Perfect! New page!

  • Like 1
  • Thanks 3

Share this post


Link to post
Share on other sites

Awesome! @7erra cant wait to try it out, i will let you know  if i find any issues.

 

Keep it up.

Share this post


Link to post
Share on other sites

Excellent!   Me and my unwitting guinea pigs group look forward to breaking it thoroughly  ... uh testing it to it's fullest extent!  

Much appreciate all your work  😉

Share this post


Link to post
Share on other sites

Hmm how to call the new functions?  I tried the below in init.sqf:

 

_shop = [TraderTest,"Shop test"] call TER_fnc_addShop;

	_shopInventory = [TraderTest,
	[

	"arifle_AK12_F",100,5,
	"arifle_AKM_F",50,5,
	"arifle_MX_F",75,5,
	"hgun_P07_F",20,5,
	"optic_DMS",10,5,
	"optic_ACO_grn",5,5,
	"B_AssaultPack_mcamo",25,5,
	"U_B_CombatUniform_mcam",15,5,
	"30Rnd_762x39_Mag_F",5,true,
	"30Rnd_65x39_caseless_mag",13,true
	]
	];

No joy on my civvie with the variable name TraderTest

Share this post


Link to post
Share on other sites
9 hours ago, accuracythruvolume said:

Hmm how to call the new functions?

 

The TER_fnc_addShop function runs locally so init.sqf is fine. The next step would be to add an inventory to the trader:

if (hasInterface) then {// adding an action on a client which cant access the shop doesnt make sense
    _shop = [TraderTest,"Shop test"] call TER_fnc_addShop;
};

if (isServer) then {// only add inventory at mission start
	[
		TraderTest,// object
		[// array in format: "class", price, amount
			"arifle_AK12_F",100,5,
			"arifle_AKM_F",50,5,
			"arifle_MX_F",75,5,
			"hgun_P07_F",20,5,
			"optic_DMS",10,5,
			"optic_ACO_grn",5,5,
			"B_AssaultPack_mcamo",25,5,
			"U_B_CombatUniform_mcam",15,5,
			"30Rnd_762x39_Mag_F",5,true,
			"30Rnd_65x39_caseless_mag",13,true
		],
		2,// overwrite mode: see VASS\fnc\fn_addShopCargo.sqf for more. in this case set the inventory as the passed array
		true// make inventory the same for everyone
	] call TER_fnc_addShopCargo;
};

 

ON ANOTHER NOTE:

I just noticed that I forgot to make the new variable global. Will be fixed in the next update. Until then you can remoteExecCall the function to achieve the same effect (at least for non JIP players):

[TraderTest, _cargoArray, 2] remoteExecCall ["TER_fnc_addShopCargo",0]; // add cargo for everyone

Due to untested MP environment I am also concerned for JIP players as they will probably receive the starting inventory and not the current one. Added to my todo list.

 

EDIT: Updated GitHub

Edited by 7erra

Share this post


Link to post
Share on other sites

When I try this:

 

On 5/19/2019 at 5:30 AM, ixaak said:

@Unluckymonster Im getting started in the use of scripts and programing in general but i figured out something by reading other coments that works for me.

 

Hope was usefull.


money = player getVariable [TER_moneyVariable,0]; 
money = money + 500; 
player setVariable [TER_moneyVariable, money];

 

 

I get this:

10:31:28 Error in expression <money = player getVariable [TER_moneyVariable,0];  
money = money + >
10:31:28   Error position: <TER_moneyVariable,0];  
money = money + >
10:31:28   Error Undefined variable in expression: ter_moneyvariable

 

Share this post


Link to post
Share on other sites

Pretty sure the variable names need to be in quotes:

 

_money = player getVariable ["TER_moneyVariable",0];

_money = _money + 500;

player setVariable ["TER_moneyVariable", _money];

  • Thanks 1

Share this post


Link to post
Share on other sites

init.sqf:

 

if (hasInterface) then 
{// adding an action on a client which cant access the shop doesnt make sense
    _shop = [TraderTest,"Shop test"] call TER_fnc_addShop;
};

_cargoArray = 
[
    // array in format: "class", price, amount
    "arifle_AK12_F",100,5,
    "arifle_AKM_F",50,5,
    "arifle_MX_F",75,5,
    "hgun_P07_F",20,5,
    "optic_DMS",10,5,
    "optic_ACO_grn",5,5,
    "B_AssaultPack_mcamo",25,5,
    "U_B_CombatUniform_mcam",15,5,
    "30Rnd_762x39_Mag_F",5,true,
    "30Rnd_65x39_caseless_mag",13,true
],

if (isServer) then 
{// only add inventory at mission start
    [TraderTest, _cargoArray, 2] remoteExecCall ["TER_fnc_addShopCargo",0]; // add cargo for everyone
};

 

 

tried both remoteExecCall and remoteExec and no dice either one  

Share this post


Link to post
Share on other sites
10 hours ago, accuracythruvolume said:

Pretty sure the variable names need to be in quotes:

 

_money = player getVariable ["TER_moneyVariable",0];

_money = _money + 500;

player setVariable ["TER_moneyVariable", _money];

Normally yes but the TER_moneyVariable is a global variable which represents a string defined in the config.sqf:

// config.sqf, line 5
TER_moneyVariable = "TER_money";

 

21 hours ago, vihkr said:

I get this:

Have you added these lines to your description.ext?

class CfgFunctions
{
	#include "arsenalShop\cfgFunctions.hpp"
};

I am going to recommend switching to the newest update. It is easier to handle and more stable.

 

10 hours ago, accuracythruvolume said:

tried both remoteExecCall and remoteExec and no dice either one  

I'm stupid. I was using a wrong variable for the condition so it never showed... GitHub updated again. Code should look like this:

if (hasInterface) then
{// adding an action on a client which cant access the shop doesnt make sense
    _shop = [TraderTest,"Shop test"] call TER_fnc_addShop;
};

_cargoArray =
[
	// array in format: "class", price, amount
    "arifle_AK12_F",100,5,
    "arifle_AKM_F",50,5,
    "arifle_MX_F",75,5,
    "hgun_P07_F",20,5,
    "optic_DMS",10,5,
    "optic_ACO_grn",5,5,
    "B_AssaultPack_mcamo",25,5,
    "U_B_CombatUniform_mcam",15,5,
    "30Rnd_762x39_Mag_F",5,true,
    "30Rnd_65x39_caseless_mag",13,true
];

if (isServer) then
{// only add inventory at mission start
    [TraderTest, _cargoArray, 2] call TER_fnc_addShopCargo;
};

 

Share this post


Link to post
Share on other sites
2 hours ago, 7erra said:

Normally yes but the TER_moneyVariable is a global variable which represents a string defined in the config.sqf:


// config.sqf, line 5
TER_moneyVariable = "TER_money";

 

Have you added these lines to your description.ext?


class CfgFunctions
{
	#include "arsenalShop\cfgFunctions.hpp"
};

I am going to recommend switching to the newest update. It is easier to handle and more stable.

 

Yes, but why does mine say VASS and yours is arsenalShop? I am also using daily build from the GitHub repo. This is the head of my description.ext (and still I get the same error) and thanks for looking into this:

 

#include "VASS\gui\cfgGUI.hpp"

class cfgFunctions
{
	#include "VASS\cfgFunctions.hpp"
};

 

 

 

Share this post


Link to post
Share on other sites
42 minutes ago, vihkr said:

Yes, but why does mine say VASS and yours is arsenalShop?

I was thinking that you are using the arsenalShop version but if you are using VASS then there should be no TER_moneyVariable as I have found an easier and more adaptable way of getting and setting the players money. In which script is the error occurring?

 

Also just changed the example code for getting and setting the money to use the rating system of arma which tracks enemies and friendlies killed.

Share this post


Link to post
Share on other sites
1 hour ago, 7erra said:

I was thinking that you are using the arsenalShop version but if you are using VASS then there should be no TER_moneyVariable as I have found an easier and more adaptable way of getting and setting the players money. In which script is the error occurring?

 

Also just changed the example code for getting and setting the money to use the rating system of arma which tracks enemies and friendlies killed.

Ah ok I should have grabbed the most recent repo and read the docs. I'll try again, thanks.

Share this post


Link to post
Share on other sites

Ooooo that's a novel idea to use the player's rating as their balance.   That might prove to be more reliable then reading custom player variables 💰

Share this post


Link to post
Share on other sites

Ok everything works fine for me, just one thing is messing up:

when i try this in the editor i start my mission with all files included and a shop,

i set my rating in the debug console with

player addRating xxx;

and open the shop.

My Balance is then xxx and i buy a wepon and ammunition, then i checkout and get everything, but my balance won't change even if i do it again and again.

Is it a problem when i try it on a Multiplayer game hosted through the editor? Or have i forgotten something important?

Share this post


Link to post
Share on other sites
1 hour ago, ItzzRe4L said:

Ok everything works fine for me, just one thing is messing up:

when i try this in the editor i start my mission with all files included and a shop,

i set my rating in the debug console with


player addRating xxx;

and open the shop.

My Balance is then xxx and i buy a wepon and ammunition, then i checkout and get everything, but my balance won't change even if i do it again and again.

Is it a problem when i try it on a Multiplayer game hosted through the editor? Or have i forgotten something important?

 

It is not you who forgot something important but me 😄. There was a line of code which I copied and didn't modify so the change in the players money was never executed correctly. The newest commit on GitHub fixes that.

Share this post


Link to post
Share on other sites

It get this with the new version:

 

 7:04:08 Error in expression <fncTparams;

_diff = _funds -_cost;Text = format ["<t align='right' color='%2'>%>
 7:04:08   Error position: <= format ["<t align='right' color='%2'>%>
 7:04:08   Error Reserved variable in expression
 7:04:08 File VASS\fnc\fn_shop.sqf [TER_fnc_shop], line 2742

 

  • Like 1

Share this post


Link to post
Share on other sites
37 minutes ago, accuracythruvolume said:

It get this with the new version:

 


 7:04:08 Error in expression <fncTparams;

_diff = _funds -_cost;Text = format ["<t align='right' color='%2'>%>
 7:04:08   Error position: <= format ["<t align='right' color='%2'>%>
 7:04:08   Error Reserved variable in expression
 7:04:08 File VASS\fnc\fn_shop.sqf [TER_fnc_shop], line 2742

 

 

Text is a reserved word because it's a command:

text

Share this post


Link to post
Share on other sites
2 hours ago, accuracythruvolume said:

It get this with the new version:

 


 7:04:08 Error in expression <fncTparams;

_diff = _funds -_cost;Text = format ["<t align='right' color='%2'>%>
 7:04:08   Error position: <= format ["<t align='right' color='%2'>%>
 7:04:08   Error Reserved variable in expression
 7:04:08 File VASS\fnc\fn_shop.sqf [TER_fnc_shop], line 2742

 

 

2 hours ago, sarogahtyp said:

 

Text is a reserved word because it's a command:

text

 

I suppose the line should have been:

_diffText = format ["<t align='right' color='%2'>%3%1$", _tCost, _tColor, _sign];

 

Share this post


Link to post
Share on other sites
6 hours ago, accuracythruvolume said:

It get this with the new version:

 


 7:04:08 Error in expression <fncTparams;

_diff = _funds -_cost;Text = format ["<t align='right' color='%2'>%>
 7:04:08   Error position: <= format ["<t align='right' color='%2'>%>
 7:04:08   Error Reserved variable in expression
 7:04:08 File VASS\fnc\fn_shop.sqf [TER_fnc_shop], line 2742

 

Oh that was not intentional. I rewrote part of the script and it seems that I missed the cursor position to delete the entire line 😅

New fix on GitHub.

  • Like 1

Share this post


Link to post
Share on other sites

Hello guys.

I can't add money to MP players when one of them kills a unit.

I tried to put that into init.sqf file.

Spoiler

addMissionEventHandler ["EntityKilled",{

    params ["_killedUnit","_killer","_triggerMan"];

    if (side _killedUnit isEqualTo east) then {
		_killer addRating 500;
    };
}];

 

In MP it's works but just for me :/

 

Any Idea ?

 

thx <3

Share this post


Link to post
Share on other sites

That's because the addRating command needs the _killer to be local (welcome to hell aka MP scripting!). The better way to handle things is to put this script into the initServer.sqf:

addMissionEventHandler ["EntityKilled",{

    params ["_killedUnit","_killer","_triggerMan"];

    if (side group _killedUnit isEqualTo east) then {
		[_killer, 500] remoteExec ["addRating",_killer];
    };
}];

The eventhandler executes the code in the brackets on the server only. The remoteExec command executes the addRating command on the _killer's computer (where he is also local). On another note: If I am correct then the side of the _killedUnit will always be civillian because he is dead. A better way to get the side of a deceased unit is to get the side of it's group.

  • Like 1

Share this post


Link to post
Share on other sites

Hey man, any idea how to make the money system of ravage work for this? Ravage has a simple money system. the money is physical, you put it in your inventory. classname is "rvg_money"

EDIT: I did a bit of tinkering fn_VASShandler sqf and did this:
 

/*
    Author: 7erra <https://forums.bohemia.net/profile/1139559-7erra/>

    Description:
     VASS calls this function when certain events happen. Add your own code to change behaviour.
     (Similar to BIS_fnc_callScriptedEventHandler)

    Parameter(s):
     0: STRING - Mode in which the functions is called
     1: ARRAY - Passed arguments

    Returns:
     See sub functions
*/

params ["_mode",["_this",[]]];

switch _mode do {
    case "getMoney":{
        /*
            Description:
             VASS wants to know how much money the unit has

            Parameter(s):
             0: OBJECT - Unit whose money is requested

            Has to return:
             NUMBER - Unit's money
        */
        params ["_unit"];
        /* EXAMPLE */
        ({_x isEqualTo "rvg_money"} count magazines _unit)
    };
    case "setMoney":{
        /*
            Description:
             VASS changes the amount of money the player has

            Parameter(s):
             1: OBJECT - Unit whose money will be changed
             0: NUMBER - Amount of money changed (can be positive or negative)

            Has to return:
             Nothing
        */
        params ["_unit", "_change"];
        /* EXAMPLE */
        _unit addMagazines ["rvg_money", _change];
    };
};


 

With that I got to show my current ravage money in my inventory on the shop, it shows the difference if you buy something, etc. but it doesnt remove a certain amount of ravage money in my inventory after I buy. for example, I have 1,200 rvg money. I buy a a gun priced at 200. The shop lets me buy it because I have 1,200 rvg money. But then after I buy, it my money is still at 1,200 instead of 1,000. Any idea? (Sorry, not so good in scripting. I only got to write the script above through bits and pieces searching on google.

UPDATE: Got it. Borrowed this code from HallyG of HAL's shop.
   

 case "setMoney":{
        /*
            Description:
             VASS changes the amount of money the player has

            Parameter(s):
             1: OBJECT - Unit whose money will be changed
             0: NUMBER - Amount of money changed (can be positive or negative)

            Has to return:
             Nothing
        */
        params ["_unit", "_funds"];
        /* EXAMPLE */
        if (_funds < 0) then {
  for "_i" from 1 to (abs _funds) do {
    _unit removeItem "rvg_money";
  };
} else {
  _unit addMagazines ["rvg_money", _funds];
};
    };
};

 

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×