Ir para conteúdo

[Encerrado] [Encerrado] [ERRO] ACTION - Change Vocation


Posts Recomendados

Olá. Eu encontrei na internet um script que troca a vocação por action, ele tem uma linha na qual deveria executar um comando na database para resetar os skills, mas está dando um erro e não está zerando os skills. Alguém saberia como consertar isso? Eu testei em SQL.

ERRO:

  Mostrar conteúdo oculto



SCRIPT:

  Mostrar conteúdo oculto

Link para o comentário
https://xtibia.com/forum/topic/246233-encerrado-encerrado-erro-action-change-vocation/
Compartilhar em outros sites

  • Administrador

Qual é a distro?
Btw, tenta trocar todos os db.executeQuery no script para db.query e vê se resolve.

function onUse(cid, item, frompos, item2, topos)
          level = getPlayerLevel(cid)-8
          pid = getPlayerGUID(cid)
 
          magehealth = level*5 -- Quantidade de vida que o Sorcerer e Druid ganha a cada level(mude apenas os numeros)
          magemana = level*30 -- Quantidade de mana que o Sorcerer e Druid ganha a cada level(mude apenas os numeros)
 
          paladinhealth = level*10 -- Quantidade de vida que o Paladin ganha a cada level(mude apenas os numeros)
          paladinmana = level*15 -- Quantidade de mana que o Paladin ganha a cada level(mude apenas os numeros)
 
          knighthealth = level*15 -- Quantidade de vida que o Knight ganha a cada level(mude apenas os numeros)
          knightmana = level*5 -- Quantidade de mana que o Knight ganha a cada level(mude apenas os numeros)
 
          if item.uid == 37001 then
                    doSendMagicEffect(topos, 14)
                    doPlayerPopupFYI(cid, 'You changed your vocation to sorcerer.')
                    doPlayerSetVocation(cid, 1)
                    setCreatureMaxHealth(cid, magehealth)
                    setCreatureMaxMana(cid, magemana)
                    doRemoveCreature(cid)
                    db.query("UPDATE `player_skills` SET `value` = ".. 10 ..", count = ".. 0 .." WHERE `player_id` = ".. pid ..";")
                    db.query("UPDATE `players` SET `maglevel` = ".. 0 ..", `manaspent` = ".. 0 .." WHERE `id` = ".. pid ..";")
          end
 
          if item.uid == 37011 then
                    doPlayerSetVocation(cid, 2)
                    setCreatureMaxHealth(cid, magehealth)
                    setCreatureMaxMana(cid, magemana)
                    doSendMagicEffect(topos, 14)
                    doPlayerPopupFYI(cid, 'You changed your vocation to druid.')
                    doRemoveCreature(cid)
                    db.query("UPDATE `player_skills` SET `value` = ".. 10 ..", count = ".. 0 .." WHERE `player_id` = ".. pid ..";")
                    db.query("UPDATE `players` SET `maglevel` = ".. 0 ..", `manaspent` = ".. 0 .." WHERE `id` = ".. pid ..";")
          end
 
          if item.uid == 37012 then
                    doPlayerSetVocation(cid, 3)
                    setCreatureMaxHealth(cid, paladinhealth)
                    setCreatureMaxMana(cid, paladinmana)
                    doSendMagicEffect(topos, 14)
                    doPlayerPopupFYI(cid, 'You changed your vocation to paladin.')
                    doRemoveCreature(cid)
                    db.query("UPDATE `player_skills` SET `value` = ".. 10 ..", count = ".. 0 .." WHERE `player_id` = ".. pid ..";")
                    db.query("UPDATE `players` SET `maglevel` = ".. 0 ..", `manaspent` = ".. 0 .." WHERE `id` = ".. pid ..";")
          end
 
          if item.uid == 37013 then
                    doPlayerSetVocation(cid, 4)
                    setCreatureMaxHealth(cid, knighthealth)
                    setCreatureMaxMana(cid, knightmana)
                    doSendMagicEffect(topos, 14)
                    doPlayerPopupFYI(cid, 'You changed your vocation to knight.')
                    doRemoveCreature(cid)
                    db.query("UPDATE `player_skills` SET `value` = ".. 10 ..", count = ".. 0 .." WHERE `player_id` = ".. pid ..";")
                    db.query("UPDATE `players` SET `maglevel` = ".. 0 ..", `manaspent` = ".. 0 .." WHERE `id` = ".. pid ..";")
          end
end

 

  Em 17/09/2017 em 03:22, PoRaI disse:

Qual é a distro?
Btw, tenta trocar todos os db.executeQuery no script para db.query e vê se resolve.

Expand  


Não foi também. A distro é TFS 0.3.6

data/actions/scripts/changevoc.lua:43: attempt to call field 'query' (a nil value)

  Em 17/09/2017 em 07:16, Dandjes disse:


Não foi também. A distro é TFS 0.3.6

data/actions/scripts/changevoc.lua:43: attempt to call field 'query' (a nil value)

Expand  
function onUse(cid, item, frompos, item2, topos)
          level = getPlayerLevel(cid)-8
          pid = getPlayerGUID(cid)
 
          magehealth = level*5 -- Quantidade de vida que o Sorcerer e Druid ganha a cada level(mude apenas os numeros)
          magemana = level*30 -- Quantidade de mana que o Sorcerer e Druid ganha a cada level(mude apenas os numeros)
 
          paladinhealth = level*10 -- Quantidade de vida que o Paladin ganha a cada level(mude apenas os numeros)
          paladinmana = level*15 -- Quantidade de mana que o Paladin ganha a cada level(mude apenas os numeros)
 
          knighthealth = level*15 -- Quantidade de vida que o Knight ganha a cada level(mude apenas os numeros)
          knightmana = level*5 -- Quantidade de mana que o Knight ganha a cada level(mude apenas os numeros)
 
          if item.uid == 37001 then
                    doSendMagicEffect(topos, 14)
                    doPlayerPopupFYI(cid, 'You changed your vocation to sorcerer.')
                    doPlayerSetVocation(cid, 1)
                    setCreatureMaxHealth(cid, magehealth)
                    setCreatureMaxMana(cid, magemana)
                    doRemoveCreature(cid)                    
          end
 
          if item.uid == 37011 then
                    doPlayerSetVocation(cid, 2)
                    setCreatureMaxHealth(cid, magehealth)
                    setCreatureMaxMana(cid, magemana)
                    doSendMagicEffect(topos, 14)
                    doPlayerPopupFYI(cid, 'You changed your vocation to druid.')
                    doRemoveCreature(cid)                  
          end
 
          if item.uid == 37012 then
                    doPlayerSetVocation(cid, 3)
                    setCreatureMaxHealth(cid, paladinhealth)
                    setCreatureMaxMana(cid, paladinmana)
                    doSendMagicEffect(topos, 14)
                    doPlayerPopupFYI(cid, 'You changed your vocation to paladin.')
                    doRemoveCreature(cid)                  
          end
 
          if item.uid == 37013 then
                    doPlayerSetVocation(cid, 4)
                    setCreatureMaxHealth(cid, knighthealth)
                    setCreatureMaxMana(cid, knightmana)
                    doSendMagicEffect(topos, 14)
                    doPlayerPopupFYI(cid, 'You changed your vocation to knight.')
                    doRemoveCreature(cid)          
          end
end

 

  Em 17/09/2017 em 18:02, Crypter disse:
function onUse(cid, item, frompos, item2, topos)
          level = getPlayerLevel(cid)-8
          pid = getPlayerGUID(cid)
 
          magehealth = level*5 -- Quantidade de vida que o Sorcerer e Druid ganha a cada level(mude apenas os numeros)
          magemana = level*30 -- Quantidade de mana que o Sorcerer e Druid ganha a cada level(mude apenas os numeros)
 
          paladinhealth = level*10 -- Quantidade de vida que o Paladin ganha a cada level(mude apenas os numeros)
          paladinmana = level*15 -- Quantidade de mana que o Paladin ganha a cada level(mude apenas os numeros)
 
          knighthealth = level*15 -- Quantidade de vida que o Knight ganha a cada level(mude apenas os numeros)
          knightmana = level*5 -- Quantidade de mana que o Knight ganha a cada level(mude apenas os numeros)
 
          if item.uid == 37001 then
                    doSendMagicEffect(topos, 14)
                    doPlayerPopupFYI(cid, 'You changed your vocation to sorcerer.')
                    doPlayerSetVocation(cid, 1)
                    setCreatureMaxHealth(cid, magehealth)
                    setCreatureMaxMana(cid, magemana)
                    doRemoveCreature(cid)                    
          end
 
          if item.uid == 37011 then
                    doPlayerSetVocation(cid, 2)
                    setCreatureMaxHealth(cid, magehealth)
                    setCreatureMaxMana(cid, magemana)
                    doSendMagicEffect(topos, 14)
                    doPlayerPopupFYI(cid, 'You changed your vocation to druid.')
                    doRemoveCreature(cid)                  
          end
 
          if item.uid == 37012 then
                    doPlayerSetVocation(cid, 3)
                    setCreatureMaxHealth(cid, paladinhealth)
                    setCreatureMaxMana(cid, paladinmana)
                    doSendMagicEffect(topos, 14)
                    doPlayerPopupFYI(cid, 'You changed your vocation to paladin.')
                    doRemoveCreature(cid)                  
          end
 
          if item.uid == 37013 then
                    doPlayerSetVocation(cid, 4)
                    setCreatureMaxHealth(cid, knighthealth)
                    setCreatureMaxMana(cid, knightmana)
                    doSendMagicEffect(topos, 14)
                    doPlayerPopupFYI(cid, 'You changed your vocation to knight.')
                    doRemoveCreature(cid)          
          end
end

 

Expand  


Desse jeito vai dar na mesma, não vai resetar o skill. Imagina um knight com ml 95??

  • Administrador
local vocation_table = {
   [37001] = 1,
   [37011] = 2,
   [37012] = 3,
   [37013] = 4,
}

function onUse(cid, item, frompos, item2, topos)
   local voc = vocation_table[item.uid]
   if voc then
      if getPlayerVocation(cid) == voc then
         return doPlayerSendCancel(cid, "Você não pode trocar para a mesma vocação.")
      elseif getPlayerVocation(cid) == 0 then
         return doPlayerSendCancel(cid, "Você precisa ter uma vocação para ser outra.")
      elseif getCreatureCondition(cid, CONDITION_INFIGHT) then
         return doPlayerSendCancel(cid, "Você não pode trocar de vocação em combate.")
      end
      local pid = getPlayerGUID(cid)
      local level = math.max(1, getPlayerLevel(cid) - 8)

      local vocationInfo = getVocationInfo(voc)
      local hpLevel = vocationInfo.healthGain * level
      local manaLevel = vocationInfo.manaGain * level

      local baseInfo = getVocationInfo(0)
      local baseHp = baseInfo.healthGain * 8
      local baseMana = baseInfo.manaGain * 8

      doSendMagicEffect(topos, 14)

      setCreatureMaxHealth(cid, baseHp + hpLevel)
      setCreatureMaxMana(cid, baseMana + manaLevel)

      doPlayerSetVocation(cid, voc)
      doRemoveCreature(cid)

      local executeQuery = db.executeQuery or db.query
      executeQuery("UPDATE `player_skills` SET `value` = '10', count = '0' WHERE `player_id` = '".. pid .."';")
      executeQuery("UPDATE `players` SET `maglevel` = '0', `manaspent` = '0' WHERE `id` = '".. pid .."';")
   end
   return true
end


Eu refiz o seu script, não sei se vai ajudar no seu caso.

O que imagino que possa ser é: você ter criado uma variável chamada db e ter dado conflito com a tabela de funções db, sei lá.

E também, se possível, envia seu luascript.cpp pra eu dar uma olhada aí.

  Em 17/09/2017 em 21:49, Dandjes disse:


Desse jeito vai dar na mesma, não vai resetar o skill. Imagina um knight com ml 95??

Expand  

Você não disse se usa Mysql ou Sqlite, não mostrou nem ao menos o banco de dados, e quer um milagre

  Em 17/09/2017 em 23:13, Crypter disse:

Você não disse se usa Mysql ou Sqlite, não mostrou nem ao menos o banco de dados, e quer um milagre

Expand  


É sqlite, o que exatamente do banco de dados voce precisa ver? 

  Em 17/09/2017 em 22:40, PoRaI disse:
local vocation_table = {
   [37001] = 1,
   [37011] = 2,
   [37012] = 3,
   [37013] = 4,
}

function onUse(cid, item, frompos, item2, topos)
   local voc = vocation_table[item.uid]
   if voc then
      if getPlayerVocation(cid) == voc then
         return doPlayerSendCancel(cid, "Você não pode trocar para a mesma vocação.")
      elseif getPlayerVocation(cid) == 0 then
         return doPlayerSendCancel(cid, "Você precisa ter uma vocação para ser outra.")
      elseif getCreatureCondition(cid, CONDITION_INFIGHT) then
         return doPlayerSendCancel(cid, "Você não pode trocar de vocação em combate.")
      end
      local pid = getPlayerGUID(cid)
      local level = math.max(1, getPlayerLevel(cid) - 8)

      local vocationInfo = getVocationInfo(voc)
      local hpLevel = vocationInfo.healthGain * level
      local manaLevel = vocationInfo.manaGain * level

      local baseInfo = getVocationInfo(0)
      local baseHp = baseInfo.healthGain * 8
      local baseMana = baseInfo.manaGain * 8

      doSendMagicEffect(topos, 14)

      setCreatureMaxHealth(cid, baseHp + hpLevel)
      setCreatureMaxMana(cid, baseMana + manaLevel)

      doPlayerSetVocation(cid, voc)
      doRemoveCreature(cid)

      local executeQuery = db.executeQuery or db.query
      executeQuery("UPDATE `player_skills` SET `value` = '10', count = '0' WHERE `player_id` = '".. pid .."';")
      executeQuery("UPDATE `players` SET `maglevel` = '0', `manaspent` = '0' WHERE `id` = '".. pid .."';")
   end
   return true
end


Eu refiz o seu script, não sei se vai ajudar no seu caso.

O que imagino que possa ser é: você ter criado uma variável chamada db e ter dado conflito com a tabela de funções db, sei lá.

E também, se possível, envia seu luascript.cpp pra eu dar uma olhada aí.

Expand  

 Também não foi. Acho melhor deixar pra lá isso kkkkk
Acredito que não vá funcionar em sqlite.

function onUse(cid, item, frompos, item2, topos)
          level = getPlayerLevel(cid)-8
          pid = getPlayerGUID(cid)
 
          magehealth = level*5 -- Quantidade de vida que o Sorcerer e Druid ganha a cada level(mude apenas os numeros)
          magemana = level*30 -- Quantidade de mana que o Sorcerer e Druid ganha a cada level(mude apenas os numeros)
 
          paladinhealth = level*10 -- Quantidade de vida que o Paladin ganha a cada level(mude apenas os numeros)
          paladinmana = level*15 -- Quantidade de mana que o Paladin ganha a cada level(mude apenas os numeros)
 
          knighthealth = level*15 -- Quantidade de vida que o Knight ganha a cada level(mude apenas os numeros)
          knightmana = level*5 -- Quantidade de mana que o Knight ganha a cada level(mude apenas os numeros)
 
          if item.uid == 37001 then
                    doSendMagicEffect(topos, 14)
                    doPlayerPopupFYI(cid, 'You changed your vocation to sorcerer.')
                    doPlayerSetVocation(cid, 1)
                    setCreatureMaxHealth(cid, magehealth)
                    setCreatureMaxMana(cid, magemana)
                    doRemoveCreature(cid)                   
					
					db.executeQuery("UPDATE `players` SET `maglevel` = " .. 0 .. " WHERE `id` = " .. getPlayerGUID(cid) .. ";")
					
					db.executeQuery("UPDATE `player_skills` SET ` value` = " .. 0 .. " WHERE `player_id` = " .. getPlayerGUID(cid) .. ";")
          end
 
          if item.uid == 37011 then
                    doPlayerSetVocation(cid, 2)
                    setCreatureMaxHealth(cid, magehealth)
                    setCreatureMaxMana(cid, magemana)
                    doSendMagicEffect(topos, 14)
                    doPlayerPopupFYI(cid, 'You changed your vocation to druid.')
                    doRemoveCreature(cid)
                    db.executeQuery("UPDATE `players` SET `maglevel` = " .. 0 .. " WHERE `id` = " .. getPlayerGUID(cid) .. ";")
					
					db.executeQuery("UPDATE `player_skills` SET ` value` = " .. 0 .. " WHERE `player_id` = " .. getPlayerGUID(cid) .. ";")
          end
 
          if item.uid == 37012 then
                    doPlayerSetVocation(cid, 3)
                    setCreatureMaxHealth(cid, paladinhealth)
                    setCreatureMaxMana(cid, paladinmana)
                    doSendMagicEffect(topos, 14)
                    doPlayerPopupFYI(cid, 'You changed your vocation to paladin.')
                    doRemoveCreature(cid)
					db.executeQuery("UPDATE `players` SET `maglevel` = " .. 0 .. " WHERE `id` = " .. getPlayerGUID(cid) .. ";")
					
					db.executeQuery("UPDATE `player_skills` SET ` value` = " .. 0 .. " WHERE `player_id` = " .. getPlayerGUID(cid) .. ";")
          end
 
          if item.uid == 37013 then
                    doPlayerSetVocation(cid, 4)
                    setCreatureMaxHealth(cid, knighthealth)
                    setCreatureMaxMana(cid, knightmana)
                    doSendMagicEffect(topos, 14)
                    doPlayerPopupFYI(cid, 'You changed your vocation to knight.')
                    doRemoveCreature(cid)
                    db.executeQuery("UPDATE `players` SET `maglevel` = " .. 0 .. " WHERE `id` = " .. getPlayerGUID(cid) .. ";")
					
					db.executeQuery("UPDATE `player_skills` SET ` value` = " .. 0 .. " WHERE `player_id` = " .. getPlayerGUID(cid) .. ";")
          end
end

 

  Em 18/09/2017 em 02:01, Crypter disse:
function onUse(cid, item, frompos, item2, topos)
          level = getPlayerLevel(cid)-8
          pid = getPlayerGUID(cid)
 
          magehealth = level*5 -- Quantidade de vida que o Sorcerer e Druid ganha a cada level(mude apenas os numeros)
          magemana = level*30 -- Quantidade de mana que o Sorcerer e Druid ganha a cada level(mude apenas os numeros)
 
          paladinhealth = level*10 -- Quantidade de vida que o Paladin ganha a cada level(mude apenas os numeros)
          paladinmana = level*15 -- Quantidade de mana que o Paladin ganha a cada level(mude apenas os numeros)
 
          knighthealth = level*15 -- Quantidade de vida que o Knight ganha a cada level(mude apenas os numeros)
          knightmana = level*5 -- Quantidade de mana que o Knight ganha a cada level(mude apenas os numeros)
 
          if item.uid == 37001 then
                    doSendMagicEffect(topos, 14)
                    doPlayerPopupFYI(cid, 'You changed your vocation to sorcerer.')
                    doPlayerSetVocation(cid, 1)
                    setCreatureMaxHealth(cid, magehealth)
                    setCreatureMaxMana(cid, magemana)
                    doRemoveCreature(cid)                   
					
					db.executeQuery("UPDATE `players` SET `maglevel` = " .. 0 .. " WHERE `id` = " .. getPlayerGUID(cid) .. ";")
					
					db.executeQuery("UPDATE `player_skills` SET ` value` = " .. 0 .. " WHERE `player_id` = " .. getPlayerGUID(cid) .. ";")
          end
 
          if item.uid == 37011 then
                    doPlayerSetVocation(cid, 2)
                    setCreatureMaxHealth(cid, magehealth)
                    setCreatureMaxMana(cid, magemana)
                    doSendMagicEffect(topos, 14)
                    doPlayerPopupFYI(cid, 'You changed your vocation to druid.')
                    doRemoveCreature(cid)
                    db.executeQuery("UPDATE `players` SET `maglevel` = " .. 0 .. " WHERE `id` = " .. getPlayerGUID(cid) .. ";")
					
					db.executeQuery("UPDATE `player_skills` SET ` value` = " .. 0 .. " WHERE `player_id` = " .. getPlayerGUID(cid) .. ";")
          end
 
          if item.uid == 37012 then
                    doPlayerSetVocation(cid, 3)
                    setCreatureMaxHealth(cid, paladinhealth)
                    setCreatureMaxMana(cid, paladinmana)
                    doSendMagicEffect(topos, 14)
                    doPlayerPopupFYI(cid, 'You changed your vocation to paladin.')
                    doRemoveCreature(cid)
					db.executeQuery("UPDATE `players` SET `maglevel` = " .. 0 .. " WHERE `id` = " .. getPlayerGUID(cid) .. ";")
					
					db.executeQuery("UPDATE `player_skills` SET ` value` = " .. 0 .. " WHERE `player_id` = " .. getPlayerGUID(cid) .. ";")
          end
 
          if item.uid == 37013 then
                    doPlayerSetVocation(cid, 4)
                    setCreatureMaxHealth(cid, knighthealth)
                    setCreatureMaxMana(cid, knightmana)
                    doSendMagicEffect(topos, 14)
                    doPlayerPopupFYI(cid, 'You changed your vocation to knight.')
                    doRemoveCreature(cid)
                    db.executeQuery("UPDATE `players` SET `maglevel` = " .. 0 .. " WHERE `id` = " .. getPlayerGUID(cid) .. ";")
					
					db.executeQuery("UPDATE `player_skills` SET ` value` = " .. 0 .. " WHERE `player_id` = " .. getPlayerGUID(cid) .. ";")
          end
end

 

Expand  



  Mostrar conteúdo oculto



Acho que definitivamente não vai funcionar, pelo menos acredito eu que em sqlite não. Mas vou deixar um rep+ pra voces pelo esforço em tentar ajudar e quem sabe alguém com interesse no script que use MySql tente testar ou usar e um dia seja útil.

  • 2 months later...
  • Administrador
A questão neste tópico de suporte foi encerrada por falta de resposta. Este tópico está fechado e foi movido para Suporte - Tópicos Sem Resposta
A questão neste tópico de suporte foi encerrada por falta de resposta. Este tópico está fechado e foi movido para Suporte - Tópicos Sem Resposta
Visitante
Este tópico está impedido de receber novos posts.
  • Quem Está Navegando   0 membros estão online

    • Nenhum usuário registrado visualizando esta página.
×
×
  • Criar Novo...