Jump to content
7erra

[Release] Virtual Arsenal Shop System

Recommended Posts

Yup just the way I would have done it 😉

  • Like 1

Share this post


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

Yup just the way I would have done it 😉

Btw, where do you find the night vision goggles in your vass eden mod?

Share this post


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

Btw, where do you find the night vision goggles in your vass eden mod?

At the moment nowhere. Hard to explain why not but I have a fix for that ready. There are also other items which cant be added but I included them in the next update. Still polishing another feature before release so stay tuned ^^

  • Like 1

Share this post


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

Still polishing another feature before release so stay tuned ^^

Awesome. Thank you very much man. 👌

Share this post


Link to post
Share on other sites

Hmmm does the trader have to be added at the start of the mission in the init.sqf?   

 

I'm attempting to add a trader dynamically and getting no luck.

 

Can the below work to ensure JIP functionality?

 

[_seller,_sellerText] remoteExec ["TER_fnc_addShop",-2];

[_seller, _cargoArray, 2] remoteExec ["TER_fnc_addShopCargo",2];

Share this post


Link to post
Share on other sites

The addShop function is a local one so placing it in the init.sqf should be fine to guarantee JIP compability. For dynamically adding a shop you should remoteExec the function like this:

[_seller,_sellerText] remoteExec ["TER_fnc_addShop",[0, -2] select isDedicated];

This way the action will only be added to players. If the server is a dedicated one and not a hosted one then the action is not added on the server (because it can't access it either way). Only execute this code from one instance, eg the server, because remoteExececing from the init.sqf is unneccessary network trafic and might lead to some problems when a new player joins.

The addShopCargo function can be either local or global (and JIP compatible). The fourth parameter defines its behaviour. By default the cargo is shared across the network.

I have to admit that I wasnt able to test the MP compability but I tried to put my theoretical knowledge to use.

Share this post


Link to post
Share on other sites

This is simply fantastic. 

 

-k 

Share this post


Link to post
Share on other sites

When VASS Mod is activated I am not able to use "backspace" or "Escape" in Editor for changing codes in a unit init line.

It happens in Arma 3 Devbranch

Share this post


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

When VASS Mod is activated I am not able to use "backspace" or "Escape" in Editor for changing codes in a unit init line.

Oh no. I think I know where that problem comes from. Will fix asap.

Share this post


Link to post
Share on other sites

does this work with mods or do i have to add the classnames from the mods ?

 

I wanna use this script for killing ais u gain money and killing players u gain money.
And its gonna be an armory mission where u can do whatever. for now. cars will be free to use. but later on i might look for a shop thing for vehicles :P

 

is it possible to make an trigger for the kill reward ?
so when u are in this radius u get the money if not u dont ?
i dont wanna edit my PvE are to add text in bcs there is already an radius around it etc :D

 

this is the mission i am currently editing for fun :D

https://steamcommunity.com/sharedfiles/filedetails/?id=688299467

Share this post


Link to post
Share on other sites
4 hours ago, TimRambo said:

does this work with mods or do i have to add the classnames from the mods ?

Anything that is available in the normal arsenal is also available in the shop so it does work with mods. I am not sure what you mean with adding classnames? Of course you have to manually add the content of the shop either by script or with my mod.

 

4 hours ago, TimRambo said:

I wanna use this script for killing ais u gain money and killing players u gain money.

Regarding the money system: VASS only includes the shop version of the arsenal but nothing more. You will need to use another money system (like the one from HoverGuy's Simple Shops). VASS allows you to interact with said money system through the TER_fnc_VASShandler function.

 

4 hours ago, TimRambo said:

is it possible to make an trigger for the kill reward ?
so when u are in this radius u get the money if not u dont ?

Well addMissionEventhandler ("EntitiyKilled") together with a condition (inArea command) should work.

Share this post


Link to post
Share on other sites
On 10/7/2018 at 6:10 PM, 7erra said:

this addEventHandler ["Killed", { params ["_unit", "_killer", "_instigator", "_useEffects"]; _money = _killer getVariable [TER_moneyVariable,0];// get the variable, if not defined use default (0) _money = _money + 500;//add kill reward _killer setVariable [TER_moneyVariable, _money]; "You received 500$" remoteExec ["hint",_killer];// execute code local on the pc of the killer }];

well i saw this on the first page.

and thats what i wanna add into the trigger when unit Opfor is in a trigger and ofc blufor when in pvp area ofc

so is it possible to place it in an trigger instead of adding it to every single unit i have xD ?
bcs then i can restrict on when u get money and when u dont get money :D

Share this post


Link to post
Share on other sites
21 hours ago, TimRambo said:

so is it possible to place it in an trigger instead of adding it to every single unit i have xD ?

 

23 hours ago, 7erra said:

Well addMissionEventhandler ("EntitiyKilled") together with a condition (inArea command) should work.

The mission eventhandler is not bound to a single unit. It tracks every unit which is killed. You can check if a unit is inside of the trigger with the inArea command so the script could look like this:

// init.sqf
addmissioneventhandler ["EntityKilled",{
	params ["_killed", "_killer", "_instigator"];
	if (isNull _instigator) then {_instigator = UAVControl vehicle _killer select 0}; // UAV/UGV player operated road kill
	if (isNull _instigator) then {_instigator = _killer}; // player driven vehicle road kill

	if (_instigator != player OR !(_killed inArea your_trigger) OR !(_instigator inArea your_trigger)) exitwith {};
	// Add your code here:
}];

You just have to name your trigger your_trigger.

Share this post


Link to post
Share on other sites

would it look like that ?

// init.sqf
addmissioneventhandler ["EntityKilled",{
	params ["_killed", "_killer", "_instigator"];
	if (isNull _instigator) then {_instigator = UAVControl vehicle _killer select 0}; // UAV/UGV player operated road kill
	if (isNull _instigator) then {_instigator = _killer}; // player driven vehicle road kill

	if (_instigator != player OR !(_killed inArea your_trigger) OR !(_instigator inArea your_trigger)) exitwith {};
	// Add your code here:
this addEventHandler ["Killed", {
	params ["_unit", "_killer", "_instigator", "_useEffects"];
	_money = _killer getVariable [TER_moneyVariable,0];// get the variable, if not defined use default (0)
	_money = _money + 500;//add kill reward
	_killer setVariable [TER_moneyVariable, _money];
	"You received 500$" remoteExec ["hint",_killer];// execute code local on the pc of the killer
}];

Share this post


Link to post
Share on other sites

No need to add the killed eventhandler:

// init.sqf
addmissioneventhandler ["EntityKilled",{
	params ["_killed", "_killer", "_instigator"];
	if (isNull _instigator) then {_instigator = UAVControl vehicle _killer select 0}; // UAV/UGV player operated road kill
	if (isNull _instigator) then {_instigator = _killer}; // player driven vehicle road kill

	if (_instigator != player OR !(_killed inArea your_trigger) OR !(_instigator inArea your_trigger)) exitwith {};
	// Add your code here:
	_money = _instigator getVariable ["your_variable",0];// get the variable, if not defined use default (0)
	_money = _money + 500;//add kill reward
	_instigator setVariable ["your_variable", _money];
	"You received 500$" remoteExec ["hint",_instigator];// execute code local on the pc of the killer
}];

 

Share this post


Link to post
Share on other sites

Tested on dedicated.  Works :slayer:

However....  If your shop contains ALOT of items.. it can take awhile to load.

 

I have a trader with ~1700 items and it takes ~35sec for the shop to load... everytime  :eh:

Share this post


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

Tested on dedicated.  Works :slayer:

However....  If your shop contains ALOT of items.. it can take awhile to load.

 

I have a trader with ~1700 items and it takes ~35sec for the shop to load... everytime  :eh:

does ur trader automaticly take in modded weapons XD ?

u dont have kill enemies and u get money ?
if u do could you send me template of the mission u have only with this script and the code for killing enemies and u get money :P ?

Share this post


Link to post
Share on other sites

I use this in init.sqf:

 

if (!isServer) exitWith {}; 

#include "scripts\fnc_BountyPayout.sqf"

With fnc_BountyPayout.sqf being:

 

fnc_BountyPayout = addMissionEventHandler ["EntityKilled", 
{
	_killed = _this select 0;
	_killer = _this select 1;
	
	_killedSide = (side group _killed);
	_killedFaction = faction _killed;
	
	if (DebugMode) then
	{
		_txt = "Killed unit: " + str(_killed) + "." + " Killer: " + str(_killer) + ".";
		_txt remoteExec ["systemChat"];
		
		_txt2 = "Faction of Killed unit: " + _killedFaction;
		_txt2 remoteExec ["systemChat"];
		
		_txt2 = "Side of Killed unit: " + str(_killedSide);
		_txt2 remoteExec ["systemChat"];
		
	};
	if (_killedSide == resistance) then   
	{
		if ((isplayer _killer) and (_killed isKindOf "Man")) then  // Indep Infantry
		{
			// Payout 50-70
			_randomNum = ((((floor(random 5)) + 4) * 5) + 30); 
			
			_indepKills = _killer getVariable "Kills_Taliban_Infantry";
			_indepKills = _indepKills + 1;
			_killer setVariable ["Kills_Taliban_Infantry", _indepKills,true];
			
			[_killer, _randomNum] call fnc_addFunds;

		};
	};
	
	if ((_killedSide == east) and (_killed isKindOf "Man")) then  // Opfor Infantry
	{
		if (isplayer _killer) then
		{
			// Payout 120-150
			_randomNum = ((((floor(random 7)) + 4) * 5) + 100); 
			
			_opforKills = _killer getVariable "Kills_Opfor_Infantry";
			_opforKills = _opforKills + 1;
			_killer setVariable ["Kills_Opfor_Infantry", _opforKills,true];
			
			[_killer, _randomNum] call fnc_addFunds;
		};
	};
	
	if ((_killedSide == civilian) and (_killed isKindOf "Man")) then
	{
		if (isplayer _killer) then
		{
			0 = [_killer,_killed] execVM "scripts\fnc_CivilianKilledPenalty.sqf";
			
			_civKills = _killer getVariable "Kills_Civilians";
			_civKills = _civKills + 1;
			_killer setVariable ["Kills_Civilians", _civKills,true];

		};
	};
	 
	// Player death
	if (_killedSide == west) then
	{
		if (isplayer _killed) then
		{
			
		};
	};
};

 

fnc_addfunds is:

 

// usage:   [_unit, _amount] call fnc_addFunds;

_unit = _this select 0;
_payout = _this select 1;

_oldValue = rating _unit;
_newValue = _oldValue + _payout;

_unit addRating _payout;

if (_payout > 0) then
{
	_earnedMoney = _unit getVariable "EarnedMoney";
	_earnedMoney = _earnedMoney + _payout;
	_unit setVariable ["EarnedMoney", _earnedMoney,true];
};

if (DebugMode) then
{
	_txt = "Adding " + str(_payout) + " to " + name _unit + ".";
	_txt remoteExec ["systemChat"];
	_txt = name _unit + "'s new balance: " + str(_newValue) + ".";
	_txt remoteExec ["systemChat"];
};

 which can be declared as:

fnc_addFunds = compile preProcessFileLineNumbers "scripts\fnc_addFunds.sqf";

 

You can even further expand on the bounty payout function to include vehicles:

 

/////  Vehicle destroyed tests   /////
	
	{
		if ((typeOf _killed == _x) and (isplayer _killer)) then 
		{
			// Payout 300-400
			_randomNum = ((((floor(random 11)) + 0) * 10) + 300); 
			[_killer, _randomNum] call fnc_addFunds;
		};
	} forEach OpforMotArray;
	
	{
		if ((typeOf _killed == _x) and (isplayer _killer)) then 
		{
			// Payout 350-400
			_randomNum = ((((floor(random 11)) + 10) * 5) + 300); 
			[_killer, _randomNum] call fnc_addFunds;
		};
	} forEach OpforAPCArray;
	
	{
		if ((typeOf _killed == _x) and (isplayer _killer)) then 
		{
			// Payout 1000-1500
			_randomNum = ((((floor(random 50)) + 1) * 10) + 1000); 
			[_killer, _randomNum] call fnc_addFunds;
		};
	} forEach OpforTankArray;
	
	{
		if ((typeOf _killed == _x) and (isplayer _killer)) then 
		{
			// Payout 300-400
			_randomNum = ((((floor(random 11)) + 0) * 10) + 300); 
			[_killer, _randomNum] call fnc_addFunds;
		};
	} forEach IndVehArray;

 

Where the various arrays are arrays of vehicle classnames.

 

if you realllllllllllllllllllllllllllllly wanna go nuts, you could be super granular and make every type of vehicle be worth a separate amount  :shhh: 

  • Like 1

Share this post


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

I use this in init.sqf:

 


if (!isServer) exitWith {}; 

#include "scripts\fnc_BountyPayout.sqf"

With fnc_BountyPayout.sqf being:

 


fnc_BountyPayout = addMissionEventHandler ["EntityKilled", 
{
	_killed = _this select 0;
	_killer = _this select 1;
	
	_killedSide = (side group _killed);
	_killedFaction = faction _killed;
	
	if (DebugMode) then
	{
		_txt = "Killed unit: " + str(_killed) + "." + " Killer: " + str(_killer) + ".";
		_txt remoteExec ["systemChat"];
		
		_txt2 = "Faction of Killed unit: " + _killedFaction;
		_txt2 remoteExec ["systemChat"];
		
		_txt2 = "Side of Killed unit: " + str(_killedSide);
		_txt2 remoteExec ["systemChat"];
		
	};
	if (_killedSide == resistance) then   
	{
		if ((isplayer _killer) and (_killed isKindOf "Man")) then  // Indep Infantry
		{
			// Payout 50-70
			_randomNum = ((((floor(random 5)) + 4) * 5) + 30); 
			
			_indepKills = _killer getVariable "Kills_Taliban_Infantry";
			_indepKills = _indepKills + 1;
			_killer setVariable ["Kills_Taliban_Infantry", _indepKills,true];
			
			[_killer, _randomNum] call fnc_addFunds;

		};
	};
	
	if ((_killedSide == east) and (_killed isKindOf "Man")) then  // Opfor Infantry
	{
		if (isplayer _killer) then
		{
			// Payout 120-150
			_randomNum = ((((floor(random 7)) + 4) * 5) + 100); 
			
			_opforKills = _killer getVariable "Kills_Opfor_Infantry";
			_opforKills = _opforKills + 1;
			_killer setVariable ["Kills_Opfor_Infantry", _opforKills,true];
			
			[_killer, _randomNum] call fnc_addFunds;
		};
	};
	
	if ((_killedSide == civilian) and (_killed isKindOf "Man")) then
	{
		if (isplayer _killer) then
		{
			0 = [_killer,_killed] execVM "scripts\fnc_CivilianKilledPenalty.sqf";
			
			_civKills = _killer getVariable "Kills_Civilians";
			_civKills = _civKills + 1;
			_killer setVariable ["Kills_Civilians", _civKills,true];

		};
	};
	 
	// Player death
	if (_killedSide == west) then
	{
		if (isplayer _killed) then
		{
			
		};
	};
};

 

fnc_addfunds is:

 


// usage:   [_unit, _amount] call fnc_addFunds;

_unit = _this select 0;
_payout = _this select 1;

_oldValue = rating _unit;
_newValue = _oldValue + _payout;

_unit addRating _payout;

if (_payout > 0) then
{
	_earnedMoney = _unit getVariable "EarnedMoney";
	_earnedMoney = _earnedMoney + _payout;
	_unit setVariable ["EarnedMoney", _earnedMoney,true];
};

if (DebugMode) then
{
	_txt = "Adding " + str(_payout) + " to " + name _unit + ".";
	_txt remoteExec ["systemChat"];
	_txt = name _unit + "'s new balance: " + str(_newValue) + ".";
	_txt remoteExec ["systemChat"];
};

 which can be declared as:

fnc_addFunds = compile preProcessFileLineNumbers "scripts\fnc_addFunds.sqf";

 

You can even further expand on the bounty payout function to include vehicles:

 


/////  Vehicle destroyed tests   /////
	
	{
		if ((typeOf _killed == _x) and (isplayer _killer)) then 
		{
			// Payout 300-400
			_randomNum = ((((floor(random 11)) + 0) * 10) + 300); 
			[_killer, _randomNum] call fnc_addFunds;
		};
	} forEach OpforMotArray;
	
	{
		if ((typeOf _killed == _x) and (isplayer _killer)) then 
		{
			// Payout 350-400
			_randomNum = ((((floor(random 11)) + 10) * 5) + 300); 
			[_killer, _randomNum] call fnc_addFunds;
		};
	} forEach OpforAPCArray;
	
	{
		if ((typeOf _killed == _x) and (isplayer _killer)) then 
		{
			// Payout 1000-1500
			_randomNum = ((((floor(random 50)) + 1) * 10) + 1000); 
			[_killer, _randomNum] call fnc_addFunds;
		};
	} forEach OpforTankArray;
	
	{
		if ((typeOf _killed == _x) and (isplayer _killer)) then 
		{
			// Payout 300-400
			_randomNum = ((((floor(random 11)) + 0) * 10) + 300); 
			[_killer, _randomNum] call fnc_addFunds;
		};
	} forEach IndVehArray;

 

Where the various arrays are arrays of vehicle classnames.

 

if you realllllllllllllllllllllllllllllly wanna go nuts, you could be super granular and make every type of vehicle be worth a separate amount  :shhh: 

i rly wish i knew mr.sqf tbh like it would be so much fun to have everything in the game + mods being amount from x to x in the shop with weapons and vehicles and include the GF_killfeed when u kill u get X amount of money and with the money u buy shit thats the kind of sandbox i am aiming for atm but without knowledge is a bit hard XDD

But this will help i hope haha XD

what spawner do u use for vehicles ?
is it this shop u also use for vehicles ?

Share this post


Link to post
Share on other sites

As far as the modded weapons.. I had to declare everything in the trader array.  Handy thing about this using arsenal though, if you declare NIArms guns for instance and a player does not have it loaded, they just won't see any of them.

Share this post


Link to post
Share on other sites
1 minute ago, accuracythruvolume said:

I use something separate for vehicles.  Custom dialog.  Perhaps the OP could make a version of this for vehicles as well?  *wink wink*

do you have an link for that custom dialog been trying to find that script since i am making my own sandbox :P
I know that losis armory and the advanced version of it use a script called dialog but no idea the name of the script itself xD

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

×