Ir para conteúdo

[Encerrado] [Encerrado] Npc Spell (preciso apenas de uma fala para funcionar)


Posts Recomendados

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 moeda = 2148

local t = {

		 ["great light"] = {price = 500,vocations = {3,4},level = 1},

		 ["light magic missile"] = {price = 500,vocations = {3},level = 1},
		 
		 ["light"] = {price = 0,vocations = {3,4},level = 1},
		 
		 ["light healing"] = {price = 170,vocations = {3,4},level = 1},
		 
		 ["find person"] = {price = 80,vocations = {3,4},level = 1},
		 
		 ["antidote"] = {price = 150,vocations = {3,4},level = 1},
		 
		 ["create food"] = {price = 300,vocations = {3},level = 1},
		 
		 ["destroy field"] = {price = 700,vocations = {3},level = 1},
		 
		 ["conjure arrow"] = {price = 450,vocations = {3},level = 1},
		 
		 ["conjure poisoned arrow"] = {price = 700,vocations = {3},level = 1},
		 
		 ["intense healing"] = {price = 350,vocations = {3},level = 1},

		 ["ultimate healing"] = {price = 1000,vocations = {3},level = 1},

		 ["heavy magic missile"] = {price = 1500,vocations = {3},level = 1},

		 ["desintegrate"] = {price = 900,vocations = {3},level = 1},
		 
		 ["invisibility"] = {price = 2000,vocations = {3},level = 1},
		 
		 ["conjure explosive arrow"] = {price = 1000,vocations = {3},level = 1},

		 }

if (msgcontains(msg, 'SPELLS') or msgcontains(msg, 'spells'))then

local str = ""

str = str .. "I sell"

for name, pos in pairs(t) do

str = str.." {"..name.."} = "..pos.price.."gold /"

end

str = str .. "."

npcHandler:say(str, cid)

elseif t[msg] then

			 if not getPlayerLearnedInstantSpell(cid, msg) then

			 if getPlayerLevel(cid) >= t[msg].level then

			 if isInArray(t[msg].vocations, getPlayerVocation(cid)) then
			 
			 npcHandler:say("Would you like to learn ".. msg .." for "..t[msg].price.."?", cid)

			 if doPlayerRemoveItem(cid,moeda,t[msg].price) then

					 doPlayerLearnInstantSpell(cid, msg)

					 npcHandler:say("You learned a new magic called ".. msg .."!", cid)

			 else

					 npcHandler:say("You dont have "..t[msg].price.." ".. getItemNameById(moeda), cid)

			 end

			 else

					 npcHandler:say("Sorry, I only teach spells to knights and paladins.", cid)

			 end

			 else

					 npcHandler:say("you need to have level "..t[msg].level.." or more to learn this magic.", cid)

			 end

			 else

					 npcHandler:say("You have already learned this magic.", cid)

			 end

end

return TRUE

end

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

Está funcionando tudo normal ele pergunta se quer o spell tal, mas ele pergunta e já vende o spell direto, não da pra responder yes, tem alguma maneira de colocar para escrever um yes para o script prosseguir?

abaixo da linha 

			 npcHandler:say("Would you like to learn ".. msg .." for "..t[msg].price.."?", cid)

 

Link para o comentário
Compartilhar em outros sites

  • 1 month later...
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...