Here, I changed all the weird letters.I've already done it. it doesn't do anything. : /
Post automatically merged:
maybe it will help. I use tfs tibia 12.64 BR
<?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>
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...
if player:getStorageValue(45001) == 1 then
npcHandler:say("I speak insertLanguage.", cid)
else
npcHandler:say("I speak English.", cid)
end
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()
<?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>
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())
talkaction
npcLua: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 scriptLua:<?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 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())
The player has to execute the talkaction before speaking to the npc.refuses to change the language
The player has to execute the talkaction before speaking to the npc.
Have you done that?
woootI do not understand you
I added code to talkaction. I created a test npc and when I enter / en or / pl nothing happens. why?
/en
, /pl
or / en
, / pl
? xDHere, I changed all the weird letters.I've already done it. it doesn't do anything. : /
Post automatically merged:
maybe it will help. I use tfs tibia 12.64 BR
<?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>
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())
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()
it's easier for you to change the language in lua npc. and save in Ansi encodings.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?