Jump to content

[REQUEST] Smelting feature


Recommended Posts

Hi guys,

 

Does anyone have a working code for smelting?

 

We are using single currency and everything is perfect -almost- but one missing thing is smelting options.

If a player is at his base with Gold Bars/10oz Gold Bars/Briefcases with all that wealth he still cannot pay his base maintenance fees because he doesn't have any "gold coins" which is the only accepted payment form.

 

I would like to make it so that as long as there's a fire barrel (or any other fire source around - such as the fireplace at trade cities) around, player can convert coins to physical gold (gold bar / 10 oz gold bar / briefcase) and vice versa.

 

Coins-to-gold workflow should be something like:

1. A popup window should ask how many gold coins to convert to physical gold

2. Remove the cash from player

3. Spawn corresponding amount of gold items in his personal inventory

 

Gold-to-coins workflow:

Perhaps we can have a fancy right click option on physical gold items [only if there's a lit fire source near by] > "convert to coins" > remove physical object and top up players gold coins.

Link to comment
Share on other sites

Not sure if this will work or not.

 

Download these two files

https://github.com/UPGStorm/Smeltbars/blob/master/player_smeltbars.sqf

https://github.com/UPGStorm/Smeltbars/blob/master/player_smeltcoins.sqf

 

Save them to your mission/gold folder

Next open up your variables.sqf and add this somewhere at the top next to the other coin stuff

SmeltingGoldBarsToCoinsRate = 1000; // How many gold coins are in a gold bar

Next open up fn_selfActions.sqf

find 

// Zupa- SC - Give Money
	if (_isMan and _isAlive and !_isZombie and !_isAnimal and !(_traderType in serverTraders)) then {
		if (s_givemoney_dialog < 0) then {
			s_givemoney_dialog = player addAction [format["Give Money to %1", (name _cursorTarget)], "gold\give_player_dialog.sqf",_cursorTarget, 3, true, true, "", ""];
		};
	} else {
		player removeAction s_givemoney_dialog;
		s_givemoney_dialog = -1;
	};

Add this right below the closing bracket

if (isNil "SmeltingInProgress") then {
		SmeltingInProgress = false;
	};

	_player_money = player getVariable["cashMoney",0];
	// Smelt gold coins
	if (inflamed _cursorTarget and (_player_money > SmeltingGoldBarsToCoinsRate) and !SmeltingInProgress) then {
		if (s_smelt_coins < 0) then {
			if (_player_money > 10000) then {
				s_smelt_coins = player addAction [format["Smelt %1 %2 into a 10oz Gold Bar", (SmeltingGoldBarsToCoinsRate * 10), CurrencyName], "gold\player_smeltcoins.sqf","ItemGoldBar10oz", 3, true, true, "", ""];
			} else {
				s_smelt_coins = player addAction [format["Smelt %1 %2 into a Gold Bar", SmeltingGoldBarsToCoinsRate, CurrencyName], "gold\player_smeltcoins.sqf","ItemGoldBar", 3, true, true, "", ""];
			};
		};
	} else {
		player removeAction s_smelt_coins;
		s_smelt_coins = -1;
	};

	_hasGoldBars = "ItemGoldBar" in _magazinesPlayer;
	// Smelt bars into coins
	if (inflamed _cursorTarget and (_hasGoldBars) and !SmeltingInProgress) then {
		if (s_smelt_bars < 0) then {
			s_smelt_bars = player addAction [format["Smelt a Gold Bar into %1 %2", SmeltingGoldBarsToCoinsRate, CurrencyName], "gold\player_smeltbars.sqf","ItemGoldBar", 3, true, true, "", ""];
		};
	} else {
		player removeAction s_smelt_bars;
		s_smelt_bars = -1;
	};
	
	_has10ozGoldBars = "ItemGoldBar10oz" in _magazinesPlayer;
	// Smelt bars into coins
	if (inflamed _cursorTarget and (_has10ozGoldBars) and !SmeltingInProgress) then {
		if (s_smelt_10bars < 0) then {
			s_smelt_10bars = player addAction [format["Smelt a 10oz Gold Bar into %1 %2", (SmeltingGoldBarsToCoinsRate * 10), CurrencyName], "gold\player_smeltbars.sqf","ItemGoldBar10oz", 3, true, true, "", ""];
		};
	} else {
		player removeAction s_smelt_10bars;
		s_smelt_10bars = -1;
	}; 

Then find

s_givemoney_dialog = -1;
	player removeAction s_bank_dialog; 

add this right above that

        player removeAction s_smelt_coins;
	s_smelt_coins = -1;
	player removeAction s_smelt_bars;
	s_smelt_bars = -1;
	player removeAction s_smelt_10bars;
	s_smelt_10bars = -1;

Profit!?!?!?

I haven't had time to really test if it works or not.

 

Credits to Maca for the smelting.

Link to comment
Share on other sites

  • 2 weeks later...

I just added your smelting to my server but.

it allows me to smelt all seems good, it takes the goldbar says smelted  into 10000 coins but does not give me any coins.

any thought on why ??

I can smelt the coins that It does not show in my wallet or my bank into gold bars..  so I kinda have them

Link to comment
Share on other sites

Instruction fix:

 

Next open up fn_damageActions.sqf should be fn_selfActions.sqf.

 

And the code works great, thank you for doing this.

how did you get this working ???

add anything extra ?

shows it works but I get no coins back just says it worked

where do the coins go ?? not my bank and not in my wallet :(

 

Do I need 

Custom HiveExt.dll Release   ?????

for this to work

Link to comment
Share on other sites

how did you get this working ???

add anything extra ?

shows it works but I get no coins back just says it worked

where do the coins go ?? not my bank and not in my wallet :(

 

Do I need 

Custom HiveExt.dll Release   ?????

for this to work

Are you using Soul's Hive?

 

Instruction fix:

 

Next open up fn_damageActions.sqf should be fn_selfActions.sqf.

 

And the code works great, thank you for doing this.

Thanks for the update.
Link to comment
Share on other sites

Calamity:  sorry did not know you posted a question here.  Only thing I did different than what the instructions said was the file I called out.  Other than that I followed it line for line.  I am using Zupa 1.1 that is upgraded to Souls 2.0.  Worked like a charm.

 

Storm:  Glad I could help, figure like most people I copy and paste the code but want to start contributing back the best I can. 

Link to comment
Share on other sites

  • 5 months later...

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...