local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
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 greetCallback(cid)
talkState[talkUser] = 0
return true
end
function creatureSayCallback(cid, type, msg)
local talkUser,msg = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid,string.lower(msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local money = 1000000
local trade = {
{id=5944, buy=100, name="Soul Orb"},
{id=8925, buy=50000, name="Solar Axe"},
{id=2413, buy=2240, name="Broadsword"}
}
local items = {}
for _, item in ipairs(trade) do
items[item.id] = {item_id = item.id, buyPrice = item.buy, sellPrice = 0, subType = 0, realName = item.name}
end
local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks)
if items[item].buyPrice ~= 0 then
doPlayerRemoveMoney(cid, amount * items[item].buyPrice)
if isItemStackable(items[item].item_id) then
doPlayerAddItem(cid, items[item].item_id, amount)
else
for i = 1, amount do
doPlayerAddItem(cid, items[item].item_id, 1)
end
end
end
end
if msgcontains(msg, 'trade') and doPlayerRemoveMoney(cid, money) then
openShopWindow(cid, trade, onBuy, onSell)
else
selfSay("sorry, u need "..money.." gps to talk with me.", cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
OBS: qual a versão do seu server pollyana?