Ir para conteúdo
  • Cadastre-se

(Resolvido)[Action] Reset system por Action


Ir para solução Resolvido por Shiuns,

Posts Recomendados

Olá galera do TibiaKing!! Gostaria de pedir uma ajuda a vocês craques dos scripts.. estou tentando colocar meu sistema de reset para ser feito quando o player clica (da use) na placa(ou qualquer objeto).. isso apenas em alguns resets, o restante já está certo para ser feito por talkaction. Porém estou tendo alguns problemas, algumas vezes ele da a mensagem no jogo dizendo que a vocação está errada sendo que está certa, ou não aparece nada no jogo e da erro no TFS. Vou deixar o código e o erro.

 

OBS: TFS 0.4 e quando consegui fazer com que não desse erro no TFS, ele dizia que precisava da vocação para resetar, sendo que o char já estava na vocação certa. Enfim é isto, quem puder ajudar REP+ e humildade no teto!!

 

Código>

Citar

function onUse(cid, fromPosition, itemEx, toPosition)
local tabble = {
{reqVoc= 7, needLevel=330000},
}
local config = {{pid = getPlayerGUID(cid) , {newlv = 90000,life = 3599865,mana = 3599715}}}
if getPlayerLevel(cid) < 330000 and tabble.needLevel
then
doPlayerPopupFYI(cid, "Voce precisa ser level "..needLevel.." para resetar.")
return true
elseif tabble.reqVoc >= getPlayerVocation(cid) or 8
then
doPlayerPopupFYI(cid, "Voce já é vocaçao.")
return true
elseif tabble.reqVoc <= 7 and getPlayerVocation(cid)
then
doPlayerPopupFYI(cid, "Voce precisa ser vocaçao para resetar.")
return true
end
if tabble.reqVoc == getPlayerVocation(cid) then setPlayerStorageValue(cid, 887978, 1)
end
local newvoc = tabble.reqVoc ~= getPlayerVocation(cid) and (tabble.reqVoc+1)
setPlayerStorageValue(cid, 887979, newvoc)
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
doRemoveCreature(cid)
db.executeQuery("UPDATE `players` SET `level` = "..config.newlv..", `experience` = "..getExperienceForLevel(config.newlv)..",`manamax` = "..config.mana..",`health` = "..config.life..", `healthmax` = "..config.life..",`mana` = "..config.mana.." WHERE `id` = "..config.pid)
return true
end

 

Mensagem de erro no TFS> 

[Error - Action Interface]
[14:3:05.587] data/actions/scripts/resets/falling.lua:onUse
[14:3:05.588] Description:
[14:3:05.589] data/actions/scripts/resets/falling.lua:10: attempt to compare number with nil
[14:3:05.590] stack traceback:
[14:3:05.591]   data/actions/scripts/resets/falling.lua:10: in function <data/actions/scripts/resets/falling.lua:1>

 

 

Link para o post
Compartilhar em outros sites
Spoiler

function onUse(cid, fromPosition, itemEx, toPosition)
local tabble = {
{reqVoc= 7, needLevel=330000},
}
local config = {{pid = getPlayerGUID(cid) , {newlv = 90000,life = 3599865,mana = 3599715}}}
if getPlayerLevel(cid) < 330000 and tabble.needLevel
then
doPlayerPopupFYI(cid, "Voce precisa ser level "..needLevel.." para resetar.")
return true
elseif tabble.reqVoc >= getPlayerVocation(cid) >= 8 then
doPlayerPopupFYI(cid, "Voce já é vocaçao.")
return true
elseif tabble.reqVoc <= 7 and getPlayerVocation(cid)
then
doPlayerPopupFYI(cid, "Voce precisa ser vocaçao para resetar.")
return true
end
if tabble.reqVoc == getPlayerVocation(cid) then setPlayerStorageValue(cid, 887978, 1)
end
local newvoc = tabble.reqVoc ~= getPlayerVocation(cid) and (tabble.reqVoc+1)
setPlayerStorageValue(cid, 887979, newvoc)
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
doRemoveCreature(cid)
db.executeQuery("UPDATE `players` SET `level` = "..config.newlv..", `experience` = "..getExperienceForLevel(config.newlv)..",`manamax` = "..config.mana..",`health` = "..config.life..", `healthmax` = "..config.life..",`mana` = "..config.mana.." WHERE `id` = "..config.pid)
return true
end

 

Link para o post
Compartilhar em outros sites
  • Solução

Falta estudar tabelas...

 

local tabble = {
   {reqVoc= 7, needLevel=330000},
}

print(tabble.reqVoc) -- retorna nil

---------------------------
local tabble = {
   {reqVoc= 7, needLevel=330000},
}

print(tabble[1].reqVoc) -- retorna 7

----------------------------

o certo é usar:

local tabble = {
   reqVoc= 7, needLevel= 330000,
}

print(tabble.reqVoc)

 

 

 

 

o código:

 

function onUse(cid, fromPosition, itemEx, toPosition)
   local tabble = {
      reqVoc = 7,
      needLevel = 330000
   }
   local config = {
      pid = getPlayerGUID(cid),
      newlv = 90000,
      life = 3599865,
      mana = 3599715
   }
   if getPlayerLevel(cid) < 330000 and tabble.needLevel then
      doPlayerPopupFYI(cid, "Voce precisa ser level " .. needLevel .. " para resetar.")
      return true
   elseif tabble.reqVoc >= getPlayerVocation(cid) or 8 then
      doPlayerPopupFYI(cid, "Voce já é vocaçao.")
      return true
   elseif tabble.reqVoc <= 7 and getPlayerVocation(cid) then
      doPlayerPopupFYI(cid, "Voce precisa ser vocaçao para resetar.")
      return true
   end
   if tabble.reqVoc == getPlayerVocation(cid) then
      setPlayerStorageValue(cid, 887978, 1)
   end
   local newvoc = tabble.reqVoc ~= getPlayerVocation(cid) and (tabble.reqVoc+1)
   setPlayerStorageValue(cid, 887979, newvoc)
   doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
   doRemoveCreature(cid)
   db.executeQuery("UPDATE `players` SET `level` = "..config.newlv..", `experience` = "..getExperienceForLevel(config.newlv)..",`manamax` = "..config.mana..",`health` = "..config.life..", `healthmax` = "..config.life..",`mana` = "..config.mana.." WHERE `id` = "..config.pid)
   return true
end

 

Link para o post
Compartilhar em outros sites

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo