[Help] Forgotte Server Banker

Status
Not open for further replies.

Mark

Administrator
Staff member
Administrator
Joined
May 27, 2007
Messages
6,389
Best answers
21
Reaction score
1,386
Location
Sweden
Change:
if isNumber getCount(msg) then
to:
if isNumber(getCount(msg)) then
 
OP
Mokerhamer

Mokerhamer

Retired Global Mod
Joined
Aug 6, 2007
Messages
1,766
Best answers
0
Reaction score
35
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())
 

Mark

Administrator
Staff member
Administrator
Joined
May 27, 2007
Messages
6,389
Best answers
21
Reaction score
1,386
Location
Sweden
Change:
elseif msgcontains(msg, 'Deposit') then
to:
elseif msgcontains(msg, 'deposit') then
 
OP
Mokerhamer

Mokerhamer

Retired Global Mod
Joined
Aug 6, 2007
Messages
1,766
Best answers
0
Reaction score
35
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)
 

Mark

Administrator
Staff member
Administrator
Joined
May 27, 2007
Messages
6,389
Best answers
21
Reaction score
1,386
Location
Sweden
Put the getCount function in npc.lua, and remove shopmodule class part.
 
OP
Mokerhamer

Mokerhamer

Retired Global Mod
Joined
Aug 6, 2007
Messages
1,766
Best answers
0
Reaction score
35
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())
 
OP
Mokerhamer

Mokerhamer

Retired Global Mod
Joined
Aug 6, 2007
Messages
1,766
Best answers
0
Reaction score
35
Talaturen do i have something wrong with my global.lua ?
I told u to put getCount in global.lua right?? remove it from global.lua and you are fine

~~Tala go 2 posts up~~
 
Last edited:

Mark

Administrator
Staff member
Administrator
Joined
May 27, 2007
Messages
6,389
Best answers
21
Reaction score
1,386
Location
Sweden
Because you made it buggy, you first check if message is deposit and then you check if the message is only numbers.
 
OP
Mokerhamer

Mokerhamer

Retired Global Mod
Joined
Aug 6, 2007
Messages
1,766
Best answers
0
Reaction score
35
Because you made it buggy, you first check if message is deposit and then you check if the message is only numbers.

Well how should it be made then??
 
Last edited:

Mark

Administrator
Staff member
Administrator
Joined
May 27, 2007
Messages
6,389
Best answers
21
Reaction score
1,386
Location
Sweden
It should look for the message AFTER that you've said deposit, not the same message WHEN YOU SAY deposit.
 
OP
Mokerhamer

Mokerhamer

Retired Global Mod
Joined
Aug 6, 2007
Messages
1,766
Best answers
0
Reaction score
35
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..
 

Mark

Administrator
Staff member
Administrator
Joined
May 27, 2007
Messages
6,389
Best answers
21
Reaction score
1,386
Location
Sweden
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.
 
OP
Mokerhamer

Mokerhamer

Retired Global Mod
Joined
Aug 6, 2007
Messages
1,766
Best answers
0
Reaction score
35
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:
OP
Mokerhamer

Mokerhamer

Retired Global Mod
Joined
Aug 6, 2007
Messages
1,766
Best answers
0
Reaction score
35
~~Bump anyone can help me (1 post up)???
 

kornholi

Administrator
Staff member
Administrator
Joined
May 28, 2007
Messages
1,017
Best answers
0
Reaction score
61
Location
Chicago, USA
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 ;)
 
OP
Mokerhamer

Mokerhamer

Retired Global Mod
Joined
Aug 6, 2007
Messages
1,766
Best answers
0
Reaction score
35
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 ;)

Well thank you for your time..
 

Mark

Administrator
Staff member
Administrator
Joined
May 27, 2007
Messages
6,389
Best answers
21
Reaction score
1,386
Location
Sweden
Where is storageid or StorageId declared?
 
OP
Mokerhamer

Mokerhamer

Retired Global Mod
Joined
Aug 6, 2007
Messages
1,766
Best answers
0
Reaction score
35
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:

Mark

Administrator
Staff member
Administrator
Joined
May 27, 2007
Messages
6,389
Best answers
21
Reaction score
1,386
Location
Sweden
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.
Top