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

Lua Npcs do not respond Item for Item

chupaescadatri

Banned User
Joined
Jul 5, 2014
Messages
338
Reaction score
49
Npcs do not respond when you have item exchange,
they sell keys, they give normal trade, but when it is to change item by item they do not respond, even with the right script, the problem would be in otclient or TFS?

TFS 0.4
Otclient
Tibia 8.6

Trade -> Ok
Buy Keys -> Ok
Addon trade for items -> Dont work
Quest trade items -> dont work

The code on another server works, so I think the error is either in my source or in otclient, if it is in otclient I imagine it to be in const.lua, but I do not know, does anyone know?

Code:
if msgcontains(msg, 'book') or msgcontains(msg, 'notebook') then
    selfSay('Do you bring me my notebook?')
    talk_state = 1
  
    elseif msgcontains(msg, 'yes') and talk_state == 1 and getPlayerItemCount(cid,1950) >= 1 then
    selfSay('Excellent. Here, take this short sword, that might serve you well.')
    doPlayerAddItem(cid, 2406)
    doPlayerRemoveItem(cid,1950, 1)
    talk_state = 0
    elseif msgcontains(msg, 'yes') and talk_state == 1 and getPlayerItemCount(cid,1950) == 0 then
    selfSay('Hm, you don\'t have it.')
    talk_state = 0
    elseif msgcontains(msg, 'no') and talk_state == 1 then
    selfSay('Too bad.')
    talk_state = 0

Code:
    if msgcontains(msg, 'book') or msgcontains(msg, 'notebook') then
    selfSay('Do you bring me my notebook?')
    talk_state = 1
  
    elseif msgcontains(msg, 'yes') and talk_state == 1 and getPlayerItemCount(cid,1950) >= 1 then
    selfSay('Excellent. Here, take this short sword, that might serve you well.')
    doPlayerAddItem(cid, 2406)
    doPlayerRemoveItem(cid,1950, 1)
    talk_state = 0
    elseif msgcontains(msg, 'yes') and talk_state == 1 and getPlayerItemCount(cid,1950) == 0 then
    selfSay('Hm, you don\'t have it.')
    talk_state = 0
    elseif msgcontains(msg, 'no') and talk_state == 1 then
    selfSay('Too bad.')
    talk_state = 0

here is not working, all npcs that will exchange item for another they do not respond anything, when it speaks "book" "infernal bolt" "minotaur leather" etc, everything related to item exchange do not respond, but when they are items to sell them respond
 
Last edited by a moderator:
Lua:
if msgcontains(msg, "book") or msgcontains(msg, "notebook") then
    selfSay("Do you bring me my notebook?")
    talk_state = 1
elseif talk_state == 1 then
    if msgcontains(msg, "yes") then
        if doPlayerRemoveItem(cid, 1950, 1) then       
            selfSay("Excellent. Here, take this short sword, that might serve you well.")
            doPlayerAddItem(cid, 2406, 1)
        else
            selfSay("Hey! You do not have my notebook! Lier lier pants on fire!")
        end
    else
        selfSay("Too bad, I could really use it right now.")
    end
    talk_state = 0
end
 
Lua:
if msgcontains(msg, "book") or msgcontains(msg, "notebook") then
    selfSay("Do you bring me my notebook?")
    talk_state = 1
elseif talk_state == 1 then
    if msgcontains(msg, "yes") then
        if doPlayerRemoveItem(cid, 1950, 1) then      
            selfSay("Excellent. Here, take this short sword, that might serve you well.")
            doPlayerAddItem(cid, 2406, 1)
        else
            selfSay("Hey! You do not have my notebook! Lier lier pants on fire!")
        end
    else
        selfSay("Too bad, I could really use it right now.")
    end
    talk_state = 0
end
[Error - LuaInterface::loadFile] data/npc/scripts/amber.lua:35: 'end' expected (to close 'function' at line 10) near 'elseif'
 
You didn't paste it right, post the full script
but it is in any npc item exchange by item that this happens, :(
Code:
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

function creatureSayCallback(cid, type, msg)
    if(npcHandler.focus ~= cid) then
        return false
    end
  
    -- NPC Amber feito por Rodrigo (Nottinghster)
    -- Inicio Amber NPC
  
    if msgcontains(msg, 'book') or msgcontains(msg, 'notebook') then
    selfSay('Do you bring me my notebook?')
    talk_state = 1
  
    elseif msgcontains(msg, 'yes') and talk_state == 1 and getPlayerItemCount(cid,1950) >= 1 then
    selfSay('Excellent. Here, take this short sword, that might serve you well.')
    doPlayerAddItem(cid, 2406)
    doPlayerRemoveItem(cid,1950, 1)
    talk_state = 0
    elseif msgcontains(msg, 'yes') and talk_state == 1 and getPlayerItemCount(cid,1950) == 0 then
    selfSay('Hm, you don\'t have it.')
    talk_state = 0
    elseif msgcontains(msg, 'no') and talk_state == 1 then
    selfSay('Too bad.')
    talk_state = 0
  
    elseif msgcontains(msg, 'orcish') or msgcontains(msg, 'language') or msgcontains(msg, 'prisoner') then
    selfSay('I speak some orcish words, not much though, just \'yes\' and \'no\' and such basic.')
    talk_state = 2
  
    elseif msgcontains(msg, 'yes') and talk_state == 2 then
    selfSay('It\'s \'mok\' in orcish. I help you more about that if you have some food.')
    elseif msgcontains(msg, 'no') and talk_state == 2 then
    selfSay('In orcish that\'s \'burp\'. I help you more about that if you have some food.')
  
    elseif msgcontains(msg, 'food') then
    selfSay('My favorite dish is salmon. Oh please, bring me some of it.')
  
    elseif msgcontains(msg, 'salmon') then
    selfSay('Yeah! If you give me some salmon I will tell you more about the orcish language.')
    talk_state = 3
  
    elseif msgcontains(msg, 'yes') and talk_state == 3 and getPlayerItemCount(cid,2668) >= 1 then
    selfSay('Thank you. Orcs call arrows \'pixo\'.')
    doPlayerRemoveItem(cid,2668,1)
    elseif msgcontains(msg, 'yes') and talk_state == 3 and getPlayerItemCount(cid,2668) == 0 then
    selfSay('You don\'t have one!')
    talk_state = 0
  
    elseif msgcontains(msg, 'bye') and (talk_state >= 1 and talk_state <= 3) then
    selfSay('See you later.')
    talk_state = 0
  
    end
    -- Final Simon NPC
    -- NPC Simon (Deeper Fibula Quest) feito por Rodrigo (Nottinghster)
    return true
end

keywordHandler:addKeyword({'how'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'are'})
keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I explore and seek adventure.'})
keywordHandler:addKeyword({'explore'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I have been almost everywhere in Tibia.'})
keywordHandler:addKeyword({'adventure'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I fought fierce monsters, climbed the highest mountains, and crossed the sea on a raft.'})
keywordHandler:addKeyword({'sea'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'My trip over the sea was horrible. The weather was bad, the waves high and my raft quite simple.'})
keywordHandler:addKeyword({'time'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Sorry, I lost my watch in a storm.'})
keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I cant help you much beyond information.'})
keywordHandler:addKeyword({'information'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Just ask and Ill try to answer.'})
keywordHandler:addKeyword({'dungeon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I have not had the time to explore the dungeons of this isle, but I have seen two big caves in the east, and there is a ruined tower in the northwest.'})
keywordHandler:addKeyword({'sewer'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I like sewers. I made my very first battle experience in the Thais sewers. The small sewersystem of Rookgaard has some nasty rats to fight.'})
keywordHandler:addKeyword({'assistant'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I have a job of great responsibility. Mostly I keep annoying persons away from my boss.'})
keywordHandler:addKeyword({'monster'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Oh, I fought orcs, cyclopses, minotaurs, and even green dragons.'})
keywordHandler:addKeyword({'cyclops'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Horrible monsters they are.'})
keywordHandler:addKeyword({'minotaur'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Horrible monsters they are.'})
keywordHandler:addKeyword({'dragon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Horrible monsters they are.'})
keywordHandler:addKeyword({'raft'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I left my raft at the south eastern shore. I forgot my private notebook on it. If you could return it to me I would be very grateful.'})
keywordHandler:addKeyword({'quest'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I left my raft at the south eastern shore. I forgot my private notebook on it. If you could return it to me I would be very grateful.'})
keywordHandler:addKeyword({'mission'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I left my raft at the south eastern shore. I forgot my private notebook on it. If you could return it to me I would be very grateful.'})
keywordHandler:addKeyword({'seymour'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I think this poor guy was a bad choice as the head of the academy.'})
keywordHandler:addKeyword({'academy'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'A fine institution, but it needs definitely more funds from the king.'})
keywordHandler:addKeyword({'king'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'King Tibianus is the ruler of Thais.'})
keywordHandler:addKeyword({'thais'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'A fine city, but the king has some problems enforcing the law.'})
keywordHandler:addKeyword({'cipfried'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'A gentle person. You should visit him, if you have problems.'})
keywordHandler:addKeyword({'dallheim'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'An extraordinary warrior. Hes the first and last line of defense of Rookgaard.'})
keywordHandler:addKeyword({'hyacinth'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Hyacinth is a great healer. He lives somewhere hidden on this isle.'})
keywordHandler:addKeyword({'willie'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Hes funny in his own, gruffy way.'})
keywordHandler:addKeyword({'obi'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Hes a funny little man.'})
keywordHandler:addKeyword({'weapon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'The best weapons on this isle are just toothpicks, compared with the weapons warriors of the mainland wield.'})
keywordHandler:addKeyword({'magic'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'You can learn spells only in the guildhalls of the mainland.'})
keywordHandler:addKeyword({'tibia'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I try to explore each spot of Tibia, and one day I will succeed.'})
keywordHandler:addKeyword({'castle'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'If you travel to Thais, you really should visit the marvelous castle.'})
keywordHandler:addKeyword({'orcish'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I speak some orcish words, not much though, just yes and no and such basic.'})
keywordHandler:addKeyword({'language'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I speak some orcish words, not much though, just yes and no and such basic.'})
keywordHandler:addKeyword({'prisoner'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I speak some orcish words, not much though, just yes and no and such basic.'})
keywordHandler:addKeyword({'orc'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Not the nicest guys you can encounter. I had some clashes with them and was prisoner of the orcs for some months.'})
keywordHandler:addKeyword({'food'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'My favorite dish is salmon. Oh please, bring me some of it.'})
keywordHandler:addKeyword({'salmon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Yeah! If you give me some salmon I will tell you more about the orcish language.'})
npcHandler:addModule(FocusModule:new())
 
but it is in any npc item exchange by item that this happens, :(
Code:
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

function creatureSayCallback(cid, type, msg)
    if(npcHandler.focus ~= cid) then
        return false
    end
 
    -- NPC Amber feito por Rodrigo (Nottinghster)
    -- Inicio Amber NPC
 
    if msgcontains(msg, 'book') or msgcontains(msg, 'notebook') then
    selfSay('Do you bring me my notebook?')
    talk_state = 1
 
    elseif msgcontains(msg, 'yes') and talk_state == 1 and getPlayerItemCount(cid,1950) >= 1 then
    selfSay('Excellent. Here, take this short sword, that might serve you well.')
    doPlayerAddItem(cid, 2406)
    doPlayerRemoveItem(cid,1950, 1)
    talk_state = 0
    elseif msgcontains(msg, 'yes') and talk_state == 1 and getPlayerItemCount(cid,1950) == 0 then
    selfSay('Hm, you don\'t have it.')
    talk_state = 0
    elseif msgcontains(msg, 'no') and talk_state == 1 then
    selfSay('Too bad.')
    talk_state = 0
 
    elseif msgcontains(msg, 'orcish') or msgcontains(msg, 'language') or msgcontains(msg, 'prisoner') then
    selfSay('I speak some orcish words, not much though, just \'yes\' and \'no\' and such basic.')
    talk_state = 2
 
    elseif msgcontains(msg, 'yes') and talk_state == 2 then
    selfSay('It\'s \'mok\' in orcish. I help you more about that if you have some food.')
    elseif msgcontains(msg, 'no') and talk_state == 2 then
    selfSay('In orcish that\'s \'burp\'. I help you more about that if you have some food.')
 
    elseif msgcontains(msg, 'food') then
    selfSay('My favorite dish is salmon. Oh please, bring me some of it.')
 
    elseif msgcontains(msg, 'salmon') then
    selfSay('Yeah! If you give me some salmon I will tell you more about the orcish language.')
    talk_state = 3
 
    elseif msgcontains(msg, 'yes') and talk_state == 3 and getPlayerItemCount(cid,2668) >= 1 then
    selfSay('Thank you. Orcs call arrows \'pixo\'.')
    doPlayerRemoveItem(cid,2668,1)
    elseif msgcontains(msg, 'yes') and talk_state == 3 and getPlayerItemCount(cid,2668) == 0 then
    selfSay('You don\'t have one!')
    talk_state = 0
 
    elseif msgcontains(msg, 'bye') and (talk_state >= 1 and talk_state <= 3) then
    selfSay('See you later.')
    talk_state = 0
 
    end
    -- Final Simon NPC
    -- NPC Simon (Deeper Fibula Quest) feito por Rodrigo (Nottinghster)
    return true
end

keywordHandler:addKeyword({'how'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'are'})
keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I explore and seek adventure.'})
keywordHandler:addKeyword({'explore'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I have been almost everywhere in Tibia.'})
keywordHandler:addKeyword({'adventure'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I fought fierce monsters, climbed the highest mountains, and crossed the sea on a raft.'})
keywordHandler:addKeyword({'sea'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'My trip over the sea was horrible. The weather was bad, the waves high and my raft quite simple.'})
keywordHandler:addKeyword({'time'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Sorry, I lost my watch in a storm.'})
keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I cant help you much beyond information.'})
keywordHandler:addKeyword({'information'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Just ask and Ill try to answer.'})
keywordHandler:addKeyword({'dungeon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I have not had the time to explore the dungeons of this isle, but I have seen two big caves in the east, and there is a ruined tower in the northwest.'})
keywordHandler:addKeyword({'sewer'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I like sewers. I made my very first battle experience in the Thais sewers. The small sewersystem of Rookgaard has some nasty rats to fight.'})
keywordHandler:addKeyword({'assistant'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I have a job of great responsibility. Mostly I keep annoying persons away from my boss.'})
keywordHandler:addKeyword({'monster'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Oh, I fought orcs, cyclopses, minotaurs, and even green dragons.'})
keywordHandler:addKeyword({'cyclops'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Horrible monsters they are.'})
keywordHandler:addKeyword({'minotaur'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Horrible monsters they are.'})
keywordHandler:addKeyword({'dragon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Horrible monsters they are.'})
keywordHandler:addKeyword({'raft'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I left my raft at the south eastern shore. I forgot my private notebook on it. If you could return it to me I would be very grateful.'})
keywordHandler:addKeyword({'quest'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I left my raft at the south eastern shore. I forgot my private notebook on it. If you could return it to me I would be very grateful.'})
keywordHandler:addKeyword({'mission'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I left my raft at the south eastern shore. I forgot my private notebook on it. If you could return it to me I would be very grateful.'})
keywordHandler:addKeyword({'seymour'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I think this poor guy was a bad choice as the head of the academy.'})
keywordHandler:addKeyword({'academy'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'A fine institution, but it needs definitely more funds from the king.'})
keywordHandler:addKeyword({'king'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'King Tibianus is the ruler of Thais.'})
keywordHandler:addKeyword({'thais'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'A fine city, but the king has some problems enforcing the law.'})
keywordHandler:addKeyword({'cipfried'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'A gentle person. You should visit him, if you have problems.'})
keywordHandler:addKeyword({'dallheim'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'An extraordinary warrior. Hes the first and last line of defense of Rookgaard.'})
keywordHandler:addKeyword({'hyacinth'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Hyacinth is a great healer. He lives somewhere hidden on this isle.'})
keywordHandler:addKeyword({'willie'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Hes funny in his own, gruffy way.'})
keywordHandler:addKeyword({'obi'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Hes a funny little man.'})
keywordHandler:addKeyword({'weapon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'The best weapons on this isle are just toothpicks, compared with the weapons warriors of the mainland wield.'})
keywordHandler:addKeyword({'magic'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'You can learn spells only in the guildhalls of the mainland.'})
keywordHandler:addKeyword({'tibia'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I try to explore each spot of Tibia, and one day I will succeed.'})
keywordHandler:addKeyword({'castle'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'If you travel to Thais, you really should visit the marvelous castle.'})
keywordHandler:addKeyword({'orcish'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I speak some orcish words, not much though, just yes and no and such basic.'})
keywordHandler:addKeyword({'language'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I speak some orcish words, not much though, just yes and no and such basic.'})
keywordHandler:addKeyword({'prisoner'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I speak some orcish words, not much though, just yes and no and such basic.'})
keywordHandler:addKeyword({'orc'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Not the nicest guys you can encounter. I had some clashes with them and was prisoner of the orcs for some months.'})
keywordHandler:addKeyword({'food'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'My favorite dish is salmon. Oh please, bring me some of it.'})
keywordHandler:addKeyword({'salmon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Yeah! If you give me some salmon I will tell you more about the orcish language.'})
npcHandler:addModule(FocusModule:new())

If it's all the NPCs you didn't post the full error (should be in libs in that case)
Take an SS of your console
 
If it's all the NPCs you didn't post the full error (should be in libs in that case)
Take an SS of your console
The strange thing is that the console is not an information, only the npc does not respond, is there any registry that it is possible to put to the console to show the error? or something to do with source?
 
The strange thing is that the console is not an information, only the npc does not respond, is there any registry that it is possible to put to the console to show the error? or something to do with source?

If you don't get any errors where did you get this from?
[Error - LuaInterface::loadFile] data/npc/scripts/amber.lua:35: 'end' expected (to close 'function' at line 10) near 'elseif'

There is a way to test if the script is loaded and what parts are loaded, below function ..() put
Lua:
print("it loaded the script")

Then add more prints with diffrent words to see if it breaks at an if statment etc
Lua:
print("loaded if statment isPlayer")
 
If you don't get any errors where did you get this from?


There is a way to test if the script is loaded and what parts are loaded, below function ..() put
Lua:
print("it loaded the script")

Then add more prints with diffrent words to see if it breaks at an if statment etc
Lua:
print("loaded if statment isPlayer")
the print loaded in tfs, but I asked for the item for npc, it did not respond, and no error appeared any terminal and neither tfs console
 
the print loaded in tfs, but I asked for the item for npc, it did not respond, and no error appeared any terminal and neither tfs console

Well I would tab the script and add prints.
You add them before and after if statments, ex "loading isPlayer" and after "passed isPlayer" then you will be able to see where it stops.
 
Well I would tab the script and add prints.
You add them before and after if statments, ex "loading isPlayer" and after "passed isPlayer" then you will be able to see where it stops.
he did not point me where the script stops,
no error appears,
if you send another message to npc it responds, it is not answered as exchange messages of the item, there is no error, I am in doubt if it is something related to the messagemode game or if it is some tfs source error, but the most strange is not that of the error message in otclient and not the error message no tfs, I do not know also if it has some system of "security" for some error in the exchange of item ..
 
he did not point me where the script stops,
no error appears,
if you send another message to npc it responds, it is not answered as exchange messages of the item, there is no error, I am in doubt if it is something related to the messagemode game or if it is some tfs source error, but the most strange is not that of the error message in otclient and not the error message no tfs, I do not know also if it has some system of "security" for some error in the exchange of item ..

Can you talk to other NPCs? If you can it's the NPC script, not server, client or lib related.
Are you using the correct npc libs?
 
Can you talk to other NPCs? If you can it's the NPC script, not server, client or lib related.
Are you using the correct npc libs?
I can talk to any npc, but the function of swapping an item for another item,
for addon, quest,
book by item
anything that is paid with item, npc does not respond, any npc, with any script that is related to item, I imagine it should be some block

I think I'm using the correct lib, I believe
 
I can talk to any npc, but the function of swapping an item for another item,
for addon, quest,
book by item
anything that is paid with item, npc does not respond, any npc, with any script that is related to item, I imagine it should be some block

I think I'm using the correct lib, I believe

Then replace them with the correct ones.

By a quick glance;
Lua:
 elseif msgcontains(msg, 'yes') and talk_state == 1 and getPlayerItemCount(cid,1950) >= 1 then
If the player does not have the item "1950" (more then 1) it won't say anything.

You don't have any "else" statment(s) with error messages.
 
Then replace them with the correct ones.

By a quick glance;
Lua:
 elseif msgcontains(msg, 'yes') and talk_state == 1 and getPlayerItemCount(cid,1950) >= 1 then
If the player does not have the item "1950" (more then 1) it won't say anything.

You don't have any "else" statment(s) with error messages.
Code:
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

function creatureSayCallback(cid, type, msg)
    if(npcHandler.focus ~= cid) then
        return false
    end
  
    -- NPC Amber feito por Rodrigo (Nottinghster)
    -- Inicio Amber NPC
  
    if msgcontains(msg, 'book') or msgcontains(msg, 'notebook') then
    selfSay('Do you bring me my notebook?')
    talk_state = 1
  
    elseif msgcontains(msg, 'yes') and talk_state == 1 and getPlayerItemCount(cid,1950) >= 1 then
    selfSay('Excellent. Here, take this short sword, that might serve you well.')
    doPlayerAddItem(cid, 2406)
    doPlayerRemoveItem(cid,1950, 1)
    talk_state = 0
    elseif msgcontains(msg, 'yes') and talk_state == 1 and getPlayerItemCount(cid,1950) == 0 then
    selfSay('Hm, you don\'t have it.')
    talk_state = 0
    elseif msgcontains(msg, 'no') and talk_state == 1 then
    selfSay('Too bad.')
    talk_state = 0
  
    elseif msgcontains(msg, 'orcish') or msgcontains(msg, 'language') or msgcontains(msg, 'prisoner') then
    selfSay('I speak some orcish words, not much though, just \'yes\' and \'no\' and such basic.')
    talk_state = 2
  
    elseif msgcontains(msg, 'yes') and talk_state == 2 then
    selfSay('It\'s \'mok\' in orcish. I help you more about that if you have some food.')
    elseif msgcontains(msg, 'no') and talk_state == 2 then
    selfSay('In orcish that\'s \'burp\'. I help you more about that if you have some food.')
  
    elseif msgcontains(msg, 'food') then
    selfSay('My favorite dish is salmon. Oh please, bring me some of it.')
  
    elseif msgcontains(msg, 'salmon') then
    selfSay('Yeah! If you give me some salmon I will tell you more about the orcish language.')
    talk_state = 3
  
    elseif msgcontains(msg, 'yes') and talk_state == 3 and getPlayerItemCount(cid,2668) >= 1 then
    selfSay('Thank you. Orcs call arrows \'pixo\'.')
    doPlayerRemoveItem(cid,2668,1)
    elseif msgcontains(msg, 'yes') and talk_state == 3 and getPlayerItemCount(cid,2668) == 0 then
    selfSay('You don\'t have one!')
    talk_state = 0
  
    elseif msgcontains(msg, 'bye') and (talk_state >= 1 and talk_state <= 3) then
    selfSay('See you later.')
    talk_state = 0
  
    end
    -- Final Simon NPC
    -- NPC Simon (Deeper Fibula Quest) feito por Rodrigo (Nottinghster)
    return true
end
I already had this line,
but no exchange is working,
when going to exchange item for money, even no chat without being no trade it works,
but it's not for money it does not work,
for money the command is
Code:
 if player_money >= 5000 then
        if doPlayerRemoveMoney(cid,5000) then
            npcHandler:say('Here it is.', cid)
and the item code is:
Code:
 elseif msgcontains(msg, 'yes') and talk_state == 1 and getPlayerItemCount(cid,1950) >= 1 then
    selfSay('Excellent. Here, take this short sword, that might serve you well.')
    doPlayerAddItem(cid, 2406)
    doPlayerRemoveItem(cid,1950, 1)
it seems that the code that does not work is the "doPlayerRemoveItem" even though it does not report any errors, npc does not respond at all when it has the "doPlayerRemoveItem" function in any npc
 
Code:
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

function creatureSayCallback(cid, type, msg)
    if(npcHandler.focus ~= cid) then
        return false
    end
 
    -- NPC Amber feito por Rodrigo (Nottinghster)
    -- Inicio Amber NPC
 
    if msgcontains(msg, 'book') or msgcontains(msg, 'notebook') then
    selfSay('Do you bring me my notebook?')
    talk_state = 1
 
    elseif msgcontains(msg, 'yes') and talk_state == 1 and getPlayerItemCount(cid,1950) >= 1 then
    selfSay('Excellent. Here, take this short sword, that might serve you well.')
    doPlayerAddItem(cid, 2406)
    doPlayerRemoveItem(cid,1950, 1)
    talk_state = 0
    elseif msgcontains(msg, 'yes') and talk_state == 1 and getPlayerItemCount(cid,1950) == 0 then
    selfSay('Hm, you don\'t have it.')
    talk_state = 0
    elseif msgcontains(msg, 'no') and talk_state == 1 then
    selfSay('Too bad.')
    talk_state = 0
 
    elseif msgcontains(msg, 'orcish') or msgcontains(msg, 'language') or msgcontains(msg, 'prisoner') then
    selfSay('I speak some orcish words, not much though, just \'yes\' and \'no\' and such basic.')
    talk_state = 2
 
    elseif msgcontains(msg, 'yes') and talk_state == 2 then
    selfSay('It\'s \'mok\' in orcish. I help you more about that if you have some food.')
    elseif msgcontains(msg, 'no') and talk_state == 2 then
    selfSay('In orcish that\'s \'burp\'. I help you more about that if you have some food.')
 
    elseif msgcontains(msg, 'food') then
    selfSay('My favorite dish is salmon. Oh please, bring me some of it.')
 
    elseif msgcontains(msg, 'salmon') then
    selfSay('Yeah! If you give me some salmon I will tell you more about the orcish language.')
    talk_state = 3
 
    elseif msgcontains(msg, 'yes') and talk_state == 3 and getPlayerItemCount(cid,2668) >= 1 then
    selfSay('Thank you. Orcs call arrows \'pixo\'.')
    doPlayerRemoveItem(cid,2668,1)
    elseif msgcontains(msg, 'yes') and talk_state == 3 and getPlayerItemCount(cid,2668) == 0 then
    selfSay('You don\'t have one!')
    talk_state = 0
 
    elseif msgcontains(msg, 'bye') and (talk_state >= 1 and talk_state <= 3) then
    selfSay('See you later.')
    talk_state = 0
 
    end
    -- Final Simon NPC
    -- NPC Simon (Deeper Fibula Quest) feito por Rodrigo (Nottinghster)
    return true
end
I already had this line,
but no exchange is working,
when going to exchange item for money, even no chat without being no trade it works,
but it's not for money it does not work,
for money the command is
Code:
 if player_money >= 5000 then
        if doPlayerRemoveMoney(cid,5000) then
            npcHandler:say('Here it is.', cid)
and the item code is:
Code:
 elseif msgcontains(msg, 'yes') and talk_state == 1 and getPlayerItemCount(cid,1950) >= 1 then
    selfSay('Excellent. Here, take this short sword, that might serve you well.')
    doPlayerAddItem(cid, 2406)
    doPlayerRemoveItem(cid,1950, 1)
it seems that the code that does not work is the "doPlayerRemoveItem" even though it does not report any errors, npc does not respond at all when it has the "doPlayerRemoveItem" function in any npc

Splitting the if statment won't help, you need an else statment so when the if statment fails (everything is not "true") it will send a message to the player saying ex "you need more money".
One of them is most likely returning false (once again print them out and see what the problem is)
 
Splitting the if statment won't help, you need an else statment so when the if statment fails (everything is not "true") it will send a message to the player saying ex "you need more money".
One of them is most likely returning false (once again print them out and see what the problem is)
The money is ok
What is not working are exchanging items, even with the item in the backpack, with the exchange item in the backpack, or without the backpack exchange item, it does not return any errors
 
Back
Top