• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

I need help with a quest / NPC

Kakaher

Member
Joined
Nov 2, 2009
Messages
129
Reaction score
7
Hello everyone!

So, I'm making a quest, and I'm trying to make it as "RPGish" as possible...

So, in the middle of it the quest you will have three items, and the npc will get them and will forge a new item for you..

I already have the npc, but the problem is that it get the 3 items and give the player the forged item right away, I'd like to make it take some time to the npc to forge the item, just like some questions in the real tibia... For example you give the 3 items to the npc, you wait 24 hours, go back and get the forged item...

Is it possible ?


Also, I'd like to make a NPC that is a story teller... So, for example, it will have 3 differents lines to tell the story like
NPC: ...
NPC: ...
NPC: ...

But, if I put selfSay(cid, "...") 3 times in a row, all the three msgs will come at the same time, can I create a delay between the lines ? like
NPC: ...
3 secodns later... NPC: ...
6 seconds later... NPC: ...

And, if the after those 3 msgs, if the player have to say "yes" for example, if he says yes while the NPC is talking, nothing will happen, just at the end of the story... Hope it is possible...

I´ll give my scripts, just so you guys have an idea of how they are looking like

the forge NPC:
LUA:
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 config = {
need_level = true,
level = 100,
pay = true,
price = 5000,
need_premium = true
}

if(msgcontains(msg, 'forge') or msgcontains(msg, 'item')) then
if config.need_premium == true and not isPremium(cid) then
selfSay('I\'m sorry, but I only work for premium players.', cid)
talkState[talkUser] = 0

else
selfSay('Are you sure you want to give me those items for me to make my legendary weapon ?', cid)
talkState[talkUser] = 1
end


elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if config.need_level == true and getPlayerLevel(cid) < config.level then
selfSay('What do you think I am? I\'m not giving my weapon to noob warriors.', cid)
talkState[talkUser] = 0

elseif config.pay == true and getPlayerMoney(cid) >= config.price == FALSE then
selfSay('You don\'t have '..config.price..' gold coins.', cid)
talkState[talkUser] = 0


elseif(getPlayerItemCount(cid, 5880) >= 100) and (getPlayerItemCount(cid, 2157) >= 100) and (getPlayerItemCount(cid, 2146) >= 100) then
doPlayerRemoveMoney(cid, config.price)
doPlayerRemoveItem(cid, 5880, 100)
doPlayerRemoveItem(cid, 2157, 100)
doPlayerRemoveItem(cid, 2146, 100)
doPlayerAddItem(cid, 12626, 1)
selfSay('Here you go my friend. Make good use of it.', cid)
talkState[talkUser] = 0

else
selfSay('You don\'t have the necessary items.', cid)
talkState[talkUser] = 0
end

end
return TRUE
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Code:
doPlayerRemoveItem(cid, 5880, 100)
doPlayerRemoveItem(cid, 2157, 100)
doPlayerRemoveItem(cid, 2146, 100)
doPlayerAddItem(cid, 12626, 1)
I'd like to leave the remove items as they are, but only add the item to th player fi he comes back to the npc say something and 24 hours, for example, have passed...


and the story teller:
LUA:
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, 'story') or msgcontains(msg, 'history')) then
selfSay('First line.', cid)
selfSay('Second line.', cid)
selfSay('Third line.', cid)

end
return TRUE
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

as simple as that... I just want to add some delay between the "selfsays"..

Thanks A LOT already in advance for the help everyone!
 
This thread should be helpful for you!
story[cid] = selfStory({"First message", "Second message", "Third etc.."}, cid, 6000) -- 6000=6s so 3s=3000 keep that in mind, but the line itself won't work if you don't follow the tutorial and add lines to npc/lib/npc.lua.
 
This thread should be helpful for you!
story[cid] = selfStory({"First message", "Second message", "Third etc.."}, cid, 6000) -- 6000=6s so 3s=3000 keep that in mind, but the line itself won't work if you don't follow the tutorial and add lines to npc/lib/npc.lua.

Thanks SO MUCH! is it working perfectly!

REP!
 
Back
Top