• 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!

[Help] Forgotte Server Banker

Status
Not open for further replies.

Mokerhamer

Retired Global Mod
Senator
Joined
Aug 6, 2007
Messages
1,767
Reaction score
35
[Help] TFS Banker Transfer (Need to fix before release of banker!)

I got olmoost my npc working all things work expect for
Transfer money can anyone help me?

Bug Shown:
-None


What's wrong with it then:
If i'm done i'm going to make some minor fixes and released it only on this forum

Bugged Lines:
Code:
elseif getCreatureName(cid}[COLOR="Magenta"]<---- How do i get the name the player said he wants to transfers to?[/COLOR]
and isNumber(getCount(msg)) and talk_state == 4 then
talk_state = 0

if doTransferBankMoney(cid, toplayer, count) then
setPlayerStorageValue(cid,300, oldcount-count)
set[COLOR="magenta"]to[/COLOR]PlayerStorageValue(cid,300, oldcount+count)

I dont think "settoPlayerStorageValue" is going to work since it dosen't exist what can i use instead?

Transfer Part:
Code:
   ------------------------Begin!--transfer--Crap----
            elseif msgcontains(msg, 'transfer') then
			if getPlayerPremiumDays(cid) > 0 then
			selfSay('If you want to transver sai this,   Name   Amount')
					talk_state = 4
			else
				selfSay(bank_need_premium)
				talk_state = 0
			end
---transver--Confurm--Yes
elseif getCreatureName(cid) and isNumber(getCount(msg)) and talk_state == 4 then
talk_state = 0
if doTransferBankMoney(cid, toplayer, count) then
setPlayerStorageValue(cid,300, oldcount-count)
settoPlayerStorageValue(cid,300, oldcount+count)
selfSay('Transver success')
else
selfSay(no_money)
end
------------------------End!--transfer--Crap----
 
Last edited:
Change:
if isNumber getCount(msg) then
to:
if isNumber(getCount(msg)) then
 
Change:
if isNumber getCount(msg) then
to:
if isNumber(getCount(msg)) then



Tested it dosen't respond when i sai deposit and it dosen't give any error:

Script:
Code:
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

function creatureSayCallback(cid, type, msg)
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	if(npcHandler.focus ~= cid) then
		return false
	end
	
		bank_need_premium = 'Sorry, you need a premium account to the bank!'
		no_money = 'You dont have enough money!'
		lost_track = 'What are u talking about?'
		money_give = 'Here you are, Spend that money smart!'
		player_gold = getPlayerItemCount(cid,2148)
		player_plat = getPlayerItemCount(cid,2152)*100
		player_crys = getPlayerItemCount(cid,2160)*10000
		player_money = player_gold + player_plat + player_crys
		
		if msgcontains(msg, 'banker') then
			selfSay('Hello there! if you need any help just sai  information')
		elseif msgcontains(msg, 'information') then
			selfSay('Hello i am the city banker you can do many things here.')
					elseif msgcontains(msg, 'help') then
			selfSay('I cant help you, if you want some information just sai information')
----------------------------------------------------------------------deposit--------------------------------
		elseif msgcontains(msg, 'Deposit') then
			if getPlayerPremiumDays(cid) > 0 then
			selfSay('How mutch would u like to deposit?')
              if isNumber(getCount(msg)) then
			selfSay('Are u sure you want to deposit somting here?')
					talk_state = 1
				else
					selfSay(lost_track)
					talk_state = 0
					end
			else
				selfSay(bank_need_premium)
				talk_state = 0
			end
-------------------------------------------------yes-----------------------
elseif msgcontains(msg, 'yes') and talk_state == 1 then
talk_state = 0
if doPlayerRemoveMoney(cid,count) == TRUE then
setPlayerStorageValue(cid,storageid)
else
selfSay(no_money)
end
--------------------------------------no----------------------
		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())
 
Change:
elseif msgcontains(msg, 'Deposit') then
to:
elseif msgcontains(msg, 'deposit') then
 
Tested it now it responds when i sai deposit it will ask me how mutch i want to deposit when i sai as exmaple 500 it sais nothing back and i get this error


Code:
data/npc/scripts/bank.lua:37: attempt to call global 'getCount' (a nil value)
 
Put the getCount function in npc.lua, and remove shopmodule class part.
 
Put the getCount function in npc.lua, and remove shopmodule class part.


I dit as u said

I added getCount in npc.lua (it's only in npc.lua):
Code:
	-- Function used to match a number value from a string. the getCount Module
function getCount(msg)
 local ret = -1
 local b, e = string.find(msg, "%d+")
    if b ~= nil and e ~= nil then
       ret = tonumber(string.sub(msg, b, e))
    end
 
    return ret
end

But the npc is bugged when i sai deposit it answers with

16:21 Banker: What are u talking about?

Script:
Code:
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

function creatureSayCallback(cid, type, msg)
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	if(npcHandler.focus ~= cid) then
		return false
	end
	
		bank_need_premium = 'Sorry, you need a premium account to the bank!'
		no_money = 'You dont have enough money!'
		lost_track = 'What are u talking about?'
		money_give = 'Here you are, Spend that money smart!'
		player_gold = getPlayerItemCount(cid,2148)
		player_plat = getPlayerItemCount(cid,2152)*100
		player_crys = getPlayerItemCount(cid,2160)*10000
		player_money = player_gold + player_plat + player_crys
		
		if msgcontains(msg, 'banker') then
			selfSay('Hello there! if you need any help just sai  information')
		elseif msgcontains(msg, 'information') then
			selfSay('Hello i am the city banker you can do many things here.')
					elseif msgcontains(msg, 'help') then
			selfSay('I cant help you, if you want some information just sai information')
----------------------------------------------------------------------deposit--------------------------------
            elseif msgcontains(msg, 'deposit') then
			if getPlayerPremiumDays(cid) > 0 then
			selfSay('How mutch would u like to deposit?')
             if isNumber (getCount(msg)) then
			selfSay('Are u sure you want to deposit that certain money here?')
					talk_state = 1
				else
					selfSay(lost_track)
					talk_state = 0
					end
			else
				selfSay(bank_need_premium)
				talk_state = 0
			end
-------------------------------------------------yes-----------------------
elseif msgcontains(msg, 'yes') and talk_state == 1 then
talk_state = 0
if doPlayerRemoveMoney(cid,count) == TRUE then
setPlayerStorageValue(cid,storageid)
else
selfSay(no_money)
end
--------------------------------------no----------------------
		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())
 
Because you made it buggy, you first check if message is deposit and then you check if the message is only numbers.
 
It should look for the message AFTER that you've said deposit, not the same message WHEN YOU SAY deposit.
 
I dont really get it..
i'm sorry i have as u sai it in dutch "Dislectie" that means i understand things hard if i read them..
 
You simply make talkstate after player has said deposit, and then if the talkstate is that value check for next message if its numbers or not, if you still don't understand then someone else will have to help you or you can wait until I write bank NPC module.
 
I think i got your point you mean somting like this?

functions are now talkstate AND IT'S WORKING!

Code:
----------------------------------------------------------Made By MokerHamer----------------------------------------------
---------------------------Special Thanks to: "Talaturen" without him i coulden't have done this!------------------------
--------------------------------------This Script may ONLY be released on www.OtLand.net -----------------------------
------------------------------------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

function creatureSayCallback(cid, type, msg)
	if(npcHandler.focus ~= cid) then
		return false
	end
	local count = (getCount(msg))

---------------Begin  Crap that u can change it if u want-----------------------	
		bank_need_premium = 'Sorry, you need a premium account to the bank!'
		no_money = 'You dont have enough money!'
		empty_bank = 'You have no money in the bank'
		lost_track = 'What are u talking about?'
		money_give = 'Here you are, Spend that money smart!'
			
		if msgcontains(msg, 'banker') then
			selfSay('Hello there! if you need any help just sai  information')
		elseif msgcontains(msg, 'information') then
			selfSay('Hello i am the city banker you can do many things here.')
					elseif msgcontains(msg, 'help') then
			selfSay('I cant help you, if you want some information just sai information')
---------------End  Crap that u can change it if u want
---deposit
            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,StorageId, currentMoney)
selfSay('Deposit succesfully')
else
selfSay(no_money)
end

---Balance
            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
talk_state = 0
if getPlayerStorageValue(cid,StorageId, currentMoney) then
selfSay('You have '..count..' Gold Pieces')
else
selfSay(empty_bank)
end


---No--To--All
		elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 4) 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())


It does take money from you and things like that but i get this bug...


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

luaGetPlayerStorageValue(). Player not found


and yes i tryt to change:
Code:
getPlayerStorageValue(cid,storageid)

to

Code:
getPlayerStorageValue(cid, storageid)

and
Code:
getPlayerStorageValue(cid,StorageId, currentMoney)


and i used StorageId

But all give the same error.. Tala could u help me?
 
Last edited:
No, sorry, I'm not good at Lua, I see the error, but I cannot fix it(add `count = getPlayer~~`?).. So, let's wait for Talaturen to help you ;)
 
Where is storageid or StorageId declared?
 
I got olmoost my npc working all things work expect for
Transfer money can anyone help me?

Bug Shown:
-None


What's wrong with it then:
If i'm done i'm going to make some minor fixes and released it only on this forum

Bugged Lines:
Code:
elseif getCreatureName(cid}[COLOR="Magenta"]<---- How do i get the name the player said he wants to transfers to?[/COLOR]
and isNumber(getCount(msg)) and talk_state == 4 then
talk_state = 0

if doTransferBankMoney(cid, toplayer, count) then
setPlayerStorageValue(cid,300, oldcount-count)
set[COLOR="magenta"]to[/COLOR]PlayerStorageValue(cid,300, oldcount+count)

I dont think "settoPlayerStorageValue" is going to work since it dosen't exist what can i use instead?

Transfer Part:
Code:
   ------------------------Begin!--transfer--Crap----
            elseif msgcontains(msg, 'transfer') then
			if getPlayerPremiumDays(cid) > 0 then
			selfSay('If you want to transver sai this,   Name   Amount')
					talk_state = 4
			else
				selfSay(bank_need_premium)
				talk_state = 0
			end
---transver--Confurm--Yes
elseif getCreatureName(cid) and isNumber(getCount(msg)) and talk_state == 4 then
talk_state = 0
if doTransferBankMoney(cid, toplayer, count) then
setPlayerStorageValue(cid,300, oldcount-count)
settoPlayerStorageValue(cid,300, oldcount+count)
selfSay('Transver success')
else
selfSay(no_money)
end
------------------------End!--transfer--Crap----
 
Last edited:
The transfer part to offline player is only possible using ways I recommend you to NOT use, if you're hosting in Windows at the moment.
 
Status
Not open for further replies.
Back
Top