Ir para conteúdo

Posts Recomendados

  Em 31/08/2020 em 16:16, 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())
Expand  

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

  Em 29/08/2020 em 18: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

 

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

 

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

 

 

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

 

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

 

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:

AivYsrD.png

 

Arquivos para download e o scan:

 

Expand  

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

  Em 01/09/2020 em 21:43, 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>

Expand  

Adicione o seguinte trecho na lib do seu servidor, pode ser no mesmo arquivo que você colocou o table.serialize

  Mostrar conteúdo oculto

 

Link para o comentário
https://xtibia.com/forum/topic/252290-otclient-sistema-de-dialogo-otpokemon/page/2/#findComment-1762443
Compartilhar em outros sites

  Em 01/09/2020 em 22:30, 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

 

Expand  

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

  Em 01/09/2020 em 23: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

 

Expand  

nao tenho table.serialize tenho so o 012-table e o mesmo arquivo ou tenho que cria um table.serialize

  Em 01/09/2020 em 22:30, 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

 

Expand  

[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

  Em 01/09/2020 em 23: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>

Expand  

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

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...