narutomaniacos 14 Posted November 1, 2020 Report Share Posted November 1, 2020 (edited) Estou tentando implementar esse sistema: Estou recebendo o erro de nil value na função doSendPlayerExtendedOpcode. Já tentei usar Player.sendExtendedOpcode porém é retornado o seguinte erro: data/lib/core/player.lua:74: attempt to index local 'self' (a number value) stack traceback: [C]: in function '__index' data/lib/core/player.lua:74: in function 'sendExtendedOpcode' data/lib/npcdialog_lib.lua:11: in function 'doSendDialogNpc' data/npc/scripts/kame.lua:11: in function 'callback' data/npc/lib/npcsystem/npchandler.lua:340: in function 'greet' data/npc/lib/npcsystem/npchandler.lua:519: 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:136: in function 'processNodeMessage' data/npc/lib/npcsystem/keywordhandler.lua:111: in function 'processMessage' data/npc/lib/npcsystem/npchandler.lua:408: in function 'onCreatureSay' data/npc/scripts/kame.lua:8: in function <data/npc/scripts/kame.lua:8> alguma sugestão de como resolver? Edited November 2, 2020 by narutomaniacos Link to comment https://xtibia.com/forum/topic/252513-sistema-de-dialogo-para-tfs-13/ Share on other sites More sharing options...
0 Gengo 202 Posted November 2, 2020 Report Share Posted November 2, 2020 Você precisa adaptar conforme suas necessidades, segue ai, se não funcionar, só lamento, como disse, vc precisa adaptar conforme suas tfs 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 greetCallback(player) player:doSendDialogNpc(Npc():getId(), "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 end function onReleaseFocus(player) player:doSendDialogNpcClose() end npcHandler:setCallback(CALLBACK_GREET, greetCallback) npcHandler:setCallback(CALLBACK_ONRELEASEFOCUS, onReleaseFocus) npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) narutomaniacos 1 Link to comment https://xtibia.com/forum/topic/252513-sistema-de-dialogo-para-tfs-13/#findComment-1763418 Share on other sites More sharing options...
0 Nysman 3 Posted November 2, 2020 Report Share Posted November 2, 2020 (edited) 4 horas atrás, narutomaniacos disse: Versão do Servidor: TFS - 1.2 Tipo de Script: Código: Mostrar conteúdo oculto local OpcodeDialog = 80 local Actions = { open = 1, closed = 2 } function doSendDialogNpc(cid, npc, msg, opc) if ( not opc ) then opc = '' end player:doSendPlayerExtendedOpcode(cid, OpcodeDialog, table.serialize({ action = Actions.open, data = { npcId = npc, message = msg, options = opc } })) end function doSendDialogNpcClose(cid) doPlayerSendExtendedOpcode(cid, OpcodeDialog, table.serialize({ action = Actions.closed })) end table.find = function (table, value) for i, v in pairs(table) do if(v == value) then return i end end return nil end Estou tentando implementar esse sistema: Porém estou recebendo o erro de nil value na função doSendPlayerExtendedOpcode. Já tentei usar doPlayerSendExtendedOpcode, player:doSendPlayerExtendedOpcode, todos sem sucesso... alguma sugestão de como resolver? É simples, o seu servidor não tem Opcode, vai precisar adicionar. Edited November 2, 2020 by Nysman Link to comment https://xtibia.com/forum/topic/252513-sistema-de-dialogo-para-tfs-13/#findComment-1763403 Share on other sites More sharing options...
0 narutomaniacos 14 Posted November 2, 2020 Author Report Share Posted November 2, 2020 1 hora atrás, Nysman disse: É simples, o seu servidor não tem Opcode, vai precisar adicionar. Até onde eu sei tfs 1.3 já vem com opcode por padrão, e acho muito díficil não ter, visto que em lib/core/player.lua tem essa função que já veio no tfs function Player.sendExtendedOpcode(self, opcode, buffer) if not self:isUsingOtClient() then return false end local networkMessage = NetworkMessage() networkMessage:addByte(0x32) networkMessage:addByte(opcode) networkMessage:addString(buffer) networkMessage:sendToPlayer(self) networkMessage:delete() return true end e em data/creaturescripts/scripts tem o extendedopcode.lua Link to comment https://xtibia.com/forum/topic/252513-sistema-de-dialogo-para-tfs-13/#findComment-1763407 Share on other sites More sharing options...
0 Poccnn 385 Posted November 2, 2020 Report Share Posted November 2, 2020 13 horas atrás, narutomaniacos disse: Já tentei usar Player.sendExtendedOpcode em quais arquivos tu fez essa mudança? Link to comment https://xtibia.com/forum/topic/252513-sistema-de-dialogo-para-tfs-13/#findComment-1763408 Share on other sites More sharing options...
0 Nysman 3 Posted November 2, 2020 Report Share Posted November 2, 2020 (edited) O erro diz que não tem opcode, mas enfim. Talvez um? player.self = funcion (player, value) for i, v in pairs (player) do if (v == value) then return i end end return nil end Edited November 2, 2020 by Nysman Link to comment https://xtibia.com/forum/topic/252513-sistema-de-dialogo-para-tfs-13/#findComment-1763411 Share on other sites More sharing options...
0 Gengo 202 Posted November 2, 2020 Report Share Posted November 2, 2020 local OpcodeDialog = 80 local Actions = { open = 1, closed = 2 } 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 narutomaniacos 1 Link to comment https://xtibia.com/forum/topic/252513-sistema-de-dialogo-para-tfs-13/#findComment-1763412 Share on other sites More sharing options...
0 narutomaniacos 14 Posted November 2, 2020 Author Report Share Posted November 2, 2020 6 horas atrás, Poccnn disse: em quais arquivos tu fez essa mudança? npcdialog_lib.lua 4 horas atrás, Nysman disse: O erro diz que não tem opcode, mas enfim. Tranquilo, obrigado por tentar ajudar 3 horas atrás, Gengo disse: local OpcodeDialog = 80 local Actions = { open = 1, closed = 2 } 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 Obrigado, resolveu o problema dessa lib, pode me ajudar em arrumar o npc também? data/npc/scripts/kame.lua:11: attempt to call global 'doSendDialogNpc' (a nil value) stack traceback: [C]: in function 'doSendDialogNpc' data/npc/scripts/kame.lua:11: in function 'callback' data/npc/lib/npcsystem/npchandler.lua:340: in function 'greet' data/npc/lib/npcsystem/npchandler.lua:519: 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:136: in function 'processNodeMessage' data/npc/lib/npcsystem/keywordhandler.lua:104: in function 'processMessage' data/npc/lib/npcsystem/npchandler.lua:408: in function 'onCreatureSay' data/npc/scripts/kame.lua:8: in function <data/npc/scripts/kame.lua:8> Está sendo retornado esse erro, estou usando o npc padrão usado no seu post, somente troquei o getNpcId() por getNpcCid() Link to comment https://xtibia.com/forum/topic/252513-sistema-de-dialogo-para-tfs-13/#findComment-1763416 Share on other sites More sharing options...
0 narutomaniacos 14 Posted November 2, 2020 Author Report Share Posted November 2, 2020 43 minutos atrás, Gengo disse: Você precisa adaptar conforme suas necessidades, segue ai, se não funcionar, só lamento, como disse, vc precisa adaptar conforme suas tfs 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 greetCallback(player) player:doSendDialogNpc(Npc():getId(), "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 end function onReleaseFocus(player) player:doSendDialogNpcClose() end npcHandler:setCallback(CALLBACK_GREET, greetCallback) npcHandler:setCallback(CALLBACK_ONRELEASEFOCUS, onReleaseFocus) npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Certo, desculpe pelo incomodo e obrigado. Não funcionou de cara mas você me deu a luz necessária,pra quem ainda estiver com problema é só deixar a função assim: function greetCallback(cid) local player = Player(cid) player:doSendDialogNpc(Npc():getId(), "Olá jovem, vejo que você conseguiu chegar até aqui!\nClique em Recompensa e fique feliz pela conquista!", "Fechar&Recompensa") return true end Link to comment https://xtibia.com/forum/topic/252513-sistema-de-dialogo-para-tfs-13/#findComment-1763419 Share on other sites More sharing options...
0 raylanderwise 0 Posted December 21, 2022 Report Share Posted December 21, 2022 (edited) TFS 1.3 alguém sabe me dizer por isso esta acontecendo? gengo.lua Edited December 21, 2022 by raylanderwise Link to comment https://xtibia.com/forum/topic/252513-sistema-de-dialogo-para-tfs-13/#findComment-1770685 Share on other sites More sharing options...
0 raylanderwise 0 Posted December 29, 2022 Report Share Posted December 29, 2022 (edited) Edited December 29, 2022 by raylanderwise Link to comment https://xtibia.com/forum/topic/252513-sistema-de-dialogo-para-tfs-13/#findComment-1771102 Share on other sites More sharing options...
Question
narutomaniacos 14
Estou tentando implementar esse sistema:
Estou recebendo o erro de nil value na função doSendPlayerExtendedOpcode. Já tentei usar Player.sendExtendedOpcode porém é retornado o seguinte erro:
alguma sugestão de como resolver?
Edited by narutomaniacosLink to comment
https://xtibia.com/forum/topic/252513-sistema-de-dialogo-para-tfs-13/Share on other sites
10 answers to this question
Recommended Posts