Eluna icon indicating copy to clipboard operation
Eluna copied to clipboard

Restore DepositBankMoney & WithdrawBankMoney

Open ConradBunton opened this issue 8 years ago • 8 comments

Simply revert the commit "Remove guild bank methods" Date : 2017.07.19 5:12pm

I dont understand why it was removed cause it worked fine.

ConradBunton avatar Nov 15 '17 18:11 ConradBunton

The functions only allowed you to deposit an amount of money, but not check if it was successful or even possible. For example there was no way to check the lower or upper bounds of the guild stash. That is why you have no idea how much you actually put or take from the bank - could be for example that you take money from an empty bank or put money to a full bank.

Rochet2 avatar Nov 15 '17 21:11 Rochet2

Ah ok Can't add a DB check to fix that problem ?

ConradBunton avatar Nov 15 '17 22:11 ConradBunton

So what about Player:ModifyMoney ? There's the same problem.

ConradBunton avatar Nov 21 '17 22:11 ConradBunton

The situation is a bit different since you can check how much money the player has: http://www.elunaengine.com/Player/GetCoinage.html (function naming was influenced by arcemu I am guessing..) Also min and maximum money is a constant.

Rochet2 avatar Nov 21 '17 23:11 Rochet2

I just added a check system in my LUA script and I have no problem at all with that commands.

ConradBunton avatar Nov 22 '17 06:11 ConradBunton

@ConradBunton Can you show what kind of "check system" you used? Just in case it helps with this.

Rochet2 avatar Nov 22 '17 09:11 Rochet2

It's just a generic script but it's something like that...

=========== DepositBankMoney == If there's too much money, it only add money to the maximal.

Deposit = xxx	-- xxx = Money to deposit
Max_GBank = yyy	-- yyy = Maximal money in the bank

if (player:IsInGuild()) then
	Chk_Deposit = CharDBQuery("SELECT * FROM guild WHERE guildid = '"..player:GetGuildId().."';")
	if Chk_Deposit then
		Current_Bank = Chk_Deposit:GetUInt32(11) -- BankMoney Column
		if Current_Bank + Deposit > Max_GBank then
			-- Delete the next line to change the result. (No transaction when too much money)
			player:GetGuild():DepositBankMoney(player, (Max_GBank-Current_Bank))
			player:SendBroadcastMessage("Too much money in your guild bank")
		else
			player:GetGuild():DepositBankMoney(player, Deposit)
		end
	end
end

========== WithdrawBank == If there's not enough money, it just withdraw to left the minimal.

Withdraw = xxx	-- xxx = Money to Withdraw
Min_GBank = 0	-- Can use more than 0

if (player:IsInGuild()) then
	Chk_Withdraw = CharDBQuery("SELECT * FROM guild WHERE guildid = '"..player:GetGuildId().."';")
	if Chk_Withdraw then
		Current_Bank = Chk_Withdraw:GetUInt32(11) -- BankMoney Column
		if (Current_Bank - Withdraw < Min_GBank) then
			-- Delete the next line to change the result. (No transaction when not enough money)
			player:GetGuild():WithdrawBankMoney(player, (Current_Bank-Min_GBank))
			player:SendBroadcastMessage("Not enough money in your guild bank")
		else
			player:GetGuild():WithdrawBankMoney(player, Withdraw)
		end
	end
end

ConradBunton avatar Nov 22 '17 12:11 ConradBunton

Does it help you ?

ConradBunton avatar Nov 29 '17 11:11 ConradBunton