Jump to content

Virtual Arsenal Shop System working with epoch


Alsekwolf

Recommended Posts

I spent some time getting Virtual Arsenal Shop System (VASS) working in epoch recently and figured I'd share that (though may not be the best way to do this, as it's my first time really making anything for arma or epoch).

Full credit to:
https://github.com/7erra/VASS-Virtual-Arsenal-Shop-System

EDIT:  I created a fork on github with basically all of the below changes, so you only need to merge description.ext, init.sqf and CfgFunctions.hpp. (Instructions for doing so are at the top of the readme in the repo.)
https://github.com/Alsekwolf/VASS-Virtual-Arsenal-Shop-System


Step 0:
get the "VASS" folder from that Github and place it at the root of your mission file.

Step 1:

Add to description.ext

#include "VASS\gui\cfgGUI.hpp"

Step 2:

Add to CfgFunctions (Default for epoch would be in mission file \epoch_config\Configs\CfgFunctions.hpp)
 

class TER
{
	class VASS
	{
		file = "VASS\fnc";
		class shop {
			preInit = 1;
		};
		class getItemValues {};
		class VASShandler {};
		class addShopCargo {};
		class addShop {};
		class resetTimer {};
	};
};

Step 3:

Now you are going to need an object in SQF code at wherever you want the shop to be accessed, something like
 

	private _objects = [];
	private _objectIDs = [];
	
	private _item1 = objNull;
	_item1 = createVehicle ["Land_CashDesk_F",[11843.6,13031.7,0.0419998],[],0,"CAN_COLLIDE"];
	_this = _item1;
	_objects pushback _this;
	_objectIDs pushback 1;
	_this setPosWorld [11843.6,13031.7,6.992];
	_this setVectorDirAndUp [[-0.956641,0.29127,0.00066811],[0.000698392,0,1]];
	trader123 = _this;
	_this setVehicleVarName "trader123";
	publicVariable "trader123";

but you won't want to use that, it does need a name Variable though, like "trader123" shown there (the rest of the code will assume you use trader123, or change it in any occurrences).
 

Step 4:
Create a SQF somewhere in the mission file, mine will be TraderCFG\Trader.sqf and add this code to it
 

// Client Stuff //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (hasInterface) then
{
_shop = [trader123,"Shop test"] call TER_fnc_addShop;
};
// Client Stuff //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Shop Inventory //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
_cargoArray =
[
	// array in format: "class", price, amount
	"arifle_MSBS65_F",100,true,
    "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_Wetsuit",25,true,
	"U_B_HeliPilotCoveralls",10,true,
    "U_B_CombatUniform_mcam",15,5,
    "30Rnd_762x39_Mag_F",5,true,
    "30Rnd_65x39_caseless_mag",13,true
];
// Shop Inventory ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Server Stuff //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if(isServer) then
{	
	// Objects /////////////////////////////////////////////////////////////
	private _objects = [];
	private _objectIDs = [];
	
	private _item1 = objNull;
	_item1 = createVehicle ["Land_CashDesk_F",[11843.6,13031.7,0.0419998],[],0,"CAN_COLLIDE"];
	_this = _item1;
	_objects pushback _this;
	_objectIDs pushback 1;
	_this setPosWorld [11843.6,13031.7,6.992];
	_this setVectorDirAndUp [[-0.956641,0.29127,0.00066811],[0.000698392,0,1]];
	trader123 = _this;
	_this setVehicleVarName "trader123";
	publicVariable "trader123";
	// Objects /////////////////////////////////////////////////////////////
	
	// Add Shop Inventory /////////////////////////////////////////////////
	[trader123, _cargoArray, 2] call TER_fnc_addShopCargo;
	// Add Shop Inventory /////////////////////////////////////////////////
};
// Server Stuff //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Replace all the code inside "// Objects //" with the object code you got in step 3, and make the any occurrences of "trader123" match what you name yours.

Step 5:
you'll need to add that file to run in your init.sqf, something like

call compile preprocessFileLineNumbers "TraderCFG\Trader.sqf";

Step 6:
navigate to "VASS/fnc/fn_VASShandler.sqf" and in change "getMoney" to be like

	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"];
		_Crypto = EPOCH_playerCrypto;
		_Crypto;
	};

Step 7:
you'll need 2 files, name doesn't really matter but mine are "TraderSetMoney_init.sqf" and "TraderSetMoney.sqf"
in TraderSetMoney_init or whatever you name it, put

if(isServer)then{
	Alsekwolf_server_TraderSetMoney = compileFinal preprocessFileLineNumbers "TraderSetMoney.sqf";
	"Alsekwolf_TakeGive" addPublicVariableEventHandler {(_this select 1) call Alsekwolf_server_TraderSetMoney};
};

(Change the TraderSetMoney.sqf name to whatever you make that file, or add if its in a folder and not root mission file)

Step 8:

put the following code in "TraderSetMoney.sqf" or whatever you name it
 

_this call EPOCH_server_effectCrypto;

Step 9:

put the following code in your init.sqf and make it match your naming

[] ExecVM "TraderSetMoney_init.sqf"; 

Step 10:

in "VASS/fnc/fn_VASShandler.sqf" change "setMoney" to match
 

	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"];
		Alsekwolf_TakeGive = [player,_change];
		publicVariableServer "Alsekwolf_TakeGive";
	};

 

That should be everything, I'm really sorry if I missed anything, it's been about 2 weeks of trying different things to get this working.
Also sorry for the bad writing of instructions, not great at that.

Edited by Alsekwolf
including link to fork on github that includes all the changes to make it easier to use.
Link to comment
Share on other sites

A few random tidbits about adding inventory to a shop

you can do something like

// Shop Inventory //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
_weaponsArray = [] call compileFinal preprocessfilelinenumbers "TraderCFG\weapons.sqf";
// Shop Inventory //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

in place of the
 

// Shop Inventory //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
_cargoArray =
[
	...
];
// Shop Inventory //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

and then do

_weaponArray =
[
	// array in format: "class", price, amount
	"arifle_Katiba_F",100,true,
	"arifle_Katiba_C_F",100,true,
	"arifle_Mk20_F",100,true
];

_weaponArray

in the weapons.sqf targeted by the above code. (Useful for having every single arma 3 gun which is like 190 lines, not in the main file.)

Just be careful about how inventory a shop has, as they can make it loading very slow, think about spreading mods/categories of items out across separate "shops".

Link to comment
Share on other sites

Quote

though may not be the best way to do this, as it's my first time really making anything for arma or epoch

Why not? It is the best way to get feedback from others! In case bugs came up, we can try to fix them together!
Unfortunately I had not the time for now to test it, but I will do as soon as possible!
Nice to see new guys publishing their work!!

Link to comment
Share on other sites

44 minutes ago, He-Man said:

Why not? It is the best way to get feedback from others! In case bugs came up, we can try to fix them together!
Unfortunately I had not the time for now to test it, but I will do as soon as possible!
Nice to see new guys publishing their work!!

I mostly just meant that I wasn't sure if this was the best way to give instructions/spot to share this as I haven't done anything here before and that I wasn't sure if there are better "practices" for achieving what I did. (Basically just asking for feedback.)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...