• 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 in two languages

danio4don

AlatharStudio
Joined
Jun 15, 2012
Messages
371
Reaction score
55
Location
Poland
Hello. once on the forum I saw a script that gave the choice of npc language, etc.

I mean the npc would speak two languages.

has anyone got such a script under tfs 1.3?
 
Solution
I've already done it. it doesn't do anything. : /
Post automatically merged:

maybe it will help. I use tfs tibia 12.64 BR
Here, I changed all the weird letters.

bandicam-2021-04-22-11-13-19-718.gif
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Language Test" script="Language Test.lua" walkinterval="2000" floorchange="0">
    <health now="100" max="100" />
    <look type="138" head="57" body="59" legs="40" feet="76" addons="0" />
</npc>
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)              npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)           npcHandler:onCreatureDisappear(cid)         end...
You could basically do this with a storage value.
Could probably automate it a little bit, using a table, but that's the general idea.
Suffice to say, there isn't really an 'npc' to give to you.. It's just the solution / idea.

Lua:
if player:getStorageValue(45001) == 1 then
    npcHandler:say("I speak insertLanguage.", cid)
else
    npcHandler:say("I speak English.", cid)
end
 
talkaction
Lua:
local talk = TalkAction("/language", "/język")

function talk.onSay(player, words, param)
    if player:getStorageValue(45001) == 1 then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Language has been changed to English.")
        player:setStorageValue(45001, -1)
    else
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Język został zmieniony na polski.")
        player:setStorageValue(45001, 1)
    end
    return false
end

talk:register()
npc
Lua:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Language Test" script="Language Test.lua" walkinterval="2000" floorchange="0">
    <health now="100" max="100" />
    <look type="138" head="57" body="59" legs="40" feet="76" addons="0" />
</npc>
npc script
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

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 greetCallback(cid)
    npcHandler.topic[cid] = 0
    local player = Player(cid)
    if player:getStorageValue(45001) == 1 then
        npcHandler:setMessage(MESSAGE_GREET, "Witamy spowrotem |PLAYERNAME|. Jak mogę ci pomóc?")
    else
        npcHandler:setMessage(MESSAGE_GREET, "Welcome back |PLAYERNAME|. How can I help you?")
    end
   
    return true
end

local function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end
   
    local player = Player(cid)
   
    if player:getStorageValue(45001) == 1 then
        if msgcontains(msg, "wsparcie") then
            npcHandler:say("W czym chciałbyś uzyskać pomoc?", cid)
        elseif msgcontains(msg, "język") and npcHandler.topic[cid] == 1 then
            npcHandler:say("Ja mówie po polsku.", cid)
        end
       
    else
        if msgcontains(msg, "help") then
            npcHandler:say("What would you like help with?", cid)
        elseif msgcontains(msg, "language") and npcHandler.topic[cid] == 1 then
            npcHandler:say("I speak English.", cid)
        end
    end

    return true
end

local function onAddFocus(cid)

end

local function onReleaseFocus(cid)

end

npcHandler:setCallback(CALLBACK_ONADDFOCUS, onAddFocus)
npcHandler:setCallback(CALLBACK_ONRELEASEFOCUS, onReleaseFocus)

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
talkaction
Lua:
local talk = TalkAction("/language", "/język")

function talk.onSay(player, words, param)
    if player:getStorageValue(45001) == 1 then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Language has been changed to English.")
        player:getStorageValue(45001, -1)
    else
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Język został zmieniony na polski.")
        player:getStorageValue(45001, 1)
    end
    return false
end

talk:register()
npc
Lua:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Language Test" script="Language Test.lua" walkinterval="2000" floorchange="0">
    <health now="100" max="100" />
    <look type="138" head="57" body="59" legs="40" feet="76" addons="0" />
</npc>
npc script
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

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 greetCallback(cid)
    npcHandler.topic[cid] = 0
    local player = Player(cid)
    if player:getStorageValue(45001) == 1 then
        npcHandler:setMessage(MESSAGE_GREET, "Witamy spowrotem |PLAYERNAME|. Jak mogę ci pomóc?")
    else
        npcHandler:setMessage(MESSAGE_GREET, "Welcome back |PLAYERNAME|. How can I help you?")
    end
  
    return true
end

local function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end
  
    local player = Player(cid)
  
    if player:getStorageValue(45001) == 1 then
        if msgcontains(msg, "wsparcie") then
            npcHandler:say("W czym chciałbyś uzyskać pomoc?", cid)
        elseif msgcontains(msg, "język") and npcHandler.topic[cid] == 1 then
            npcHandler:say("Ja mówie po polsku.", cid)
        end
      
    else
        if msgcontains(msg, "help") then
            npcHandler:say("What would you like help with?", cid)
        elseif msgcontains(msg, "language") and npcHandler.topic[cid] == 1 then
            npcHandler:say("I speak English.", cid)
        end
    end

    return true
end

local function onAddFocus(cid)

end

local function onReleaseFocus(cid)

end

npcHandler:setCallback(CALLBACK_ONADDFOCUS, onAddFocus)
npcHandler:setCallback(CALLBACK_ONRELEASEFOCUS, onReleaseFocus)

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Post automatically merged:

I added everything. but still refuses to change the language. there are no bugs.
 
I've already done it. it doesn't do anything. : /
Post automatically merged:

maybe it will help. I use tfs tibia 12.64 BR
 
I've already done it. it doesn't do anything. : /
Post automatically merged:

maybe it will help. I use tfs tibia 12.64 BR
Here, I changed all the weird letters.

bandicam-2021-04-22-11-13-19-718.gif
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Language Test" script="Language Test.lua" walkinterval="2000" floorchange="0">
    <health now="100" max="100" />
    <look type="138" head="57" body="59" legs="40" feet="76" addons="0" />
</npc>
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

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 greetCallback(cid)
    npcHandler.topic[cid] = 0
    local player = Player(cid)
    if player:getStorageValue(45001) == 1 then
        npcHandler:setMessage(MESSAGE_GREET, "Witamy spowrotem |PLAYERNAME|. Jak moge ci pomoc?")
    else
        npcHandler:setMessage(MESSAGE_GREET, "Welcome back |PLAYERNAME|. How can I help you?")
    end
   
    return true
end

local function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end
   
    local player = Player(cid)
   
    if player:getStorageValue(45001) == 1 then
        if msgcontains(msg, "wsparcie") then
            npcHandler:say("W czym chcialbys uzyskac pomoc?", cid)
        elseif msgcontains(msg, "jezyk") then
            npcHandler:say("Ja mowie po polsku.", cid)
        end
       
    else
        if msgcontains(msg, "help") then
            npcHandler:say("What would you like help with?", cid)
        elseif msgcontains(msg, "language") then
            npcHandler:say("I speak English.", cid)
        end
    end

    return true
end

local function onAddFocus(cid)

end

local function onReleaseFocus(cid)

end

npcHandler:setCallback(CALLBACK_ONADDFOCUS, onAddFocus)
npcHandler:setCallback(CALLBACK_ONRELEASEFOCUS, onReleaseFocus)

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Lua:
local talk = TalkAction("/language", "/jezyk")

function talk.onSay(player, words, param)
    if player:getStorageValue(45001) == 1 then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Language has been changed to English.")
        player:setStorageValue(45001, -1)
    else
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Jezyk zostal zmieniony na polski.")
        player:setStorageValue(45001, 1)
    end
    return false
end

talk:register()
 
Solution
Back
Top