Postado Maio 26, 2018 7 anos @Jociel local t = { [255] = {256, 50, 3000, 3000} -- {old vocation} = {New vocation, looktype, life extra, mana extra} } local itemid, count = 2150 , 5 -- ID do item que precisa local level = 100 -- level necessario para a promotion 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) local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid local a = t[getPlayerVocation(cid)] local outfit = {lookType = a[2]} if msgcontains(msg, "yes") then if a then if getPlayerLevel(cid) >= level then if doPlayerRemoveItem(cid, itemid, count) then doPlayerSetVocation(cid, a[1]) doCreatureChangeOutfit(cid, outfit) setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + a[3]) setCreatureMaxMana(cid, getCreatureMaxMana(cid) + a[4]) addEvent(doRemoveCreature, 1000, cid) else selfSay('Voce precisa de '.. count ..' '.. getItemInfo(itemid).name ..' para fazer a super promotion.', cid) end else selfSay('Você precisa estar no level '.. level ..'.', cid) end else selfSay('Sua vocation não tem promotion disponivel', cid) end return true end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Postado Maio 26, 2018 7 anos Autor @Sttorm o erro persiste [26/05/2018 11:28:38] [Error - Npc interface] [26/05/2018 11:28:38] data/npc/scripts/mysticSystem.lua:onCreatureSay [26/05/2018 11:28:38] Description: [26/05/2018 11:28:38] data/npc/scripts/mysticSystem.lua:25: attempt to index local 'a' (a nil value) [26/05/2018 11:28:38] stack traceback: [26/05/2018 11:28:38] data/npc/scripts/mysticSystem.lua:25: in function 'callback' [26/05/2018 11:28:38] data/npc/lib/npcsystem/npchandler.lua:390: in function 'onCreatureSay' [26/05/2018 11:28:38] data/npc/scripts/mysticSystem.lua:19: in function <data/npc/scripts/mysticSystem.lua:19>
Postado Maio 26, 2018 7 anos Solução @Jociel local t = { [255] = {256, 50, 3000, 3000} -- {old vocation} = {New vocation, looktype, life extra, mana extra} } local itemid, count = 2150 , 5 -- ID do item que precisa local level = 100 -- level necessario para a promotion 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) local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid local a = t[getPlayerVocation(cid)] if msgcontains(msg, "yes") then if a then if getPlayerLevel(cid) >= level then if doPlayerRemoveItem(cid, itemid, count) then local outfit = {lookType = a[2]} doPlayerSetVocation(cid, a[1]) doCreatureChangeOutfit(cid, outfit) setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + a[3]) setCreatureMaxMana(cid, getCreatureMaxMana(cid) + a[4]) addEvent(doRemoveCreature, 1000, cid) else selfSay('Voce precisa de '.. count ..' '.. getItemInfo(itemid).name ..' para fazer a super promotion.', cid) end else selfSay('Você precisa estar no level '.. level ..'.', cid) end else selfSay('Sua vocation não tem promotion disponivel', cid) end return true 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.