local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState= {}
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 creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local cycmsg = 'Hello'
local noimsg = 'You wanna changed your tokens?'
local deny = 'Your are sure?'
if msgcontains(msg, 'help') or msgcontains(msg, 'trade') then
selfSay('Me can make {changed}, for changed your tokens..', cid)
elseif msgcontains(msg, 'changed') then
selfSay('You wanna changed your 50 tokens for 10 vip coins?', cid)
talkState[talkUser] = 1
elseif talkState[talkUser] == 1 then
if msgcontains(msg, 'yes') then
if doPlayerTakeItem(cid, 2487, 50) == true then -- 2487 - changed for tokens ID
doPlayerAddItem(cid, 5887, 10) --- changed for ID vipcoins
selfSay(cycmsg, cid)
talkState[talkUser] = 0
else
selfSay(noimsg, cid)
end
else
selfSay(deny, cid)
end
talkState[talkUser] = 0
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())