local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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
local tabla = {
["Admin Armor"] = {8000, 2503},
["admin helmet"] = {8000, 2501},
["admin legs"] = {8000, 2504},
["admin shield"] = {15000, 8905},
["admin boots"] = {20000, 2646},
["admin blade"] = {20000, 7407},
["admin wand"] = {10000, 7735},
["admin rod"] = {10000, 7410},
["firewalker boots"] = {50, 9932},
["flame blade"] = {100, 8931}
}
local tokens = 9020 ---- ID of tokens
function creatureSayCallback(cid, type, msg)
local s = getPlayerItemCount
local msgn = "you don't have enough tokens"
if (msgcontains(msg, 'trade')) and s(cid,tokens) == 0 then
npcHandler:say('You dont have any ' .. getItemName(tokens) .. '', cid)
elseif msgcontains(msg, 'trade') and s(cid,tokens) >= 1 and s(cid,tokens) <= 0 then
npcHandler:say('You dont have enough ' .. getItemName(tokens) .. '!', cid)
elseif msgcontains(msg, 'trade') and s(cid,10581) >= 10 and s(cid,10581) <= 500 then
npcHandler:say('You can change your ' .. getItemName(tokens) .. ' for, {boots of haste}, {demon helmet}, {frozen starlight}, {spellbok of dark mysteries}, {royal crossbow} y {stuffed dragon} ... Y con mas de 30 fichas, {star tear}, {jester staff}, {vancini axe}, {flame blade} y {firewalker boots}', cid)
end
for txt, v in pairs(tabla) do
if msgcontains(msg, txt) then
if doPlayerRemoveItem(cid,tokens,v[1]) then
doPlayerAddItem(cid,v[2],1)
npcHandler:say("Here you are ".. getItemNameById(v[2]) .."!", cid)
else
npcHandler:say("".. msgn .."", cid)
end
end
end
return true
end
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())