• 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!

NPC long story function - NpcHandler:story

Serginov

Onkonkoronkonk
Joined
Jun 28, 2008
Messages
1,321
Reaction score
18
Location
Sweden - Dalarna
As I've seen doNpcTalkALot function is not the best of all. Every player can see what one guy is supposed to see(At least I think it was something like that)

Tested and working on TFS 0.3.6pl1

So I made a new one. Just paste this before the last end in:
npc/lib/npcsystem/npchandler.lua
Code:
    function storyTalk(messages, focus, i, self)
        if self:isFocused(focus) then
            selfSay(messages[i], focus)
        end
    end
    
    function NpcHandler:story(messages, focus, storyDelay)
        if self:isFocused(focus) then
            selfSay(messages[1], focus)
            local delay = storyDelay
            for i = 2, #messages do
                addEvent(storyTalk, storyDelay, messages, focus, i, self)
                storyDelay = storyDelay + delay
            end
        end
    end
Usage;
Code:
    if msgcontains(msg, "cool story brah!") then
        local msg = {"I am ...", "teh coolest dude ... ", "that ever ...", "existed."}
        npcHandler:story(msg, cid, 1000)
    end
 
Last edited:
lol if i use that 3 nears or longer npc says to me this text
Code:
15:07 Arkulius: I am ...
15:07 Basilisk: teh coolest dude ... 
15:07 Basilisk: that ever ...
15:07 Basilisk: existed.
 
I've better function.
PHP:
function doNPCTalkALot(cid, npc, delay, messages)
	for i = 1,#messages do
		addEvent(doCreatureSay, delay * i, npc, messages[i], TALKTYPE_PRIVATE_NP, false, cid)
	end
end
And for example:
PHP:
doNPCTalkALot(cid, getNpcCid(), 5000, {"I need 100 {Wyrm Scale} and 50 {Shockwave Amulet}.", "If you have found it say {mission}"})
 
Ooh, will fix that later Mauzim

Edit; Fixed the bug Mauzim was talking about.
Also now when you say bye the NPC won't keep telling you the story
 
Last edited:
Back
Top