Try this one then.
Code:
ocal talkNode = 0
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions start
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThingMove(creature, thing, oldpos, oldstackpos) npcHandler:onThingMove(creature, thing, oldpos, oldstackpos) end
function onCreatureAppear(creature) npcHandler:onCreatureAppear(creature) end
function onCreatureDisappear(id) npcHandler:onCreatureDisappear(id) end
function onCreatureTurn(creature) npcHandler:onCreatureTurn(creature) end
function onCreatureChangeOutfit(creature) npcHandler:onCreatureChangeOutfit(creature) end
function onThink() npcHandler:onThink() end
-- OTServ event handling functions end
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
function creatureSayCallback(cid, type, msg)
if(npcHandler.focus ~= cid) then
return false
end
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
local cost = 1337
local outPos = {x = 100, y = 100, z = 10}
if msgcontains(msg,'yes') then
if talkNode == 0 then
selfSay('Then you will need to pay ' .. cost .. ' gold. Do you wanna pay that amount?')
talkNode = 1
elseif talkNode == 1 then
if player_money >= cost then
doPlayerRemoveMoney(cid,cost)
doTeleportThing(cid,outPos)
end
end
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
-- Makes sure the npc reacts when you say hi, bye etc.
npcHandler:addModule(FocusModule:new())