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

opcode instalation doSendPlayerExtendedOpcode 1.5 Nekiro downgrade 8.6

Michcol94

Member
Joined
Sep 2, 2021
Messages
105
Reaction score
18
On xtibia.com I found an interesting dialogue system and I wanted to test it. link:
[OTClient] Sistema de Dialogo Otpokemon (https://xtibia.com/forum/topic/252290-otclient-sistema-de-dialogo-otpokemon/page/2/)
It turns out that there is no doSendPlayerExtendedOpcode function in the tfs 1.5 by nekiro downgrade 8.6 engine, at least I haven't found it and it is certainly needed. ExtendedOpcode is supposedly in the engine somewhere in the sources somewhere I found something trying to install opcode according to the guide from our forum. link:
Extended Opcodes (Server Side) (https://otland.net/threads/extended-opcodes-server-side.180536/)
Unfortunately, the guide differs significantly from my source code and I can't do it and I need your help.

And how to enable opcode in otclient mehah?

I would still have a question about the guide from xtibia.com what to do exactly with the downloaded module in the last part of the guide. Because I pasted the module files into the modules folder.

so far the NPC appears when I write to him hi nothing happens and throws this error in the console:
Lua Script Error: [Npc interface]
data/npc/scripts/gengo.lua:eek:nCreatureSay
data/npc/scripts/gengo.lua:11: attempt to call global 'getNpcId' (a nil value)
stack traceback:
[C]: in function 'getNpcId'
data/npc/scripts/gengo.lua:11: in function 'callback'
data/npc/lib/npcsystem/npchandler.lua:340: in function 'greet'
data/npc/lib/npcsystem/npchandler.lua:509: in function 'onGreet'
data/npc/lib/npcsystem/modules.lua:223: in function 'callback'
data/npc/lib/npcsystem/keywordhandler.lua:26: in function 'processMessage'
data/npc/lib/npcsystem/keywordhandler.lua:151: in function 'processNodeMessage'
data/npc/lib/npcsystem/keywordhandler.lua:126: in function 'processMessage'
data/npc/lib/npcsystem/npchandler.lua:398: in function 'onCreatureSay'
data/npc/scripts/gengo.lua:8: in function <data/npc/scripts/gengo.lua:8>
 
Nie ma getNpcId, spróbuj z getNpcCid
Lua Script Error: [Npc interface]
data/npc/scripts/gengo.lua:eek:nCreatureSay
data/npc/scripts/gengo.lua:11: attempt to call global 'doSendDialogNpc' (a nil value)
stack traceback:
[C]: in function 'doSendDialogNpc'
data/npc/scripts/gengo.lua:11: in function 'callback'
data/npc/lib/npcsystem/npchandler.lua:340: in function 'greet'
data/npc/lib/npcsystem/npchandler.lua:509: in function 'onGreet'
data/npc/lib/npcsystem/modules.lua:223: in function 'callback'
data/npc/lib/npcsystem/keywordhandler.lua:26: in function 'processMessage'
data/npc/lib/npcsystem/keywordhandler.lua:151: in function 'processNodeMessage'
data/npc/lib/npcsystem/keywordhandler.lua:119: in function 'processMessage'
data/npc/lib/npcsystem/npchandler.lua:398: in function 'onCreatureSay'
data/npc/scripts/gengo.lua:8: in function <data/npc/scripts/gengo.lua:8>
 
plik 012-table.lua który znajduje się w folderze twojego serwera w data/lib/ lub możesz utworzyć plik i dodać następujący kod:
table.find = function (table, value)

Lua:
for i, v in pairs(table) do
    if(v == value) then
      return i
    end
  end
  return nil
end


table.serialize = function(x, recur)
  local t = type(x)
  recur = recur or {}


  if t == nil then
    return "nil"
  elseif t == "string" then
    return string.format("%q", x)
  elseif t == "number" then
    return tostring(x)
  elseif t == "boolean" then
    return t and "true" or "false"
  elseif getmetatable(x) then
    error("Can not serialize a table that has a metatable associated with it.")
  elseif t == "table" then
    if(table.find(recur, x)) then
      error("Can not serialize recursive tables.")
    end
    table.insert(recur, x)


    local s = "{"
    for k, v in pairs(x) do
      s = s .. "[" .. table.serialize(k, recur) .. "]"
      s = s .. " = " .. table.serialize(v, recur) .. ","
    end
    s = s .. "}"
    return s
  else
    error("Can not serialize value of type '" .. t .. "'.")
  end
end
There was no 012-table.lua in my lib files, so I created a new file and copied the code
 
Lua:
player:doSendDialogNpc(getNpcCid(), "????????",
        "1&2&4&5&6")
Lua:
function Player.doSendDialogNpc(self, npc, msg, opc)
    if ( not opc ) then
      opc = ''
    end
    self:sendExtendedOpcode(OpcodeDialog, table.serialize({ action = Actions.open, data = { npcId = npc, message = msg, options = opc } }))
  end
 
  function Player.doSendDialogNpcClose(self)
    self:sendExtendedOpcode(OpcodeDialog, table.serialize({ action = Actions.closed }))
  end


There was no 012-table.lua in my lib files, so I created a new file and copied the code
\data\lib\lib.lua
Code:
dofile('data/lib/012-table.lua')
 
Where should I use this code " function Player.doSendDialogNpc(self, npc, msg, opc) " and " player:doSendDialogNpc(getNpcCid(), "??????????",
"1&2&4&5&6") "
whether the function file should also be added to lib.lua
dofile('data/lib/npcdialog_lib.lua') ?????????
then it throws more errors when starting the server.


I replaced the lib functions in the npcdialog_lib file and used
Lua:
player:doSendDialogNpc(cid,getNpcCid(), "Olá jovem, vejo que você conseguiu chegar até aqui!\nClique em Recompensa e fique feliz pela conquista!", "Fechar&Recompensa")
I tried without cid as well and it crashes the error on this line in the console:
Lua Script Error: [Npc interface]
data/npc/scripts/gengo.lua:eek:nCreatureSay
data/npc/scripts/gengo.lua:11: attempt to index global 'player' (a nil value)
stack traceback:
[C]: in function '__index'
data/npc/scripts/gengo.lua:11: in function 'callback'
data/npc/lib/npcsystem/npchandler.lua:340: in function 'greet'
data/npc/lib/npcsystem/npchandler.lua:509: in function 'onGreet'
data/npc/lib/npcsystem/modules.lua:223: in function 'callback'
data/npc/lib/npcsystem/keywordhandler.lua:26: in function 'processMessage'
data/npc/lib/npcsystem/keywordhandler.lua:151: in function 'processNodeMessage'
data/npc/lib/npcsystem/keywordhandler.lua:119: in function 'processMessage'
data/npc/lib/npcsystem/npchandler.lua:398: in function 'onCreatureSay'
data/npc/scripts/gengo.lua:8: in function <data/npc/scripts/gengo.lua:8>
 
Last edited:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
function onThink() npcHandler:eek:nThink() end
function onCreatureAppear(cid) npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:eek:nCreatureSay(cid, type, msg) end
function greetCallback(cid)

doSendDialogNpc(getNpcCid(), "Olá jovem, vejo que você conseguiu chegar até aqui!\nClique em Recompensa e fique feliz pela conquista!", "Fechar&Recompensa")
return true
end
function creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
end

if msgcontains(msg:lower(), "recompensa") then
local message = ""
if getPlayerStorageValue(cid, 7000) == -1 then
setPlayerStorageValue(cid, 7000, 1)
doPlayerAddItem(cid, 2160, 1)
message = "Você acaba de ganhar uns trocado por chegar até aqui.\nVolte sempre!"
else
message = "Você ja pegou sua recompensa, obrigado e volte sempre!"
end
doSendDialogNpc(getNpcCid(), message, "Fechar")
elseif msgcontains(msg:lower(), "fechar") then
doSendDialogNpcClose(cid)
npcHandler:unGreet(cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:addModule(FocusModule:new())
I understand more or less the functions that Error 502 wrote to me and it solves the problem of missing function doSendPlayerExtendedOpcode and we use the existing function send ExtendedOpcode but I don't know how to use this function in the code above I tried different ways and always in the line doSendDialogNpc I get a value of zero and it seems to me that it will be terribly simple yesterday I was sitting on one code 7h in one place and I missed two words hehehe can someone help me
Post automatically merged:

Lua:
function greetCallback(cid)
  local player = Player(cid)
  player:doSendDialogNpc(getNpcCid(), "Olá jovem, vejo que você conseguiu chegar até aqui!\nClique em Recompensa e fique feliz pela conquista!", "Fechar&Recompensa")
  return true             
end
[Error - Npc::loadFromXml] Failed to load data/npc/Gengo.xml: File was not found
[Error - Npc::loadFromXml] Failed to load data/npc/Gengo.xml: File was not found
[Error - Npc::loadFromXml] Failed to load data/npc/Gengo.xml: File was not found
[Error - Npc::loadFromXml] Failed to load data/npc/Gengo.xml: File was not found
[Error - Npc::loadFromXml] Failed to load data/npc/Gengo.xml: File was not found
[Error - Npc::loadFromXml] Failed to load data/npc/Gengo.xml: File was not found
[Error - Npc::loadFromXml] Failed to load data/npc/Gengo.xml: File was not found
[Error - Npc::loadFromXml] Failed to load data/npc/Gengo.xml: File was not found
[Error - Npc::loadFromXml] Failed to load data/npc/Gengo.xml: File was not found
[Error - Npc::loadFromXml] Failed to load data/npc/Gengo.xml: File was not found
[Error - Npc::loadFromXml] Failed to load data/npc/Gengo.xml: File was not found
[Error - Npc::loadFromXml] Failed to load data/npc/Gengo.xml: File was not found
Post automatically merged:

Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
function onThink()                     npcHandler:onThink()                     end
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 greetCallback(cid)
  local player = Player(cid)
  player:doSendDialogNpc(cid,getNpcCid(), "Olá jovem, vejo que você conseguiu chegar até aqui!\nClique em Recompensa e fique feliz pela conquista!", "Fechar&Recompensa")
  return true             
end
function creatureSayCallback(cid, type, msg)
 
  if not npcHandler:isFocused(cid) then
    return false
  end
 
  if msgcontains(msg:lower(), "recompensa") then
    local message = ""
    if getPlayerStorageValue(cid, 7000) == -1 then
      setPlayerStorageValue(cid, 7000, 1)
    doPlayerAddItem(cid, 2160, 1)
    message = "Você acaba de ganhar uns trocado por chegar até aqui.\nVolte sempre!"
  else
    message = "Você ja pegou sua recompensa, obrigado e volte sempre!"
    end
  local player = Player(cid)
  player:doSendDialogNpc(cid,getNpcCid(), message, "Fechar")
  elseif msgcontains(msg:lower(), "fechar") then
  player:doSendDialogNpcClose(cid)
  npcHandler:unGreet(cid)
  end
  return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:addModule(FocusModule:new())
Omg it started but I don't know what now? he writes hi ... and the npc replies in chat "23:36 Gengo: Greetings, Aaaaaaaaaaaaaaaaaaaaa." and no dialog box appears :( it doesn't throw any errors in the console, help someone show in the pictures what the effect was supposed to be and what it is.
my module hehe:
Zrzut ekranu 2023-08-06 234400.png
Expected effect:
Zrzut ekranu 2023-08-06 234547.png
Post automatically merged:

I'm writing "recompensa" and gets item everything works except dialog ehhhh annoying
 
Last edited:
Back
Top