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

TFS 1.X+ make a greetcallback call tfs 1.5 7.72

bpm91

Intermediate OT User
Joined
May 23, 2019
Messages
939
Solutions
7
Reaction score
129
Location
Brazil
YouTube
caruniawikibr
I have a small problem, I can't make the greetcallback call work using the magic word djani'hah, I've tried several ways, I even tried to do it with but it doesn't work
Lua:
npcHandler:setMessage(MESSAGE_FAREWELL, 'Farewell human!')
npcHandler:setMessage(MESSAGE_WALKAWAY, 'Farewell human!')


npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)


local focusModule = FocusModule:new()
focusModule:addGreetMessage('djanni\'hah')
npcHandler:addModule(focusModule)

my script is
 

Attachments

try.

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

local function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    local player = Player(cid)

    if not msgcontains(msg, 'djanni\'hah') and (not player or player:getStorageValue(StorageKeys.DjinnWar.Faction.Efreet) ~= 1) then
        npcHandler:say('Shove off, little one! Humans are not welcome here, ' .. player:getName() .. '!', cid)
        return false
    end

    if player:getStorageValue(StorageKeys.DjinnWar.Faction.Greeting) == -1 then
        npcHandler:say({
            'Hahahaha! ...',
            player:getName() .. ', that almost sounded like the word of greeting. Humans - cute they are!'
        }, cid)
        return false
    end

    if player:getStorageValue(StorageKeys.DjinnWar.Faction.Efreet) ~= 1 then
        npcHandler:setMessage(MESSAGE_GREET, 'What? You know the word, ' .. player:getName() .. '? All right then - I won\'t kill you. At least, not now. What brings you {here}?')
    else
        npcHandler:setMessage(MESSAGE_GREET, 'Still alive, ' .. player:getName() .. '? What brings you {here}?')
    end
    return true
end

local function specificCreatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end
    
    local player = Player(cid)
    
    if msgcontains(msg, 'passage') or msgcontains(msg, 'here') then
        if player:getStorageValue(StorageKeys.DjinnWar.Faction.Efreet) ~= 1 then
            npcHandler:say({
                'Only the mighty Efreet, the true djinn of Tibia, may enter Mal\'ouquah! ...',
                'All Marid and little worms like yourself should leave now or something bad may happen. Am I right?'
            }, cid)
            npcHandler.topic[cid] = 1
        else
            npcHandler:say('You already pledged loyalty to king Malor!', cid)
        end
        if msgcontains(msg, 'yes') then
            npcHandler:say('Of course. Then don\'t waste my time and shove off.', cid)
            npcHandler.topic[cid] = 0
        elseif msgcontains(msg, 'no') then
            if player:getStorageValue(PlayerStorageKeys.DjinnWar.Faction.Marid) == 1 then
                npcHandler:say('Who do you think you are? A Marid? Shove off you worm!', cid)
                npcHandler.topic[cid] = 0
            else
                npcHandler:say({
                    'Of cour... Huh!? No!? I can\'t believe it! ...',
                    'You... you got some nerves... Hmm. ...',
                    'Maybe we have some use for someone like you. Would you be interested in working for us. Helping to fight the Marid?'
                }, cid)
                npcHandler.topic[cid] = 2
            end
        end

    elseif npcHandler.topic[cid] == 2 then
        if msgcontains(msg, 'yes') then
            npcHandler:say('So you pledge loyalty to king Malor and you are willing to never ever set foot on Marid\'s territory, unless you want to kill them? Yes?', cid)
            npcHandler.topic[cid] = 3

        elseif msgcontains(msg, 'no') then
            npcHandler:say('Of course. Then don\'t waste my time and shove off.', cid)
            npcHandler.topic[cid] = 0
        end

    elseif npcHandler.topic[cid] == 3 then
        if msgcontains(msg, 'yes') then
            npcHandler:say({
                'Well then - welcome to Mal\'ouquah. ...',
                'Go now to general Baa\'leal and don\'t forget to greet him correctly! ...',
                'And don\'t touch anything!'
            }, cid)
            player:setStorageValue(PlayerStorageKeys.DjinnWar.Faction.Efreet, 1)
            player:setStorageValue(PlayerStorageKeys.DjinnWar.Faction.Greeting, 0)

        elseif msgcontains(msg, 'no') then
            npcHandler:say('Of course. Then don\'t waste my time and shove off.', cid)
        end
        npcHandler.topic[cid] = 0
    end
    return true
end

npcHandler:setMessage(MESSAGE_FAREWELL, 'Farewell human!')
npcHandler:setMessage(MESSAGE_WALKAWAY, 'Farewell human!')
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Back
Top