BlazerX 51 Postado Agosto 31, 2020 Share Postado Agosto 31, 2020 2 minutos atrás, anderson127 disse: e aquele npc ali em cima local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} function doBuyPokemonWithCasinoCoins(cid, poke) npcHandler:onSellpokemon(cid) 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 onThink() npcHandler:onThink() end function getPlayerAllTowerItens(cid) if getPlayerItemCount(cid, 12163) >= 1000 and getPlayerItemCount(cid, 12161) >= 1000 and getPlayerItemCount(cid, 19500) >= 1500 and getPlayerItemCount(cid, 19501) >= 2000 and getPlayerItemCount(cid, 19540) >= 200 and getPlayerItemCount(cid, 15092) >= 100 and getPlayerItemCount(cid, 15098) >= 100 and getPlayerItemCount(cid, 15094) >= 100 and getPlayerItemCount(cid, 19536) >= 50 then return true end return false end function doRemoveItensTower(cid) doPlayerRemoveItem(cid, 12163, 1000) doPlayerRemoveItem(cid, 12161, 1000) doPlayerRemoveItem(cid, 19500, 1500) doPlayerRemoveItem(cid, 19501, 2000) doPlayerRemoveItem(cid, 19540, 200) doPlayerRemoveItem(cid, 15092, 100) doPlayerRemoveItem(cid, 15098, 100) doPlayerRemoveItem(cid, 15094, 100) doPlayerRemoveItem(cid, 19536, 50) return true end function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end if (msgcontains(msg, 'Embedded Tower') or msgcontains(msg, 'embedded tower')) then if getPlayerStorageValue(cid, 509001) >= 1 then selfSay("Não preciso mais de sua ajuda, você agora pode explorar a Embedded Tower!") return true end if getPlayerStorageValue(cid, 659875) == -1 then selfSay("Antes de tudo preciso checar se eis forte o suficiente para poder entrar lá, você poderia trazer-me {50x Giant Ruby}, {100x Sharpe Leave}, {100x Pawn}, {100x Crimson Feather}, {200x Linearly Guided Hypnosis}, {2000x enchanted gem}, {2000x Rubber Ball}, {1500x Earth Ball}, {1000x Seed}, {1000x water gem}?", cid) talkState[cid] = 1 else selfSay("Você já fez seus pedidos?", cid) talkState[cid] = 2 end elseif (msgcontains(msg, 'yes') or msgcontains(msg, 'sim')) and talkState[cid] == 1 and getPlayerStorageValue(cid, 659875) == -1 then if getPlayerAllTowerItens(cid) then doRemoveItensTower(cid) selfSay("É dito uma lenda à qual a antiga civilização pokémon adorava 3 grandes deuses que trariam prosperidade, hoje são representado-os pelas {Pedra Sagrada da Floresta}, {Pedra Sagrada da Terra} e a {Pedra Sagrada do Mar}, volte quando feito seus {pedidos}!", cid) setPlayerStorageValue(cid, 659875, 1) else selfSay("Lembre-se, os itens são {50x Giant Ruby}, {100x Sharpe Leave}, {100x Pawn}, {100x Crimson Feather}, {200x Linearly Guided Hypnosis}, {2000x enchanted gem}, {2000x Rubber Ball}, {1500x Earth Ball}, {1000x Seed}, {1000x water gem}...", cid) talkState[cid] = 0 return true end elseif msgcontains(msg, 'pedidos') and getPlayerStorageValue(cid, 659875) == 1 then selfSay("Você já fez seus pedidos?", cid) talkState[cid] = 2 elseif (msgcontains(msg, 'yes') or msgcontains(msg, 'sim')) and talkState[cid] == 2 and getPlayerStorageValue(cid, 659875) == 1 then if getPlayerStorageValue(cid, 60900) >= 1 and getPlayerStorageValue(cid, 60901) >= 1 and getPlayerStorageValue(cid, 60902) >= 1 then setPlayerStorageValue(cid, 509001, 1) setPlayerStorageValue(cid, 78501, 1) selfSay("Pronto agora você pode acessar a tower!", cid) talkState[talkUser] = 0 else selfSay("Você não fez seus pedidos às 3x pedras sagradas;", cid) talkState[talkUser] = 0 end elseif (msgcontains(msg, 'no') or msgcontains(msg, 'nao')) then selfSay("So good bye...", cid) talkState[cid] = 0 return false end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Manda pm para mim que eu vou ajudar você. Link para o comentário https://xtibia.com/forum/topic/252290-otclient-sistema-de-dialogo-otpokemon/page/2/#findComment-1762423 Compartilhar em outros sites More sharing options...
Ninlin 0 Postado Agosto 31, 2020 Share Postado Agosto 31, 2020 muito bom Link para o comentário https://xtibia.com/forum/topic/252290-otclient-sistema-de-dialogo-otpokemon/page/2/#findComment-1762430 Compartilhar em outros sites More sharing options...
raulcdj 3 Postado Setembro 1, 2020 Share Postado Setembro 1, 2020 Em 29/08/2020 em 15:44, Gengo disse: [OTClient] Sistema de Dialogo Otpokemon Venho através desse tópico contribuir para a comunidade, um simples modulo de dialogo no estilo do Otpokemon, não é um sistema de dialogo avançado é algo simples que deixa seu servidor intuitivo. 1) Faça o download do modulo no qual se encontra no final do tópico e abrindo a pasta do seu client, extraia e coloque o modulo na pasta modules. 2) O módulo utiliza uma função chamada switch que não é comum ter no otclient, porem podemos colocar sem muito esforço, na pasta do otclient abra o arquivo util.lua que se encontra em modules/corelib/ e no final do arquivo coloque o seguinte código: Mostrar conteúdo oculto function switch(indice) return function(codetable) local case = codetable[indice] or codetable.default if ( case ) then if ( type(case) == "function" ) then return case(indice) else error("action "..tostring(indice).." not a function") end end end end Feito o passo 1 e 2, vamos para a parte do servidor. 1) Crie um arquivo na pasta data/lib/ podendo ter o nome de npcdialog_lib.lua e coloque o seguinte 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 doSendPlayerExtendedOpcode(cid, OpcodeDialog, table.serialize({ action = Actions.open, data = { npcId = npc, message = msg, options = opc } })) end function doSendDialogNpcClose(cid) doSendPlayerExtendedOpcode(cid, OpcodeDialog, table.serialize({ action = Actions.closed })) end 2) O arquivo que acabamos de criar utiliza uma função chamada table.serialize que não é comum ter nos servidores, para que funcione sem erros vamos adicionar, abra o arquivo 012-table.lua que fica na pasta do seu servidor em data/lib/ ou você pode criar o arquivo e adicionar o seguinte código: Mostrar conteúdo oculto 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 Feito todo esse procedimento, estarei disponibilizando um npc para que vocês possam ter uma noção de como utilizar esse sistema de dialogo. 1) Crie um arquivo na pasta do servidor em data/npc/ chamado Gengo.xml e adicione o seguinte código: Mostrar conteúdo oculto <?xml version="1.0" encoding="UTF-8"?> <npc name="Gengo" script="gengo.lua"> <health now="150" max="150"/> <look type="1413" head="114" body="119" legs="114" feet="114" corpse="2212"/> </npc> 2) Crie um arquivo na pasta do servidor em data/npc/lib/ com o nome gengo.lua e adicione o seguinte código: Mostrar conteúdo oculto 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) doSendDialogNpc(cid, getNpcId(), "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(cid, getNpcId(), 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()) O npc é algo simples, porem serve para que você possa ter uma noção de como utilizar as funções do npc. Demostrativo dentro do game: Arquivos para download e o scan: Mostrar conteúdo oculto Module: https://mega.nz/file/hWp1lbIT#4vqL-YN-ZlLQ8N2XeojIw-cD5VWDHJCAYp6SfRHn84o Scan: https://www.virustotal.com/gui/file/f7f5eff65c9d589faedffc0aa728b95c848669108026cb208ec872d5ad25b5b8/detection meu servidor e pda e da esse erro quando digo hi [01/09/2020 18:42:24] [Error - Npc interface] [01/09/2020 18:42:24] data/npc/scripts/gengo.lua:onCreatureSay [01/09/2020 18:42:24] Description: [01/09/2020 18:42:24] data/lib/012-table.lua:16: attempt to call field 'find' (a nil value) [01/09/2020 18:42:24] stack traceback: [01/09/2020 18:42:24] data/lib/012-table.lua:16: in function 'serialize' [01/09/2020 18:42:24] data/lib/npcdialog_lib.lua:11: in function 'doSendDialogNpc' [01/09/2020 18:42:24] data/npc/scripts/gengo.lua:11: in function 'callback' [01/09/2020 18:42:24] data/npc/lib/npcsystem/npchandler.lua:339: in function 'greet' [01/09/2020 18:42:24] data/npc/lib/npcsystem/npchandler.lua:512: in function 'onGreet' [01/09/2020 18:42:24] data/npc/lib/npcsystem/modules.lua:222: in function 'callback' [01/09/2020 18:42:24] data/npc/lib/npcsystem/keywordhandler.lua:40: in function 'processMessage' [01/09/2020 18:42:24] data/npc/lib/npcsystem/keywordhandler.lua:168: in function 'processNodeMessage' [01/09/2020 18:42:24] data/npc/lib/npcsystem/keywordhandler.lua:122: in function 'processMessage' [01/09/2020 18:42:24] data/npc/lib/npcsystem/npchandler.lua:388: in function 'onCreatureSay' [01/09/2020 18:42:24] data/npc/scripts/gengo.lua:8: in function <data/npc/scripts/gengo.lua:8> Link para o comentário https://xtibia.com/forum/topic/252290-otclient-sistema-de-dialogo-otpokemon/page/2/#findComment-1762440 Compartilhar em outros sites More sharing options...
Gengo 202 Postado Setembro 1, 2020 Autor Share Postado Setembro 1, 2020 45 minutos atrás, raulcdj disse: meu servidor e pda e da esse erro quando digo hi [01/09/2020 18:42:24] [Error - Npc interface] [01/09/2020 18:42:24] data/npc/scripts/gengo.lua:onCreatureSay [01/09/2020 18:42:24] Description: [01/09/2020 18:42:24] data/lib/012-table.lua:16: attempt to call field 'find' (a nil value) [01/09/2020 18:42:24] stack traceback: [01/09/2020 18:42:24] data/lib/012-table.lua:16: in function 'serialize' [01/09/2020 18:42:24] data/lib/npcdialog_lib.lua:11: in function 'doSendDialogNpc' [01/09/2020 18:42:24] data/npc/scripts/gengo.lua:11: in function 'callback' [01/09/2020 18:42:24] data/npc/lib/npcsystem/npchandler.lua:339: in function 'greet' [01/09/2020 18:42:24] data/npc/lib/npcsystem/npchandler.lua:512: in function 'onGreet' [01/09/2020 18:42:24] data/npc/lib/npcsystem/modules.lua:222: in function 'callback' [01/09/2020 18:42:24] data/npc/lib/npcsystem/keywordhandler.lua:40: in function 'processMessage' [01/09/2020 18:42:24] data/npc/lib/npcsystem/keywordhandler.lua:168: in function 'processNodeMessage' [01/09/2020 18:42:24] data/npc/lib/npcsystem/keywordhandler.lua:122: in function 'processMessage' [01/09/2020 18:42:24] data/npc/lib/npcsystem/npchandler.lua:388: in function 'onCreatureSay' [01/09/2020 18:42:24] data/npc/scripts/gengo.lua:8: in function <data/npc/scripts/gengo.lua:8> Adicione o seguinte trecho na lib do seu servidor, pode ser no mesmo arquivo que você colocou o table.serialize Spoiler table.find = function (table, value) for i, v in pairs(table) do if(v == value) then return i end end return nil end Link para o comentário https://xtibia.com/forum/topic/252290-otclient-sistema-de-dialogo-otpokemon/page/2/#findComment-1762443 Compartilhar em outros sites More sharing options...
raulcdj 3 Postado Setembro 1, 2020 Share Postado Setembro 1, 2020 33 minutos atrás, Gengo disse: Adicione o seguinte trecho na lib do seu servidor, pode ser no mesmo arquivo que você colocou o table.serialize Ocultar conteúdo table.find = function (table, value) 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 table.find = function (table, value) for i, v in pairs(table) do if(v == value) then return i end end return nil end Agora, raulcdj disse: 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 table.find = function (table, value) for i, v in pairs(table) do if(v == value) then return i end end return nil end nao tenho table.serialize tenho so o 012-table e o mesmo arquivo ou tenho que cria um table.serialize 55 minutos atrás, Gengo disse: Adicione o seguinte trecho na lib do seu servidor, pode ser no mesmo arquivo que você colocou o table.serialize Mostrar conteúdo oculto table.find = function (table, value) for i, v in pairs(table) do if(v == value) then return i end end return nil end [01/09/2020 20:23:23] [Error - Npc interface] [01/09/2020 20:23:23] data/npc/scripts/gengo.lua:onCreatureSay [01/09/2020 20:23:23] Description: [01/09/2020 20:23:23] data/lib/npcdialog_lib.lua:11: attempt to call global 'doSendPlayerExtendedOpcode' (a nil value) [01/09/2020 20:23:23] stack traceback: [01/09/2020 20:23:23] data/lib/npcdialog_lib.lua:11: in function 'doSendDialogNpc' [01/09/2020 20:23:23] data/npc/scripts/gengo.lua:11: in function 'callback' [01/09/2020 20:23:23] data/npc/lib/npcsystem/npchandler.lua:339: in function 'greet' [01/09/2020 20:23:23] data/npc/lib/npcsystem/npchandler.lua:512: in function 'onGreet' [01/09/2020 20:23:23] data/npc/lib/npcsystem/modules.lua:222: in function 'callback' [01/09/2020 20:23:23] data/npc/lib/npcsystem/keywordhandler.lua:40: in function 'processMessage' [01/09/2020 20:23:23] data/npc/lib/npcsystem/keywordhandler.lua:168: in function 'processNodeMessage' [01/09/2020 20:23:23] data/npc/lib/npcsystem/keywordhandler.lua:122: in function 'processMessage' [01/09/2020 20:23:23] data/npc/lib/npcsystem/npchandler.lua:388: in function 'onCreatureSay' [01/09/2020 20:23:23] data/npc/scripts/gengo.lua:8: in function <data/npc/scripts/gengo.lua:8> Link para o comentário https://xtibia.com/forum/topic/252290-otclient-sistema-de-dialogo-otpokemon/page/2/#findComment-1762444 Compartilhar em outros sites More sharing options...
Gengo 202 Postado Setembro 2, 2020 Autor Share Postado Setembro 2, 2020 Em 01/09/2020 em 20:03, raulcdj disse: 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 table.find = function (table, value) for i, v in pairs(table) do if(v == value) then return i end end return nil end nao tenho table.serialize tenho so o 012-table e o mesmo arquivo ou tenho que cria um table.serialize [01/09/2020 20:23:23] [Error - Npc interface] [01/09/2020 20:23:23] data/npc/scripts/gengo.lua:onCreatureSay [01/09/2020 20:23:23] Description: [01/09/2020 20:23:23] data/lib/npcdialog_lib.lua:11: attempt to call global 'doSendPlayerExtendedOpcode' (a nil value) [01/09/2020 20:23:23] stack traceback: [01/09/2020 20:23:23] data/lib/npcdialog_lib.lua:11: in function 'doSendDialogNpc' [01/09/2020 20:23:23] data/npc/scripts/gengo.lua:11: in function 'callback' [01/09/2020 20:23:23] data/npc/lib/npcsystem/npchandler.lua:339: in function 'greet' [01/09/2020 20:23:23] data/npc/lib/npcsystem/npchandler.lua:512: in function 'onGreet' [01/09/2020 20:23:23] data/npc/lib/npcsystem/modules.lua:222: in function 'callback' [01/09/2020 20:23:23] data/npc/lib/npcsystem/keywordhandler.lua:40: in function 'processMessage' [01/09/2020 20:23:23] data/npc/lib/npcsystem/keywordhandler.lua:168: in function 'processNodeMessage' [01/09/2020 20:23:23] data/npc/lib/npcsystem/keywordhandler.lua:122: in function 'processMessage' [01/09/2020 20:23:23] data/npc/lib/npcsystem/npchandler.lua:388: in function 'onCreatureSay' [01/09/2020 20:23:23] data/npc/scripts/gengo.lua:8: in function <data/npc/scripts/gengo.lua:8> Certo, você nao tem, então siga o tutorial e adicione, e reveja com cuidado, verifique no seu servidor você não tem a função doSendPlayerExtendedOpcode, recomendo instalar, esse topico não ensino instalar opcodes. Link para o comentário https://xtibia.com/forum/topic/252290-otclient-sistema-de-dialogo-otpokemon/page/2/#findComment-1762476 Compartilhar em outros sites More sharing options...
Posts Recomendados