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

Dogrinha

New Member
Joined
Oct 6, 2019
Messages
206
Solutions
1
Reaction score
2
I have difficulty making the correct syntax for npc to continue the mission and open the trade when finishing the djin quest, so far it works not open the trade without having finished, but I have problems with the fact that I can not request mission, he doesn't answer me, I already removed the storages and it didn't work
tfs 0.4
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)


local Topic = {}
local storage = 100057
local storage2 = 100032
 
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 greetCallback(cid)
    Topic[cid] = 0
    return true
end
 
function creatureSayCallback(cid, type, msg)
    local p = getCreatureName(cid)
    local v = getPlayerStorageValue(cid, storage)
    if npcHandler:isFocused(cid) then
        if msgcontains(msg, 'no') and Topic[cid] == 2 then
            npcHandler:say("Dont disturb me then.",cid)
            Topic[cid] = 1
        elseif msgcontains(msg, 'no') and Topic[cid] >= 4 then
            npcHandler:say("Dont disturb me then.",cid)
            Topic[cid] = 3
        end
    end
    if (msgcontains(msg, "hi")) and (not npcHandler:isFocused(cid)) and getPlayerStorageValue(cid, storage) == -1 then
        if  getPlayerStorageValue(cid, 100054) == 2 and getPlayerStorageValue(cid, 9030) == 1 then
            npcHandler:say("What do you want from me, "..p.."?", cid)
            npcHandler:addFocus(cid)
            Topic[cid] = 1
        end
    elseif Topic[cid] == 1 then
        if msgcontains(msg, 'mission') and getPlayerStorageValue(cid, storage) == -1  then
            npcHandler:say("So Baa'leal thinks you are up to do a mission for us? ...",cid)
            npcHandler:say("I think he is getting old, entrusting human scum such as you are with an important mission like that. ...",cid, 1000)
            npcHandler:say("I don't understand why you haven't been slaughtered right at the gates. ...",cid, 2500)
            npcHandler:say("Are you prepared to embark on a dangerous mission for us?",cid, 3500)
            Topic[cid] = 2
        end
    elseif Topic[cid] == 2 then
        if msgcontains(msg, 'yes') and getPlayerStorageValue(cid, storage) == -1  then
            npcHandler:say("All right then, human. Have you ever heard of the {Tears of Daraman}? ...",cid)
            npcHandler:say("They are precious gemstones made of some unknown blue mineral and possess enormous magical power. ...",cid, 1000)
            npcHandler:say("If you want to learn more about these gemstones don't forget to visit our library. ...",cid, 2000)
            npcHandler:say("Anyway, one of them is enough to create thousands of our mighty djinn blades. ...",cid, 3000)
            npcHandler:say("Unfortunately my last gemstone broke and therefore I'm not able to create new blades anymore. ...",cid, 4000)
            npcHandler:say("To my knowledge there is only one place where you can find these gemstones - I know for a fact that the Marid have at least one of them. ...",cid, 5000)
            npcHandler:say("Well... to cut a long story short, your mission is to sneak into Ashta'daramai and to steal it. ...",cid, 6000)
            npcHandler:say("Needless to say, the Marid won't be too eager to part with it. Try not to get killed until you have delivered the stone to me.",cid, 7000)
            setPlayerStorageValue(cid, 100062, 6)
            setPlayerStorageValue(cid,10160, 1)
        end
        Topic[cid] = 0
    end
    if (msgcontains(msg, "hi")) and (not npcHandler:isFocused(cid)) and getPlayerStorageValue(cid, storage) == 1 then
        if getPlayerStorageValue(cid, storage) == 1 and getPlayerStorageValue(cid, 9030) == 1 then
            npcHandler:say("What do you want from me, "..p.."?", cid)
            npcHandler:addFocus(cid)
            Topic[cid] = 3
        end
    elseif Topic[cid] == 3 then
        if msgcontains(msg, 'mission') then
            npcHandler:say("Did you find the tear of Daraman?",cid)
            Topic[cid] = 4
        end
    elseif Topic[cid] == 4 then
        if msgcontains(msg, 'yes') and doPlayerTakeItem(cid, 2346, 1) then
            npcHandler:say("So you have made it? You have really managed to steal a Tear of Daraman? ...",cid)
            npcHandler:say("Amazing how you humans are just impossible to get rid of. Incidentally, you have this character trait in common with many insects and with other vermin. ...",cid, 1000)
            npcHandler:say("Nevermind. I hate to say it, but it you have done us a favour, human. That gemstone will serve us well. ...",cid, 3000)
            npcHandler:say("Baa'leal, wants you to talk to {Malor} concerning some {new mission.} ...",cid, 4500)
            npcHandler:say("Looks like you have managed to extended your life expectancy - for just a bit longer.",cid, 5500)
            setPlayerStorageValue(cid,storage, 1)
            setPlayerStorageValue(cid, 100062, 8)
            setPlayerStorageValue(cid,100159, 3)
        else
            npcHandler:say("You better don't return here until you've got the Tear.", cid)
            end
        Topic[cid] = 0
        end
    if msgcontains(msg, "bye") or msgcontains(msg, "farewell") then
        npcHandler:say("Finally.",cid)
        npcHandler:releaseFocus(cid)
        npcHandler:resetNpc(cid)
        Topic[cid] = 0
    end
    return true
end

local function onTradeRequest(cid)
    if getPlayerStorageValue(cid, storage2) == -1 then
        npcHandler:say('You did not give you the permission to trade with me.', cid)
        return false
    end
    return true
end

--------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------
npcHandler:setCallback(CALLBACK_ONTRADEREQUEST, onTradeRequest)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
 
Back
Top