• 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 0.X Tfs 0.4 npc dont answer if say in lowercase

roriscrave

Advanced OT User
Joined
Dec 7, 2011
Messages
1,188
Solutions
34
Reaction score
200
TFS 0.4 TIBIA 8.6
this travel npc script has a problem, if I say:
hi
Thais
yes
I can travel ...

but if I say
hi
thais
yes
obs: msg thais in lowercase, he does not answer me, how do I fix it?

Code:
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
    --//////////////////////GUEST CARD//////////////////////--
    -- [City Name]
    -- TALK = switching 1, 2, 3, 4 accoring to the number of cities
    -- COST = How many will costs the travel (gold coins)
    -- LEVEL = level needed to travel with this NPC
    -- STOR = True or False,
    ---------[True] if the player needs a certain storage in DATABASE.
    ---------[False] if you wanna disable this function.
    -- STORID = In case you put 'True', paste this your StorageID, required to travel.
    -- DESTINATION = X, Y, Z Position of place where will be teleported.
    --//////////////////////GUEST CARD//////////////////////--
    local travels = {
    ["Thais"] = {talk=1, cost=350, level=0,  stor=false,  storId=1010, destination={x=100, y=100, z=7}},
    ["Venore"] = {talk=2, cost=250, level=10, stor=false,  storId=1010, destination={x=100, y=100, z=7}},
    ["Ankrahmun"] = {talk=3, cost=170, level=25, stor=false,  storId=1010, destination={x=100, y=100, z=7}},
    ["Port Hope"] = {talk=4, cost=165, level=50, stor=false,  storId=1010, destination={x=100, y=100, z=7}}
    }
    for k, v in pairs(travels) do
        if(msgcontains(msg, k)) then
            if v.stor then
                if getPlayerStorageValue(cid, v.storId) > 0 then
                    selfSay('Do you want to travel to '..k..' for '..v.cost..' gold coins?', cid)
                    talkState[talkUser] = v.talk
                    else
                        selfSay('You must got Norseman Mission\'s to travel with me. Hics! Hi ckS ! Hic.', cid)
                        talkState[talkUser] = 0
                    end
                    else
                        selfSay('Do you want to travel to '..k..' for '..v.cost..' gold coins?', cid)
                        talkState[talkUser] = v.talk
                    end        
                elseif(msgcontains(msg, 'yes') and talkState[talkUser] == v.talk) then
                                if getPlayerLevel(cid) >= v.level then
                                        if(doPlayerRemoveMoney(cid, v.cost) == TRUE) then
                                                doTeleportThing(cid, v.destination, FALSE)
                                                selfSay('Traveled to '..k..'.', cid)
                                        else
                                        selfSay('Sorry, you don\'t have enough gold coins.', cid)
                                        end
                                else
                                selfSay('Sorry, you don\'t have enough level.', cid)
                                end
                talkState[talkUser] = 0
                elseif(msgcontains(msg, 'no') and isInArray({v.talk}, talkState[talkUser]) == TRUE) then
                        talkState[talkUser] = 0
                        selfSay('Ok then.', cid)
                end
        end
        return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
Hey,
try to make all city names lowercase and then change this:

Lua:
if(msgcontains(msg:lower(), k)) then
It worked 100%, I wanted to add a table if it is premium account, how do I?

["thais"] = {talk=1, cost=350, level=0, stor=false, storId=1010, premium=true destination={x=100, y=100, z=7}},
 
I had no chance to test it since I don't have tfs 0.4 but try this one:

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
    --//////////////////////GUEST CARD//////////////////////--
    -- [City Name]
    -- TALK = switching 1, 2, 3, 4 accoring to the number of cities
    -- COST = How many will costs the travel (gold coins)
    -- LEVEL = level needed to travel with this NPC
    -- STOR = True or False,
    ---------[True] if the player needs a certain storage in DATABASE.
    ---------[False] if you wanna disable this function.
    -- STORID = In case you put 'True', paste this your StorageID, required to travel.
    -- DESTINATION = X, Y, Z Position of place where will be teleported.
    --//////////////////////GUEST CARD//////////////////////--
    local travels = {
    ["thais"] = {talk=1, cost=350, level=0,  stor=false, prem=false, storId=1010, destination={x=100, y=100, z=7}},
    ["venore"] = {talk=2, cost=250, level=10, stor=false, prem=false, storId=1010, destination={x=100, y=100, z=7}},
    ["ankrahmun"] = {talk=3, cost=170, level=25, stor=false, prem=false, storId=1010, destination={x=100, y=100, z=7}},
    ["port hope"] = {talk=4, cost=165, level=50, stor=false, prem=false, storId=1010, destination={x=100, y=100, z=7}}
    ["test city"] = {talk=5, cost=0, level=0, stor=false, prem=true, storId=110, destination={x=100, y=100, z=7}}
    }
    for k, v in pairs(travels) do
        if(msgcontains(msg:lower(), k)) then
            if v.stor then
                if getPlayerStorageValue(cid, v.storId) > 0 then
                    selfSay('Do you want to travel to '..k..' for '..v.cost..' gold coins?', cid)
                    talkState[talkUser] = v.talk
                    else
                        selfSay('You must got Norseman Mission\'s to travel with me. Hics! Hi ckS ! Hic.', cid)
                        talkState[talkUser] = 0
                    end
                    else
                        selfSay('Do you want to travel to '..k..' for '..v.cost..' gold coins?', cid)
                        talkState[talkUser] = v.talk
                    end      
                elseif(msgcontains(msg, 'yes') and talkState[talkUser] == v.talk) then
                            if not isPremium(cid) and v.prem then
                                selfSay('Sorry, you don\'t have a premium account.', cid)                       
                            else
                                if getPlayerLevel(cid) >= v.level then
                                        if(doPlayerRemoveMoney(cid, v.cost) == TRUE) then
                                                doTeleportThing(cid, v.destination, FALSE)
                                                selfSay('Traveled to '..k..'.', cid)
                                        else
                                        selfSay('Sorry, you don\'t have enough gold coins.', cid)
                                        end
                                else
                                selfSay('Sorry, you don\'t have enough level.', cid)
                                end
                            end
                talkState[talkUser] = 0
                elseif(msgcontains(msg, 'no') and isInArray({v.talk}, talkState[talkUser]) == TRUE) then
                        talkState[talkUser] = 0
                        selfSay('Ok then.', cid)
                end
        end
        return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

EDIT: Changed a typo in the code, should work now
 
Last edited:
works fine! thx a lot man!!!!!
I had no chance to test it since I don't have tfs 0.4 but try this one:

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
    --//////////////////////GUEST CARD//////////////////////--
    -- [City Name]
    -- TALK = switching 1, 2, 3, 4 accoring to the number of cities
    -- COST = How many will costs the travel (gold coins)
    -- LEVEL = level needed to travel with this NPC
    -- STOR = True or False,
    ---------[True] if the player needs a certain storage in DATABASE.
    ---------[False] if you wanna disable this function.
    -- STORID = In case you put 'True', paste this your StorageID, required to travel.
    -- DESTINATION = X, Y, Z Position of place where will be teleported.
    --//////////////////////GUEST CARD//////////////////////--
    local travels = {
    ["thais"] = {talk=1, cost=350, level=0,  stor=false, prem=false, storId=1010, destination={x=100, y=100, z=7}},
    ["venore"] = {talk=2, cost=250, level=10, stor=false, prem=false, storId=1010, destination={x=100, y=100, z=7}},
    ["ankrahmun"] = {talk=3, cost=170, level=25, stor=false, prem=false, storId=1010, destination={x=100, y=100, z=7}},
    ["port hope"] = {talk=4, cost=165, level=50, stor=false, prem=false, storId=1010, destination={x=100, y=100, z=7}}
    ["test city"] = {talk=5, cost=0, level=0, stor=false, prem=true, storId=110, destination={x=100, y=100, z=7}}
    }
    for k, v in pairs(travels) do
        if(msgcontains(msg:lower(), k)) then
            if v.stor then
                if getPlayerStorageValue(cid, v.storId) > 0 then
                    selfSay('Do you want to travel to '..k..' for '..v.cost..' gold coins?', cid)
                    talkState[talkUser] = v.talk
                    else
                        selfSay('You must got Norseman Mission\'s to travel with me. Hics! Hi ckS ! Hic.', cid)
                        talkState[talkUser] = 0
                    end
                    else
                        selfSay('Do you want to travel to '..k..' for '..v.cost..' gold coins?', cid)
                        talkState[talkUser] = v.talk
                    end     
                elseif(msgcontains(msg, 'yes') and talkState[talkUser] == v.talk) then
                            if not isPremium(cid) and v.prem then
                                selfSay('Sorry, you don\'t have a premium account.', cid)                      
                            else
                                if getPlayerLevel(cid) >= v.level then
                                        if(doPlayerRemoveMoney(cid, v.cost) == TRUE) then
                                                doTeleportThing(cid, v.destination, FALSE)
                                                selfSay('Traveled to '..k..'.', cid)
                                        else
                                        selfSay('Sorry, you don\'t have enough gold coins.', cid)
                                        end
                                else
                                selfSay('Sorry, you don\'t have enough level.', cid)
                                end
                            end
                talkState[talkUser] = 0
                elseif(msgcontains(msg, 'no') and isInArray({v.talk}, talkState[talkUser]) == TRUE) then
                        talkState[talkUser] = 0
                        selfSay('Ok then.', cid)
                end
        end
        return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

EDIT: Changed a typo in the code, should work now
 
Back
Top