williampasqualini 22 Postado Setembro 17, 2011 Share Postado Setembro 17, 2011 Mapa Utilizado Baiak Distro TFS 8.60 Preciso de um npc que ensine spells em troca de 2k por exemplo. O script que eu testei foi: 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, 'ultimate berserker')) then selfSay('voce gostaria de aprender a Ultimate Berserker?', cid) talkState[talkUser] = 1 elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then if(getPlayerVocation(cid) == 4 or getPlayerVocation(cid) == 8) then if(getPlayerLevel(cid) >= 130 and getPlayerLearnedInstantSpell(cid, "exori mas hur") == FALSE) then doPlayerLearnInstantSpell(cid, "exori mas hur") selfSay('Agora voce aprendeu a magia ultimate berserker.', cid) else selfSay('Voce ja aprendeu esta magia ou não possui nivel suficiente.', cid) end else selfSay('Apenas Knights e Elite Knights podem aprender esta magia.', cid) end talkState[talkUser] = 0 elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then talkState[talkUser] = 0 selfSay('Certo então.', cid) end if(msgcontains(msg, 'conjure assassin')) then selfSay('voce gostaria de aprender a Conjure Assassin?', cid) talkState[talkUser] = 2 elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then if(getPlayerVocation(cid) == 3 or getPlayerVocation(cid) == 7) then if(getPlayerLevel(cid) >= 80 and getPlayerLearnedInstantSpell(cid, "exevo con san") == FALSE) then doPlayerLearnInstantSpell(cid, "exevo con san") selfSay('Agora voce aprendeu a magia conjure assassin.', cid) else selfSay('Voce ja aprendeu esta magia ou não possui nivel suficiente.', cid) end else selfSay('Apenas jogadores com vocações podem aprender esta magia.', cid) end talkState[talkUser] = 0 elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then talkState[talkUser] = 0 selfSay('Certo então.', cid) end if(msgcontains(msg, 'great holy')) then selfSay('voce gostaria de aprender a Great Holy?', cid) talkState[talkUser] = 2 elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then if(getPlayerVocation(cid) == 3 or getPlayerVocation(cid) == 7) then if(getPlayerLevel(cid) >= 100 and getPlayerLearnedInstantSpell(cid, "exori con san") == FALSE) then doPlayerLearnInstantSpell(cid, "exori con san") selfSay('Agora voce aprendeu a magia great holy.', cid) else selfSay('Voce ja aprendeu esta magia ou não possui nivel suficiente.', cid) end else selfSay('Apenas jogadores com vocações podem aprender esta magia.', cid) end talkState[talkUser] = 0 elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then talkState[talkUser] = 0 selfSay('Certo então.', cid) end if(msgcontains(msg, 'great winter')) then selfSay('voce gostaria de aprender a Great Winter?', cid) talkState[talkUser] = 2 elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then if(getPlayerVocation(cid) == 2 or getPlayerVocation(cid) == 6) then if(getPlayerLevel(cid) >= 100 and getPlayerLearnedInstantSpell(cid, "exori frigo hur") == FALSE) then doPlayerLearnInstantSpell(cid, "exori frigo hur") selfSay('Agora voce aprendeu a magia great winter.', cid) else selfSay('Voce ja aprendeu esta magia ou não possui nivel suficiente.', cid) end else selfSay('Apenas jogadores com vocações podem aprender esta magia.', cid) end talkState[talkUser] = 0 elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then talkState[talkUser] = 0 selfSay('Certo então.', cid) end if(msgcontains(msg, 'great meteor')) then selfSay('voce gostaria de aprender a Great Meteor?', cid) talkState[talkUser] = 2 elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then if(getPlayerVocation(cid) == 3 or getPlayerVocation(cid) == 7) then if(getPlayerLevel(cid) >= 80 and getPlayerLearnedInstantSpell(cid, "exori mort hur") == FALSE) then doPlayerLearnInstantSpell(cid, "exori mort hur") selfSay('Agora voce aprendeu a magia great meteor.', cid) else selfSay('Voce ja aprendeu esta magia ou não possui nivel suficiente.', cid) end else selfSay('Apenas jogadores com vocações podem aprender esta magia.', cid) end talkState[talkUser] = 0 elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then talkState[talkUser] = 0 selfSay('Certo então.', cid) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Más não funcionou. Link para o comentário https://xtibia.com/forum/topic/168045-novo-npc-vende-spell-por-x-golds-igual-no-global/ Compartilhar em outros sites More sharing options...
williampasqualini 22 Postado Setembro 21, 2011 Autor Share Postado Setembro 21, 2011 Por favor alguem faz esse script pra mim? Link para o comentário https://xtibia.com/forum/topic/168045-novo-npc-vende-spell-por-x-golds-igual-no-global/#findComment-1106228 Compartilhar em outros sites More sharing options...
Kuro o Shiniga 87 Postado Setembro 21, 2011 Share Postado Setembro 21, 2011 (editado) 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 local spells = { [1] = {spell_name = "Antidote" ,price = 150, words = 'EXANA POX', number = 1}, [2] = {spell_name = "Berserk" ,price = 2500, words = 'EXORI', number = 2}, [3] = {spell_name = "Blood Rage" ,price = 8000, words = 'UTITO TEMPO', number = 3}, [4] = {spell_name = "Challenge" ,price = 2000, words = 'EXETA RES', number = 4}, [5] = {spell_name = "Charge" ,price = 1300, words = 'UTANI TEMPO HUR', number = 5}, [6] = {spell_name = "Fierce Berserk" ,price = 5000, words = 'EXORI GRAN', number = 6}, [7] = {spell_name = "Find Person" ,price = 80, words = 'EXIVA', number = 7}, [8] = {spell_name = "Great Light" ,price = 500, words = 'UTEVO GRAN LUX', number = 8}, [9] = {spell_name = "Groundshaker" ,price = 1500, words = 'EXORI MAS', number = 9}, [10] = {spell_name = "Haste" ,price = 600, words = 'UTANI HUR', number = 10}, [11] = {spell_name = "Levitate" ,price = 500, words = 'EXANI HUR', number = 11}, [12] = {spell_name = "Light" ,price = 100, words = 'UTEVO LUX', number = 12}, [13] = {spell_name = "Light Healing" ,price = 170, words = 'EXURA', number = 13}, [14] = {spell_name = "Magic Rope" ,price = 200, words = 'EXANI TERA', number = 14}, [15] = {spell_name = "Protector" ,price = 6000, words = 'UTAMO TEMPO', number = 15}, [16] = {spell_name = "Train Party" ,price = 4000, words = 'UTITO MAS SIO', number = 16}, [17] = {spell_name = "Whirlwind Throw" ,price = 800, words = 'EXORI HUR', number = 17}, [18] = {spell_name = "Wound Cleansing" ,price = 300, words = 'EXANA MORT', number = 18}, } for i = 1, #spells do if msgcontains(msg, spells.spell_name) then if getPlayerLearnedInstantSpell(cid, spells.spell_name) == false then npcHandler:say("Would you like to buy "..spells.spell_name.." for "..spells.price.." gold?", cid) talkState[talkUser] = spells.number else npcHandler:say("You already know how to cast this spell.", cid) end elseif msgcontains(msg, 'yes') then if talkState[talkUser] == spells.number then if getPlayerMoney(cid) >= spells.price then doPlayerRemoveMoney(cid, spells.price) npcHandler:say("To cast this spell say {"..spells.words.."}.", cid) doPlayerLearnInstantSpell(cid, spells.spell_name) doSendMagicEffect(getCreaturePosition(cid), 12) else npcHandler:say("You don\'t have enough money.", cid) end end end end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) So não sei se vai funcionar não testei '=' Editado Setembro 21, 2011 por Pinpao Link para o comentário https://xtibia.com/forum/topic/168045-novo-npc-vende-spell-por-x-golds-igual-no-global/#findComment-1106244 Compartilhar em outros sites More sharing options...
digo1040 56 Postado Setembro 21, 2011 Share Postado Setembro 21, 2011 Quando voce diz que não funciona voce diz que mesmo não comprado consegue usar a magia, ou que não consegue comprar a magia? Link para o comentário https://xtibia.com/forum/topic/168045-novo-npc-vende-spell-por-x-golds-igual-no-global/#findComment-1106259 Compartilhar em outros sites More sharing options...
williampasqualini 22 Postado Setembro 22, 2011 Autor Share Postado Setembro 22, 2011 Quando voce diz que não funciona voce diz que mesmo não comprado consegue usar a magia, ou que não consegue comprar a magia? Eu falo com npc: hi o nome da magia e ele me responde que eu aprendi a magia. quando eu vou usar a magia ele me informa que eu tenho que aprender.... ai eu vou novamente falo denovo com o npc e mesmo asim não aprendo a magia...mesmo o npc dizendo que eu aprendi. é isso que esta acontecendo com o script que postei. 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 local spells = { [1] = {spell_name = "Antidote" ,price = 150, words = 'EXANA POX', number = 1}, [2] = {spell_name = "Berserk" ,price = 2500, words = 'EXORI', number = 2}, [3] = {spell_name = "Blood Rage" ,price = 8000, words = 'UTITO TEMPO', number = 3}, [4] = {spell_name = "Challenge" ,price = 2000, words = 'EXETA RES', number = 4}, [5] = {spell_name = "Charge" ,price = 1300, words = 'UTANI TEMPO HUR', number = 5}, [6] = {spell_name = "Fierce Berserk" ,price = 5000, words = 'EXORI GRAN', number = 6}, [7] = {spell_name = "Find Person" ,price = 80, words = 'EXIVA', number = 7}, [8] = {spell_name = "Great Light" ,price = 500, words = 'UTEVO GRAN LUX', number = 8}, [9] = {spell_name = "Groundshaker" ,price = 1500, words = 'EXORI MAS', number = 9}, [10] = {spell_name = "Haste" ,price = 600, words = 'UTANI HUR', number = 10}, [11] = {spell_name = "Levitate" ,price = 500, words = 'EXANI HUR', number = 11}, [12] = {spell_name = "Light" ,price = 100, words = 'UTEVO LUX', number = 12}, [13] = {spell_name = "Light Healing" ,price = 170, words = 'EXURA', number = 13}, [14] = {spell_name = "Magic Rope" ,price = 200, words = 'EXANI TERA', number = 14}, [15] = {spell_name = "Protector" ,price = 6000, words = 'UTAMO TEMPO', number = 15}, [16] = {spell_name = "Train Party" ,price = 4000, words = 'UTITO MAS SIO', number = 16}, [17] = {spell_name = "Whirlwind Throw" ,price = 800, words = 'EXORI HUR', number = 17}, [18] = {spell_name = "Wound Cleansing" ,price = 300, words = 'EXANA MORT', number = 18}, } for i = 1, #spells do if msgcontains(msg, spells.spell_name) then if getPlayerLearnedInstantSpell(cid, spells.spell_name) == false then npcHandler:say("Would you like to buy "..spells.spell_name.." for "..spells.price.." gold?", cid) talkState[talkUser] = spells.number else npcHandler:say("You already know how to cast this spell.", cid) end elseif msgcontains(msg, 'yes') then if talkState[talkUser] == spells.number then if getPlayerMoney(cid) >= spells.price then doPlayerRemoveMoney(cid, spells.price) npcHandler:say("To cast this spell say {"..spells.words.."}.", cid) doPlayerLearnInstantSpell(cid, spells.spell_name) doSendMagicEffect(getCreaturePosition(cid), 12) else npcHandler:say("You don\'t have enough money.", cid) end end end end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) So não sei se vai funcionar não testei '=' Não deu certo, eu falo hi, hello; pro npc e ele não responde nada. Link para o comentário https://xtibia.com/forum/topic/168045-novo-npc-vende-spell-por-x-golds-igual-no-global/#findComment-1106686 Compartilhar em outros sites More sharing options...
Posts Recomendados