Jump to content
Sign in to follow this  
CPT_ALPHA

System Money

Recommended Posts

Good night/day.
I have a question regarding a script that I am using. The issue is that when a player takes a Barrel to a certain area, I want it to add an amount of money to his account. In addition, with an addAction you can check how much money you have at that moment. It's a simple script, I don't want to handle buying or selling either, just adding money by taking a barrel (Not one, but all the ones I find) to a certain area.

I have an init with the following code:

cash = 0;

	player addAction ["MONEY", {hint format ["MONEY: %1", cash];},[],6];


And within the game, mark an area with the following code:

Condition:

this && (count( nearestObjects [thisTrigger, ["Land_BarrelSand_F"], 4, true] ) >0 )

 

When activated:

deleteVehicle ( ( nearestObjects [thisTrigger, ["Land_BarrelSand_F"], 4, true] ) select 0 ); 
cash = cash +96000;

The code works, the current money can be shown with a hint, and when a barrel is taken to an area, it adds the money. But I have 2 problems:

1. The addaction is displayed in the middle of the screen to display the money once, ok. But when I open and close inventory, it reappears in the middle of the screen, and when I pick something up, it reappears and is annoying. I want the addAction to not look like a pop-up, but only appear when called. Last but not least, if it is not possible, how can I set up a cash register, so that the money they carry is shown there?

Captura-de-pantalla-2023-01-14-005321.pn

2. Money only appears to the game host. If a player carries the barrel and collects the money, this is only added to me, the others continue to see 0, since they carried the barrel. Could it be because of the init? And how can it be solved?

Thank you to everyone who wants to help me, from the bottom of my heart.

Share this post


Link to post
Share on other sites

1.  showWindow parameter.

 

https://community.bistudio.com/wiki/addAction

this addAction
[
	"title",	// title
	{
		params ["_target", "_caller", "_actionId", "_arguments"]; // script
	},
	nil,		// arguments
	1.5,		// priority
	true,		// showWindow
	true,		// hideOnUse
	"",		// shortcut
	"true", 	// condition
	50,		// radius
	false,		// unconscious
	"",		// selection
	""		// memoryPoint
];
player addAction 
[
	"MONEY",	//title
	{
		hint format ["MONEY: %1", cash];
	},
	[],		//arguments
	6,		//priority
	false		//showWindow
];

 

2.  Locality. Try using initplayerLocal.sqf instead.

params ["_player"];
cash = 0;

	_player addAction ["MONEY", {hint format ["MONEY: %1", cash];},[],6, false];

 

Share this post


Link to post
Share on other sites
29 minutes ago, Harzach said:

1.  showWindow parameter.

 

https://community.bistudio.com/wiki/addAction


this addAction
[
	"title",	// title
	{
		params ["_target", "_caller", "_actionId", "_arguments"]; // script
	},
	nil,		// arguments
	1.5,		// priority
	true,		// showWindow
	true,		// hideOnUse
	"",		// shortcut
	"true", 	// condition
	50,		// radius
	false,		// unconscious
	"",		// selection
	""		// memoryPoint
];

player addAction 
[
	"MONEY",	//title
	{
		hint format ["MONEY: %1", cash];
	},
	[],		//arguments
	6,		//priority
	false		//showWindow
];

 

2.  Locality. Try using initplayerLocal.sqf instead.


params ["_player"];
cash = 0;

	_player addAction ["MONEY", {hint format ["MONEY: %1", cash];},[],6, false];

 


-------------------------------
Thanks, works great. I had also thought about the initplayerLocal, but I didn't apply it. I'll try it later, when someone connects
Take advantage of the fact that you know about that, do you know how to make it disappear when I save an item in a box and also add money?

Condition:

[Box1, "Item_Money"] call BIS_fnc_hasItem;

When activated:

Box1 removeItem "Item_Money";
cash = cash +1000;


There is another condition, which I found would be the next one, I just don't know how to apply it exactly. Maybe in the init?

_items = items player;

if ("Item_Monet" in _items) then {

};


Thank you also, for the above.

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
Sign in to follow this  

×