• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

NPC [Release] Forgotten server Banker!

The error was around line 80, this should fix it:
Code:
----------------------------------------------------------Made By MokerHamer----------------------------------------------
--------------------Special Thanks to: Talaturen and Jiddo  without them i coulden't have done this!------------------
------------------------------------------NOTE* THIS SCRIPT MAY ONLY BE RELEASED ON WWW.OTLAND.NET ONLY---------------------
------------------------------------This Script is specialde made for World Of Tramon V8.0-----------------------------
-----------------------------------------------------World Of Tramon Link: None Yet--------------------------------------
--------------------------------------------------------------------------------------------------------------------------------
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
function onCreatureAppear(cid)				npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) 			npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) 	npcHandler:onCreatureSay(cid, type, msg) end
function onThink() 						npcHandler:onThink() end
-- OTServ event handling functions end


---------Begin-Dont--Tough!--Noob--censative
function creatureSayCallback(cid, type, msg)
	if(npcHandler.focus ~= cid) then
		return false
	end
	
	local count = (getCount(msg))		
	local oldcount = getPlayerStorageValue(cid, 300)
    if(oldcount == -1) then
     oldcount = 0
	 setPlayerStorageValue(cid, 300, 0)
      end
---------End-Dont--Tough!--Noob--censative



---------------Begin  Crap that u can change it if u want-----------------------	
		bank_need_premium = 'Sorry, You need premium account to use the bank.'
		low_money_deposit = 'You do not have enough money in your deposit to withdraw, '..count..' Gold Pieces. '
		lost_track = 'Huh, What are you talking about?'
			
        if msgcontains(msg, 'banker') then
			selfSay('Hello. How can I help you? If you need some help just say information')
		elseif msgcontains(msg, 'information') then
			selfSay('Hello i am the city banker, you can do many things here like, Check your balance deposit and even withdraw!')
---------------End  Crap that u can change it if u want

-------------------------------------------------------------Begin of the Banker script---------------------------------------

------------------------Begin!--deposit--Crap----
            elseif msgcontains(msg, 'deposit') then
			if getPlayerPremiumDays(cid) > 0 then
			selfSay('How mutch would u like to deposit?')
					talk_state = 1
			else
				selfSay(bank_need_premium)
				talk_state = 0
			end
---deposit--Confurm--Yes
elseif isNumber(getCount(msg)) and talk_state == 1 then
talk_state = 0
if doPlayerRemoveMoney(cid, count) == TRUE then
setPlayerStorageValue(cid,300, oldcount+count)
selfSay('You have successfully deposit '..count..' Gold Pieces')
else
selfSay(lost_track)
end
------------------------End!--deposit--Crap----

------------------------Begin!--Balance--Crap----
            elseif msgcontains(msg, 'balance') then
			if getPlayerPremiumDays(cid) > 0 then
			selfSay('do u want to check your balance?')
					talk_state = 2
			else
				selfSay(bank_need_premium)
				talk_state = 0
			end
---Balance--Confurm--Yes
	elseif msgcontains(msg, 'yes') and talk_state == 2 then
		selfSay('You have '..oldcount..' Gold Pieces deposit.')

------------------------End!--Balance--Crap----

------------------------Begin!--withdraw--Crap----
            elseif msgcontains(msg, 'withdraw') then
			if getPlayerPremiumDays(cid) > 0 then
			selfSay('How mutch would u like to withdraw?')
					talk_state = 3
			else
				selfSay(bank_need_premium)
				talk_state = 0
			end
---withdraw--Confurm--Yes
elseif isNumber(getCount(msg)) and talk_state == 3 then
talk_state = 0
if count <= oldcount then
setPlayerStorageValue(cid,300, oldcount-count)
doPlayerAddMoney(cid, count)
selfSay('You have successfully withdrawed '..count..' Gold Pieces.')
else
selfSay(low_money_deposit)
end
------------------------End!--withdraw--Crap----

---No--To--All
		elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 3) then
			selfSay('Why the fuck dit you start this conversation anywais?')
			talk_state = 0
			end

	    return true
           end
	
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Lol i was just about to fix it when i saw your fix i remembered i had this in the top script

Code:
	local oldcount = getPlayerStorageValue(cid,300)
    if(oldcount == -1) then
     oldcount = 0
      end

so the same thing in balance would only bug it :p
 
transfer functions

I can write "doAddToBankAccount" (u can add "-200" - it will take 200 gp from account) and "doCheckPlayerAccount" (both work even when player is offline). I'll post this scripts tommorow.
With this functions you can "transfer" cash from one account to second:
Code:
if doCheckPlayerAccount(name_of_cid) >= transfer_amount then
doAddToBankAccount(name_of_cid, -transfer_amonut)
doAddToBankAccount(transfer_to_player, transfer_amount)
else
selfSay("you dont have enought money")
end
or something like that.
 
Last edited:
forever bug!

Lua Script Error: [Npc interface]
data/npc/scripts/Bank.lua:eek:nCreatureSay

luaGetPlayerStorageValue(). Player not found

Lua Script Error: [Npc interface]
data/npc/scripts/Bank.lua:eek:nCreatureSay

luaGetPlayerStorageValue(). Player not found
 
forever bug!

Lua Script Error: [Npc interface]
data/npc/scripts/Bank.lua:eek:nCreatureSay

luaGetPlayerStorageValue(). Player not found

Lua Script Error: [Npc interface]
data/npc/scripts/Bank.lua:eek:nCreatureSay

luaGetPlayerStorageValue(). Player not found


i know it's an bug that i couldent find, but the npc works correctly and i have never found bugs in the npc (only that one)
but i cant to any harm!
 
npc banker not working:
Code:
Lua Script Error: [Npc interface] 
data/npc/scripts/banker.lua:onCreatureSay

data/npc/scripts/banker.lua:25: attempt to call global 'getCount' (a nil value)

Lua Script Error: [Npc interface] 
data/npc/scripts/banker.lua:onCreatureSay

data/npc/scripts/banker.lua:25: attempt to call global 'getCount' (a nil value)

Lua Script Error: [Npc interface] 
data/npc/scripts/banker.lua:onCreatureSay

data/npc/scripts/banker.lua:25: attempt to call global 'getCount' (a nil value)

Lua Script Error: [Npc interface] 
data/npc/scripts/banker.lua:onCreatureSay

data/npc/scripts/banker.lua:25: attempt to call global 'getCount' (a nil value)
 
npc banker not working:
Code:
Lua Script Error: [Npc interface] 
data/npc/scripts/banker.lua:onCreatureSay

data/npc/scripts/banker.lua:25: attempt to call global 'getCount' (a nil value)

Lua Script Error: [Npc interface] 
data/npc/scripts/banker.lua:onCreatureSay

data/npc/scripts/banker.lua:25: attempt to call global 'getCount' (a nil value)

Lua Script Error: [Npc interface] 
data/npc/scripts/banker.lua:onCreatureSay

data/npc/scripts/banker.lua:25: attempt to call global 'getCount' (a nil value)

Lua Script Error: [Npc interface] 
data/npc/scripts/banker.lua:onCreatureSay

data/npc/scripts/banker.lua:25: attempt to call global 'getCount' (a nil value)


You forgot to add the GetCount script
 
where to add? i have added in scripts but give me this error:
Code:
Lua Script Error: [Npc interface] 
data/npc/scripts/banker.lua

data/npc/scripts/banker.lua:101: attempt to index global 'npcHandler' (a nil value)
Warning: [NpcScript::NpcScript] Can not load script. data/npc/scripts/banker.lua
 
where to add? i have added in scripts but give me this error:
Code:
Lua Script Error: [Npc interface] 
data/npc/scripts/banker.lua

data/npc/scripts/banker.lua:101: attempt to index global 'npcHandler' (a nil value)
Warning: [NpcScript::NpcScript] Can not load script. data/npc/scripts/banker.lua


lol this should be on line 101

if count <= oldcount then
 
I'm testing your bank NPC. I deleted few lines (npc shouldn't be only for pacc). I added:
Code:
----------------------------------------------------------Made By MokerHamer----------------------------------------------
--------------------Special Thanks to: Talaturen and Jiddo  without them i coulden't have done this!------------------
------------------------------------------NOTE* THIS SCRIPT MAY ONLY BE RELEASED ON WWW.OTLAND.NET ONLY---------------------
------------------------------------This Script is specialde made for World Of Tramon V8.0-----------------------------
-----------------------------------------------------World Of Tramon Link: None Yet--------------------------------------
--------------------------------------------------------------------------------------------------------------------------------
function creatureSayCallback(cid, type, msg)
	if(npcHandler.focus ~= cid) then
		return false
	end
	
	local count = (getCount(msg))		
	local oldcount = getPlayerStorageValue(cid, 300)
    if(oldcount == -1) then
     oldcount = 0
      end
		low_money_deposit = 'You do not have enough money in your deposit to withdraw, '..count..' GP.'
		lost_track = 'Huh, What are you talking about?'
			
        if msgcontains(msg, 'banker') then
			selfSay('Hello. How can I help you?')
		elseif msgcontains(msg, 'information') then
			selfSay('Hello I am the banker. You can check your balance, deposit and even withdraw!')
            elseif msgcontains(msg, 'deposit') then
			selfSay('How much would you like to deposit?')
			talk_state = 1
elseif isNumber(getCount(msg)) and talk_state == 1 then
talk_state = 0
if doPlayerRemoveMoney(cid, count) == TRUE then
setPlayerStorageValue(cid, 300, oldcount+count)
selfSay('You have successfully deposit '..count..' GP.')
else
selfSay(lost_track)
end
elseif msgcontains(msg, 'balance') then
talk_state = 0
selfSay('You have '..oldcount..' GP.')
elseif msgcontains(msg, 'withdraw') then
selfSay('How much would u like to withdraw?')
talk_state = 3
elseif isNumber(getCount(msg)) and talk_state == 3 then
talk_state = 0
if count <= oldcount then
setPlayerStorageValue(cid,300, oldcount-count)
doPlayerAddMoney(cid, count)
selfSay('You have successfully withdraw '..count..' GP.')
else
selfSay(low_money_deposit)
end
		elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 3) then
			selfSay('Can I do anything else for you?')
talk_state = 0
end

return true
end
	
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
to my "house-auction-web-system" npc, but here is one bug. When I say to NPC "hi", "withdraw", "yes" NPC give me 99 platinum coins and 99 gold coins. Why? Is it work only with my NPC or it's bug from your NPC? Isn't getCount return -1 when you say any word (not number)?
"if count <= oldcount then" - "if -1 (from getCount) <= 4002 (my balance) then"
Also when I say "deposit", "yes" it take from my account 1 gp :>
----------------------------------------
I dont have time now to write transfer functions, but maybe my code will help you with LUA-MySQL:
Code:
house_check_time = 0
function onThink()
if os.time() > house_check_time then
	house_check_time = os.time() + 5
	dofile("./config.lua")
	env = assert(luasql.mysql())
	con = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))
	cur = assert(con:execute("SELECT `cid`, `houseid`, `price`, `name` FROM `house_add_in_game` ORDER BY `price` LIMIT 0, 1;"))
	row = cur:fetch({}, "a")
		while row do
			local houseid = row.houseid
			local guid = row.cid
			local name = row.name
			local price = row.price
			local cid = getPlayerByName(name)
			local price = stringToVariant(price)
			local price = variantToNumber(price)
			local price = price + row.price
			if isPlayer(cid) == TRUE then
			local player_cash = getPlayerStorageValue(cid, 300)
			if player_cash > price or player_cash == price then
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You won house!")
			local player_cash = player_cash - price
			setPlayerStorageValue(cid, 300, player_cash)
			setHouseOwner(houseid, guid)
			assert(con:execute("DELETE FROM `house_add_in_game` WHERE `houseid` = '" .. houseid .. "' ;"))
			assert(con:execute("UPDATE `houses` SET `owner` = '" .. guid .. "' WHERE `id` = '" .. houseid .. "';"))
			else
			house_check_time = os.time() + 12
			doPlayerSendCancel(cid, "You won house, but you dont have enought cash in bank.")
			end
			else
			--what to do when player is not online
			storageqry = assert(con:execute("SELECT * FROM `player_storage` WHERE `player_id` = '" .. guid .. "' AND `key` = 300 LIMIT 0, 1;"))
			storage = storageqry:fetch({}, "a")
			while storage do
			local player_cash = storage.value
			local player_cash = stringToVariant(player_cash)
			local player_cash = variantToNumber(player_cash)
			local player_cash = player_cash + storage.value
			if player_cash > price or player_cash == price then
			local player_cash = player_cash - price
			assert(con:execute("UPDATE `player_storage` SET `value` = '" .. player_cash .. "' WHERE `player_id` = '" .. guid .. "' AND `key` = '300';"))
			setHouseOwner(houseid, guid)
			assert(con:execute("DELETE FROM `house_add_in_game` WHERE `houseid` = '" .. houseid .. "' ;"))
			assert(con:execute("UPDATE `houses` SET `owner` = '" .. guid .. "' WHERE `id` = '" .. houseid .. "';"))
			else
			--player is offline and dont have enought cash in bank! what to do? dont waste CPU and wait until he login
			house_check_time = os.time() + 12
			end
			storage = storageqry:fetch (storage, "a")
			end
			end
			row = cur:fetch (row, "a")
		end
	con:close()
	env:close()
end
npcHandler:onThink()
end
It's code of first good NPC to my web-house-auction-system. Maybe it will help you..
 
Last edited:
I'm testing your bank NPC. I deleted few lines (npc shouldn't be only for pacc). I added:
Code:
----------------------------------------------------------Made By MokerHamer----------------------------------------------
--------------------Special Thanks to: Talaturen and Jiddo  without them i coulden't have done this!------------------
------------------------------------------NOTE* THIS SCRIPT MAY ONLY BE RELEASED ON WWW.OTLAND.NET ONLY---------------------
------------------------------------This Script is specialde made for World Of Tramon V8.0-----------------------------
-----------------------------------------------------World Of Tramon Link: None Yet--------------------------------------
--------------------------------------------------------------------------------------------------------------------------------
function creatureSayCallback(cid, type, msg)
	if(npcHandler.focus ~= cid) then
		return false
	end
	
	local count = (getCount(msg))		
	local oldcount = getPlayerStorageValue(cid, 300)
    if(oldcount == -1) then
     oldcount = 0
      end
		low_money_deposit = 'You do not have enough money in your deposit to withdraw, '..count..' GP.'
		lost_track = 'Huh, What are you talking about?'
			
        if msgcontains(msg, 'banker') then
			selfSay('Hello. How can I help you?')
		elseif msgcontains(msg, 'information') then
			selfSay('Hello I am the banker. You can check your balance, deposit and even withdraw!')
            elseif msgcontains(msg, 'deposit') then
			selfSay('How much would you like to deposit?')
			talk_state = 1
elseif isNumber(getCount(msg)) and talk_state == 1 then
talk_state = 0
if doPlayerRemoveMoney(cid, count) == TRUE then
setPlayerStorageValue(cid, 300, oldcount+count)
selfSay('You have successfully deposit '..count..' GP.')
else
selfSay(lost_track)
end
elseif msgcontains(msg, 'balance') then
talk_state = 0
selfSay('You have '..oldcount..' GP.')
elseif msgcontains(msg, 'withdraw') then
selfSay('How much would u like to withdraw?')
talk_state = 3
elseif isNumber(getCount(msg)) and talk_state == 3 then
talk_state = 0
if count <= oldcount then
setPlayerStorageValue(cid,300, oldcount-count)
doPlayerAddMoney(cid, count)
selfSay('You have successfully withdraw '..count..' GP.')
else
selfSay(low_money_deposit)
end
		elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 3) then
			selfSay('Can I do anything else for you?')
talk_state = 0
end

return true
end
	
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
to my "house-auction-web-system" npc, but here is one bug. When I say to NPC "hi", "withdraw", "yes" NPC give me 99 platinum coins and 99 gold coins. Why? Is it work only with my NPC or it's bug from your NPC? Isn't getCount return -1 when you say any word (not number)?
"if count <= oldcount then" - "if -1 (from getCount) <= 4002 (my balance) then"
Also when I say "deposit", "yes" it take from my account 1 gp :>
----------------------------------------
I dont have time now to write transfer functions, but maybe my code will help you with LUA-MySQL:
Code:
house_check_time = 0
function onThink()
if os.time() > house_check_time then
	house_check_time = os.time() + 5
	dofile("./config.lua")
	env = assert(luasql.mysql())
	con = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))
	cur = assert(con:execute("SELECT `cid`, `houseid`, `price`, `name` FROM `house_add_in_game` ORDER BY `price` LIMIT 0, 1;"))
	row = cur:fetch({}, "a")
		while row do
			local houseid = row.houseid
			local guid = row.cid
			local name = row.name
			local price = row.price
			local cid = getPlayerByName(name)
			local price = stringToVariant(price)
			local price = variantToNumber(price)
			local price = price + row.price
			if isPlayer(cid) == TRUE then
			local player_cash = getPlayerStorageValue(cid, 300)
			if player_cash > price or player_cash == price then
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You won house!")
			local player_cash = player_cash - price
			setPlayerStorageValue(cid, 300, player_cash)
			setHouseOwner(houseid, guid)
			assert(con:execute("DELETE FROM `house_add_in_game` WHERE `houseid` = '" .. houseid .. "' ;"))
			assert(con:execute("UPDATE `houses` SET `owner` = '" .. guid .. "' WHERE `id` = '" .. houseid .. "';"))
			else
			house_check_time = os.time() + 12
			doPlayerSendCancel(cid, "You won house, but you dont have enought cash in bank.")
			end
			else
			--what to do when player is not online
			storageqry = assert(con:execute("SELECT * FROM `player_storage` WHERE `player_id` = '" .. guid .. "' AND `key` = 300 LIMIT 0, 1;"))
			storage = storageqry:fetch({}, "a")
			while storage do
			local player_cash = storage.value
			local player_cash = stringToVariant(player_cash)
			local player_cash = variantToNumber(player_cash)
			local player_cash = player_cash + storage.value
			if player_cash > price or player_cash == price then
			local player_cash = player_cash - price
			assert(con:execute("UPDATE `player_storage` SET `value` = '" .. player_cash .. "' WHERE `player_id` = '" .. guid .. "' AND `key` = '300';"))
			setHouseOwner(houseid, guid)
			assert(con:execute("DELETE FROM `house_add_in_game` WHERE `houseid` = '" .. houseid .. "' ;"))
			assert(con:execute("UPDATE `houses` SET `owner` = '" .. guid .. "' WHERE `id` = '" .. houseid .. "';"))
			else
			--player is offline and dont have enought cash in bank! what to do? dont waste CPU and wait until he login
			house_check_time = os.time() + 12
			end
			storage = storageqry:fetch (storage, "a")
			end
			end
			row = cur:fetch (row, "a")
		end
	con:close()
	env:close()
end
npcHandler:onThink()
end
It's code of first good NPC to my web-house-auction-system. Maybe it will help you..


Well thank you for helping me out, but i'm currently learning lua-mysql








how to put on line 101?, 101 of what file? >.< i don't understnad ^^'

use notepad ++
 
Last edited:
Bug


Code:
21:09 Star [101]: withdraw
21:09 Santander: How mutch would u like to withdraw?
21:09 Star [101]: yes
21:09 Santander: You have successfully withdrawed -1 Gold Pieces.
21:10 Santander: Good bye, Star!

him add me 10k lol
 
Doesn't work. Problem with GetCount (I added that in npc.lua :S)
 
i'll rebuilt the npc tp use the basic getcount function
 
Hey Mokerhamer you fixed problem?

I use TFS rev 551 this error log ...

data/npc/scripts/Paradize.Bank.lua:eek:nCreatureSay
luaGetPlayerStorageValue(). Player not found

wait reply!
WAIT REPLY
 
Hey Mokerhamer you fixed problem?

I use TFS rev 551 this error log ...

data/npc/scripts/Paradize.Bank.lua:eek:nCreatureSay
luaGetPlayerStorageValue(). Player not found

wait reply!
WAIT REPLY

At the moment i'm retired from lua the only thing i do at the moment is check if everything is alright in the lua section
 
This one here is compatible with TFS and it has a transfer function:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)

local talkState = 0
local transaction_count = 0
local transaction_type = 0 --1-withdraw 2-store 3 -transfer
local transfer_name = ""
local transfer_cid = 0

NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)		npcHandler:onCreatureAppear(cid)		end
function onCreatureDisappear(cid)	npcHandler:onCreatureDisappear(cid)		end
function onCreatureSay(cid, type, msg)	npcHandler:onCreatureSay(cid, type, msg)	end
function onThink()			npcHandler:onThink()				end

function clearCrap()
	talkState = 0
	transaction_count = 0
	transfer_name = ""
	transfer_cid = 0
end
function createBankAccount(_cid)
	if getPlayerStorageValue(_cid,STORAGE_BANK) < 0 then
		setPlayerStorageValue(_cid,STORAGE_BANK,0)
	end
end

function creatureSayCallback(cid, type, msg)
	if(npcHandler.focus ~= cid) then
		return FALSE
	end
	
	if msgcontains(msg, 'balance') then
		local balance = getPlayerStorageValue(cid, STORAGE_BANK )
		if  balance >= 0 then
			selfSay("Your account balance is " .. tostring(balance) .. " gold.")
		else
			selfSay("You haven't stored anything in your account yet.")
		end

	elseif msgcontains(msg, 'withdraw') then
		selfSay("How much do you want to withdraw?")
		talkState = 1
		transaction_count = 0

	elseif msgcontains(msg, 'store') or msgcontains(msg,'deposit') then
		selfSay("How much do you want to store? <oink!>")
		talkState = 2
		transaction_count = 0

	elseif msgcontains(msg, 'transfer') then
		selfSay("To whom do you want to transfer money to?")
		talkState = 3
		transfer_name = ""
		transfer_cid = 0
		transaction_count = 0

	elseif msgcontains(msg, 'help') then
		selfSay("I am Florencia, the piggy bank. <oink!> You can store or withdraw money from me or check your balance.")

	--confirm to withdraw money
	elseif talkState == 1 then
		local num = tonumber(msg)
		if(num ~= nil) then
			transaction_count = num
			selfSay("Do you want to withdraw " .. msg .. " gold coins?")
			talkState = 10
			transaction_type = 1
		else
			selfSay("How much?")
		end

	--confirm to store money
	elseif talkState == 2 then
		local num = tonumber(msg)
		if(num ~= nil) then
			transaction_count = num
			selfSay("Do you want to store " .. msg .. " gold coins?")
			talkState = 10
			transaction_type = 2
		else
			selfSay("How much?")
		end

	--ask how much to transfer
	elseif talkState == 3 then
		local _transid = getPlayerByName(msg)
		if _transid ~= nil and _transid > 0 then
			transfer_name = msg
			transfer_cid = _transid
			selfSay("How much do you wish to transfer?")
			talkState = 4
		else
			selfSay("That player does not exist/is not online.")
			talkState = 0
		end

	--confirm transfer
	elseif talkState == 4 then
		local num = tonumber(msg)
		if(num ~= 0) then
			transaction_count = num
			selfSay("Do you want to transfer " .. msg .. " gold coins to " .. transfer_name .. "?")
			talkState = 10
			transaction_type = 3
		else
			selfSay("How much?")
		end

	elseif talkState == 10 then
		if msgcontains(msg,'yes') then
			createBankAccount(cid)
			local balance = getPlayerStorageValue(cid, STORAGE_BANK )
			
			--withdraw
			if transaction_type == 1 then
				if balance >= transaction_count then
					setPlayerStorageValue(cid,STORAGE_BANK,balance-transaction_count)
					doPlayerAddMoney(cid,transaction_count)
					selfSay('Done.')
				else
					selfSay('Sorry, your bank account does not have that much money.')
				end

			--store
			elseif transaction_type == 2 then
				if doPlayerRemoveMoney(cid,transaction_count) then
					setPlayerStorageValue(cid,STORAGE_BANK,balance+transaction_count)
					selfSay('Done.')
				else
					selfSay("You do not have that much money!")
				end

			--transfer
			elseif transaction_type == 3 then
				if balance >= transaction_count then
					setPlayerStorageValue(cid,STORAGE_BANK,balance-transaction_count)
					createBankAccount(transfer_cid)
					setPlayerStorageValue(transfer_cid,STORAGE_BANK,getPlayerStorageValue(transfer_cid,STORAGE_BANK)+transaction_count)
					selfSay('Done.')
				else
					selfSay("Your bank account does not have that much money.")
				end
			end

			clearCrap()

		elseif msgcontains(msg,'no') then
			selfSay('Transaction canceled <oink!>')
			clearCrap()
		end
	end

	return TRUE
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Piggy Bank" script="data/npc/scripts/bank.lua" autowalk="1" floorchange="0">
	<health now="100" max="100"/>
	<look typeex="2114" corpse="0"/>
	<parameters>
		<parameter key="message_greet" value="Hello |PLAYERNAME|. I am your personal bank. " />
	</parameters>
</npc>
 
Back
Top