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

Lua Bank NPC (Suzy) not working. Help!

tani

New Member
Joined
May 12, 2013
Messages
68
Reaction score
4
Im using OTHire Version 0.0.2


Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)



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

keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I work in this bank. I can change money for you."})
keywordHandler:addKeyword({'name'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I am Suzy."})


function creatureSayCallback(cid, type, msg) msg = string.lower(msg)
---------------
-- deposit --
---------------
if(npcHandler.focus ~= cid) then
return false
end
amount = getCount(msg)
if amount > 1000000 then
npcHandler:say('this amount is too high!', 1)
return false
end
if msgcontains(msg, 'deposit all') then
PLAYERCURRENTMONEY = ((getPlayerItemCount(cid, ITEM_CRYSTAL_COIN) * 10000) + (getPlayerItemCount(cid, ITEM_PLATINUM_COIN) * 100) + getPlayerItemCount(cid, ITEM_GOLD_COIN))
npcHandler:say('would you like to deposit '.. PLAYERCURRENTMONEY ..' gold?', 1)
suzy_talk_state = 205

elseif msgcontains(msg, 'deposit') and getCount(msg) <= 0 then
npcHandler:say('How much would you like to deposit?', 1)
suzy_talk_state = 201

elseif msgcontains(msg, 'deposit') and getCount(msg) >= 1 then
DEPOSITMONEY = getCount(msg)
npcHandler:say('Would you like to deposit '.. DEPOSITMONEY ..' gold?', 1)
suzy_talk_state = 202

elseif suzy_talk_state == 201 then
TEXTMSG = msg
DEPOSITAMOUNT = getCount(msg)
if DEPOSITAMOUNT >= 1 then
npcHandler:say("would you like to deposit ".. DEPOSITAMOUNT .." gold?", 1)
else
npcHandler:say("I'm sorry, but you must give me an valid amount of how much you would like to deposit.", 1)
end
suzy_talk_state = 203

elseif suzy_talk_state == 203 and msgcontains(msg, 'yes') then

if DepositMoney(cid, DEPOSITAMOUNT) == TRUE then
npcHandler:say("You have added ".. DEPOSITAMOUNT .." gold to your bank account.", 1)
else
npcHandler:say("You don't have that much money!", 1)
end
suzy_talk_state = 0

elseif suzy_talk_state == 202 then

if DepositMoney(cid, DEPOSITMONEY) == TRUE then
npcHandler:say("You have added ".. DEPOSITMONEY .." gold to your bank account.", 1)
else
npcHandler:say("You don't have that much money!", 1)
end
suzy_talk_state = 0

elseif suzy_talk_state == 205 and msgcontains(msg, 'yes') then

if DepositMoney(cid, PLAYERCURRENTMONEY) == TRUE then
npcHandler:say("You have added ".. PLAYERCURRENTMONEY .." gold to your bank account.", 1)
else
npcHandler:say("Hey! where did you put the money?", 1)
end
suzy_talk_state = 0

end

-------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------
---------------
-- Balance --
---------------
if(npcHandler.focus ~= cid) then
return false
end
if msgcontains(msg, 'balance') or msgcontains(msg, 'balance') then

if getPlayerBalance(cid) <= 4999 then
npcHandler:say("Your account balance is ".. getPlayerBalance(cid) .." gold.", 1)
suzy_talk_state = 0
elseif getPlayerBalance(cid) >= 5000 and getPlayerBalance(cid) <= 49999 then
npcHandler:say("Your account balance is ".. getPlayerBalance(cid) .." gold.", 1)
suzy_talk_state = 0
elseif getPlayerBalance(cid) >= 50000 and getPlayerBalance(cid) <= 99999 then
npcHandler:say("You certainly have made a pretty penny. Your account balance is ".. getPlayerBalance(cid) .." gold.", 1)
suzy_talk_state = 0
elseif getPlayerBalance(cid) >= 100000 then
npcHandler:say("You have really been successful with money! you account balance is ".. getPlayerBalance(cid) .." gold.", 1)
suzy_talk_state = 0
end
end

-------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------
---------------
-- Withdraw --
---------------
if(npcHandler.focus ~= cid) then
return false
end
if msgcontains(msg, 'withdraw') and getCount(msg) >= 1 then
WITHDRAWAMOUNT = getCount(msg)
npcHandler:say('Would you like to withdraw '.. WITHDRAWAMOUNT ..' gold?', 1)
suzy_talk_state = 304

elseif msgcontains(msg, 'withdraw') then
npcHandler:say('How much would you like to withdraw?', 1)
suzy_talk_state = 301

elseif suzy_talk_state == 301 then
WITHDRAWMONEY = getCount(msg)
if WITHDRAWMONEY >= 1 then
npcHandler:say("would you like to withdraw ".. WITHDRAWMONEY .." gold?", 1)
suzy_talk_state = 303
else
npcHandler:say("I'm sorry, but you must give me an valid amount of how much you would like to withdraw.", 1)
suzy_talk_state = 0
end

elseif suzy_talk_state == 303 and msgcontains(msg, 'yes') or suzy_talk_state == 303 and msgcontains(msg, 'YES') then

if WithdrawMoney(cid, WITHDRAWMONEY) == TRUE then
npcHandler:say("There you go.. enjoy them!", 1)
else
npcHandler:say("You don't have that much money on your bank account!", 1)
end
suzy_talk_state = 0

elseif suzy_talk_state == 304 and msgcontains(msg, 'yes') or suzy_talk_state == 304 and msgcontains(msg, 'YES') then

if WithdrawMoney(cid, WITHDRAWAMOUNT) == TRUE then
npcHandler:say("There you go.. enjoy them!", 1)
else
npcHandler:say("You don't have that much money on your bank account!", 1)
end
suzy_talk_state = 0
end
-------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------
---------------
--Change gold--
---------------
if(npcHandler.focus ~= cid) then
return false
end
if msgcontains(msg, 'change') then
npcHandler:say('Would you like to change gold, "platinum" or "crystal"?', 1)
suzy_talk_state = 401

elseif msgcontains(msg, 'gold') and suzy_talk_state == 401 then
npcHandler:say('How many platinum coins would you like to get?', 1)
suzy_talk_state = 402

----------
elseif msgcontains(msg, 'platinum') and suzy_talk_state == 401 then
npcHandler:say('would you like to change platinum to gold or "crystal"?', 1)
suzy_talk_state = 403
elseif msgcontains(msg, 'gold') and suzy_talk_state == 403 then
npcHandler:say('How many platinum coins would you like to change to gold?', 1)
suzy_talk_state = 404
elseif msgcontains(msg, 'crystal') and suzy_talk_state == 403 then
npcHandler:say('How many crystal coins would you like to get?', 1)
suzy_talk_state = 405
----------

elseif msgcontains(msg, 'crystal') and suzy_talk_state == 401 then
npcHandler:say('How many crystal coins would you like to change to platinum coins?', 1)
suzy_talk_state = 406



elseif suzy_talk_state == 402 then
TEXTMSG = msg
amount = getCount(msg)
if amount >= 1 then
if doPlayerRemoveItem(cid, 2148, (amount) * 100) == TRUE then
doPlayerAddItem(cid, 2152, amount)
npcHandler:say("Here's your ".. amount .." platinum coins.", 1)
suzy_talk_state = 0
else
npcHandler:say("You don't have that much money!", 1)
suzy_talk_state = 402
end
else
npcHandler:say("I'm sorry, but you must give me an valid amount.", 1)
suzy_talk_state = 402
end

elseif suzy_talk_state == 404 then
TEXTMSG = msg
amount = getCount(msg)
if amount >= 1 then
if doPlayerRemoveItem(cid, 2152, (amount)) == TRUE then
doPlayerAddItem(cid, 2148, (amount) * 100)
npcHandler:say("Here's your ".. (amount) * 100 .." gold coins.", 1)
suzy_talk_state = 0
else
npcHandler:say("You don't have that much money!", 1)
suzy_talk_state = 404
end
else
npcHandler:say("I'm sorry, but you must give me an valid amount.", 1)
suzy_talk_state = 404
end

elseif suzy_talk_state == 405 then
TEXTMSG = msg
amount = getCount(msg)
if amount >= 1 then
if doPlayerRemoveItem(cid, 2152, (amount) * 100) == TRUE then
doPlayerAddItem(cid, 2160, amount)
npcHandler:say("Here's your ".. amount .." crystal coins.", 1)
suzy_talk_state = 0
else
npcHandler:say("You don't have that much money!", 1)
suzy_talk_state = 405
end
else
npcHandler:say("I'm sorry, but you must give me an valid amount.", 1)
suzy_talk_state = 405
end

elseif suzy_talk_state == 406 then
TEXTMSG = msg
amount = getCount(msg)
if amount >= 1 then
if doPlayerRemoveItem(cid, 2160, (amount)) == TRUE then
doPlayerAddItem(cid, 2152, amount * 100)
npcHandler:say("Here's your ".. (amount) * 100 .." platinum coins.", 1)
suzy_talk_state = 0
else
npcHandler:say("You don't have that much money!", 1)
suzy_talk_state = 406
end
else
npcHandler:say("I'm sorry, but you must give me an valid amount.", 1)
suzy_talk_state = 406
end

end
-------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------
---------------
 
Last edited:
well, in your distro I'm not sure. In TFS 1.2, it's easy, but it depends on the way your server is saved and shutdown. Also note that it does not automatically restart, and you would need an external script or application to run the server again upon shutdown (unless you want to manually restart it every morning ;) which I doubt)
 
Back
Top