Postado Maio 11, 2015 10 anos 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 Maio 11, 2015 10 anos Tenta ae 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) end return true end 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())
Postado Maio 12, 2015 10 anos 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 Maio 14, 2015 10 anos 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.