potinho
Intermediate OT User
Hello everyone, everything good?
I have an NPC that takes a player to a certain location asking for an item and an amount of money, but I have 2 problems:
I asked him to request 5 crystal coins (50k) and he is asking for 100k. I would also like the NPC to ask for two items for sacrifice, how to configure this way?
npc.lua
I have an NPC that takes a player to a certain location asking for an item and an amount of money, but I have 2 problems:
I asked him to request 5 crystal coins (50k) and he is asking for 100k. I would also like the NPC to ask for two items for sacrifice, how to configure this way?
npc.lua
Lua:
local tab = {
pos = {x = 766, y = 253, z = 6}, -- x, y, z destination
item = {2557, 30}, -- {itemID, count}
price = 5 -- crystal coin amout
}
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
if (msgcontains(msg, 'boat')) then
talkState[talkUser] = 1
selfSay('Are you sure?', cid)
selfSay('Remember: you need '..tab.item[2]..' '..getItemNameById(tab.item[1])..' and '..tab.price..' crystal coins to be teleported. Do you want to go in anyway?', cid)
elseif (msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if (getPlayerItemCount(cid, tab.item[1]) >= tab.item[2] and doPlayerRemoveMoney(cid, tab.price * 10000)) then
doTeleportThing(cid, tab.pos)
doPlayerRemoveItem(cid, tab.item[1], tab.item[2])
doPlayerRemoveMoney(cid, tab.price * 10000)
doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
selfSay('Here you are. Have a good lucky and a nice travel, thanks for help.', cid)
else
talkState[talkUser] = 0
selfSay('I can not teleport you. You do not have the required items.', cid)
end
elseif (msgcontains(msg, 'no') and talkState[talkUser] == 1) then
talkState[talkUser] = 0
selfSay('Okay, maybe another time.', cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())