Ir para conteúdo

Featured Replies

Postado

Ola galera, eu estou com um pequeno erro em um NPC, eu não estou conseguindo resolver, alguém pode me ajudar? REP+

 

Fica aqui o erro na distro:

 

[11/05/2015 18:04:25] [Error - LuaScriptInterface::loadFile] data/npc/scripts/Mega Evo Guru.lua:25: 'end' expected (to close 'function' at line 9) near 'elseif'


[11/05/2015 18:04:25] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/Mega Evo Guru.lua
[11/05/2015 18:04:25] data/npc/scripts/Mega Evo Guru.lua:25: 'end' expected (to close 'function' at line 9) near 'elseif'

 

Script do NPC:

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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 creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
 
        if msgcontains(msg, 'mega charizard x') or msgcontains(msg, 'Mega Charizard X') then
           if getPlayerLevel(cid) < 100 then
              selfSay("Voce ainda não possui vinclo suficiente com seus pokemons, treine mais e volte aqui!", cid)
              talkState[talkUser] = 4
              return true
           end
              selfSay("Entao deseja equipar uma Mega Stone no seu Charizard? Me entregue seu Charizard e uma Charizartite X!", cid)
              talkState[talkUser] = 0
           end
        elseif (msgcontains(msg, 'yes') or msgcontains(msg, 'Yes')) and talkState[talkUser] == 4 then
           if getPlayerSlotItem(cid, 8).uid <= 0 then
              selfSay("Equipe seu Charizard no slot principal!", cid)
              talkState[talkUser] = 0
		      return true
	       end 
	                                                                             --alterado v1.2
	       if #getCreatureSummons(cid) >= 1 then
	          selfSay("Guarde seu pokemon na pokebola!", cid)
              talkState[talkUser] = 0
              return true
           end
	       
	       local pb = getPlayerSlotItem(cid, 8).uid
	       
	       if getItemAttribute(pb, "poke") ~= "Charizard" then
	          selfSay("Equipe seu Charizard no slot principal!", cid)
              talkState[talkUser] = 0
              return true
           end
           if doPlayerRemoveItem(cid,11414,1) == true then
              selfSay("So there is it! Enjoy!", cid)
              doItemSetAttribute(pb, "hp", 1)
              doItemSetAttribute(pb, "poke", "Stonex Charizard")
		      doItemSetAttribute(pb, "description", "Contains a Charizard.")
		      doTransformItem(getPlayerSlotItem(cid, 7).uid, fotos["Charizard"])
		      ----------------------
		      local pokeinfo = getPokemonStatus("Charizard")
		      local level = getItemAttribute(pb, "level")
		      local offense = pokeinfo.off * level
              local defense = pokeinfo.def * level
              local agility = pokeinfo.agi * level
              local spatk = pokeinfo.spatk * level
	          local vit = pokeinfo.vit * level
	          local leveltable = getPokemonExperienceTable("Charizard")
	          doItemSetAttribute(pb, "exp", leveltable[level])
              doItemSetAttribute(pb, "nextlevelexp", leveltable[level+1] - leveltable[level])
              doItemSetAttribute(pb, "offense", offense)
		      doItemSetAttribute(pb, "defense", defense)
		      doItemSetAttribute(pb, "speed", agility)
		      doItemSetAttribute(pb, "vitality", vit)
		      doItemSetAttribute(pb, "specialattack", spatk)
		      doItemSetAttribute(pb, "fakedesc", "Contains a Charizard.")
	          -----------------------
		      if useKpdoDlls then
		        doCreatureExecuteTalkAction(cid, "/pokeread")
	          end
		      talkState[talkUser] = 0
		      return true
	      else
	          selfSay("Onde esta a Charizartite X?", cid)
	          talkState[talkUser] = 0
	          return true
          end
        end

return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())             

 

Não sei se vai ajudar tbm na hora de me ajudar, mas era para ele fazer o seguinte:

 

-Player fala qual mega ele quer

-NPC Verifica o LvL do player

-NPC pergunta se o player tem certeza

-NPC verifica se o pokemon esta no slot certo

-NPC verifica se o pokemon na pokebola é o charizard

-NPC altera os dados da pokebola do player

-NPC remove a Mega stone

 

Postado

Tenta ae

 

  1. local keywordHandler = KeywordHandler:new()
  2. local npcHandler = NpcHandler:new(keywordHandler)
  3. NpcSystem.parseParameters(npcHandler)
  4. local talkState = {}
  5. function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
  6. function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
  7. function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
  8. function onThink() npcHandler:onThink() end
  9. function creatureSayCallback(cid, type, msg)
  10. end
  11. return true
  12. end
  13. if(not npcHandler:isFocused(cid)) then
  14. return false
  15. end
  16.  
  17. local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
  18.  
  19. if msgcontains(msg, 'mega charizard x') or msgcontains(msg, 'Mega Charizard X') then
  20. if getPlayerLevel(cid) < 100 then
  21. selfSay("Voce ainda não possui vinclo suficiente com seus pokemons, treine mais e volte aqui!", cid)
  22. talkState[talkUser] = 4
  23. return true
  24. end
  25. selfSay("Entao deseja equipar uma Mega Stone no seu Charizard? Me entregue seu Charizard e uma Charizartite X!", cid)
  26. talkState[talkUser] = 0
  27. end
  28. elseif (msgcontains(msg, 'yes') or msgcontains(msg, 'Yes')) and talkState[talkUser] == 4 then
  29. if getPlayerSlotItem(cid, 8).uid <= 0 then
  30. selfSay("Equipe seu Charizard no slot principal!", cid)
  31. talkState[talkUser] = 0
  32. return true
  33. end
  34. --alterado v1.2
  35. if #getCreatureSummons(cid) >= 1 then
  36. selfSay("Guarde seu pokemon na pokebola!", cid)
  37. talkState[talkUser] = 0
  38. return true
  39. end
  40.  
  41. local pb = getPlayerSlotItem(cid, 8).uid
  42.  
  43. if getItemAttribute(pb, "poke") ~= "Charizard" then
  44. selfSay("Equipe seu Charizard no slot principal!", cid)
  45. talkState[talkUser] = 0
  46. return true
  47. end
  48. if doPlayerRemoveItem(cid,11414,1) == true then
  49. selfSay("So there is it! Enjoy!", cid)
  50. doItemSetAttribute(pb, "hp", 1)
  51. doItemSetAttribute(pb, "poke", "Stonex Charizard")
  52. doItemSetAttribute(pb, "description", "Contains a Charizard.")
  53. doTransformItem(getPlayerSlotItem(cid, 7).uid, fotos["Charizard"])
  54. ----------------------
  55. local pokeinfo = getPokemonStatus("Charizard")
  56. local level = getItemAttribute(pb, "level")
  57. local offense = pokeinfo.off * level
  58. local defense = pokeinfo.def * level
  59. local agility = pokeinfo.agi * level
  60. local spatk = pokeinfo.spatk * level
  61. local vit = pokeinfo.vit * level
  62. local leveltable = getPokemonExperienceTable("Charizard")
  63. doItemSetAttribute(pb, "exp", leveltable[level])
  64. doItemSetAttribute(pb, "nextlevelexp", leveltable[level+1] - leveltable[level])
  65. doItemSetAttribute(pb, "offense", offense)
  66. doItemSetAttribute(pb, "defense", defense)
  67. doItemSetAttribute(pb, "speed", agility)
  68. doItemSetAttribute(pb, "vitality", vit)
  69. doItemSetAttribute(pb, "specialattack", spatk)
  70. doItemSetAttribute(pb, "fakedesc", "Contains a Charizard.")
  71. -----------------------
  72. if useKpdoDlls then
  73. doCreatureExecuteTalkAction(cid, "/pokeread")
  74. end
  75. talkState[talkUser] = 0
  76. return true
  77. else
  78. selfSay("Onde esta a Charizartite X?", cid)
  79. talkState[talkUser] = 0
  80. return true
  81. end
  82. end
  83.  
  84. return true
  85. end
  86.  
  87. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  88. npcHandler:addModule(FocusModule:new())

Postado
  • Autor

não resolveu, dps eu mando como ficou a distro,  analizando eu creio que algo esta faltando na linha 25 e não na 9, mas colocando outro end la, ainda não resolve.

Postado

Testei em uma base PDA e está funcionando, caso apresente algum erro me fale:

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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 creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end

local msg = msg:lower();
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
        
        local pb = getPlayerSlotItem(cid, 8).uid
        if msgcontains(msg, 'mega charizard x') or msgcontains(msg, 'mega') then
           if getPlayerLevel(cid) >= 100 then
              selfSay("Você deseja equipar uma Mega stone em seu charizard? Me entregue seu Charizard e uma Charizartite X.", cid)
              talkState[talkUser] = 1
           else
              selfSay("Você parece fraco, treine mais e volte depois.", cid)
              talkState[talkUser] = 0
           end
        elseif msgcontains(msg, 'yes') then
           if talkState[talkUser] == 1 then
               if pb > 0 then
                  if #getCreatureSummons(cid) < 1 then
                     if getItemAttribute(pb, "poke") == "Charizard" then
                        if doPlayerRemoveItem(cid,11414,1) == true then
                            selfSay("Aqui está seu pokémon! Aproveite!", cid)
                            doItemSetAttribute(pb, "hp", 1)
                            doItemSetAttribute(pb, "poke", "Stonex Charizard")
                            doItemSetAttribute(pb, "description", "Contains a Charizard.")
                            doTransformItem(getPlayerSlotItem(cid, 7).uid, fotos["Charizard"])
                                local pokeinfo = getPokemonStatus("Charizard")
                                local level = getItemAttribute(pb, "level")
                                local offense = pokeinfo.off * level
                                local defense = pokeinfo.def * level
                                local agility = pokeinfo.agi * level
                                local spatk = pokeinfo.spatk * level
                                local vit = pokeinfo.vit * level
                                local leveltable = getPokemonExperienceTable("Charizard")
                            doItemSetAttribute(pb, "exp", leveltable[level])
                            doItemSetAttribute(pb, "nextlevelexp", leveltable[level+1] - leveltable[level])
                            doItemSetAttribute(pb, "offense", offense)
                            doItemSetAttribute(pb, "defense", defense)
                            doItemSetAttribute(pb, "speed", agility)
                            doItemSetAttribute(pb, "vitality", vit)
                            doItemSetAttribute(pb, "specialattack", spatk)
                            doItemSetAttribute(pb, "fakedesc", "Contains a Charizard.")
                            talkState[talkUser] = 0
                        else
                            selfSay("Você não tem uma Charizartite X.", cid)
                            talkState[talkUser] = 0
                        end
                     else
                         selfSay("Coloque seu charizard no slot principal.", cid)
                         talkState[talkUser] = 0
                     end
                  else
                      selfSay("Guarde seu pokémon na pokébola.", cid)
                      talkState[talkUser] = 0
                  end
               else
                   selfSay("Coloque seu charizard no slot principal.", cid)
                   talkState[talkUser] = 0
               end
           end
        elseif msgcontains(msg, "no") then
           if talkState[talkUser] == 1 then
              selfSay("Ok...", cid)
              talkState[talkUser] = 0
           end
        end
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())          

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

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo