Postado Abril 13, 2015 10 anos Dou 10 reps se alguem me ajudar com essa parada Meu npc de spell vende a spell certinho e tal, mas os players ficam meio perdido pq tipo comprei intense healing, e agora? Como eu uso? Ai queria colocar uma descrição pra cada magia, tipo intense healing = exura gran, ai qnd ele compra-se intense healing ia dizer que é exura gran Exemplo: Como está no meu ot 20:44 Dan [16]: intense healing 20:44 Lea: You learned intense healing. Como eu queria 20:44 Dan [16]: intense healing 20:44 Lea: You learned intense healing! Spell: [exura gran]. Se puder tbm coloca no livro qnd fala 'spells pro npc' aqui ó for name, info in pairs(spells_t) do if isInArray(info.vocations, voc) and not getPlayerLearnedInstantSpell(cid, name) then table.insert(str, tostring(" {".. name .."} for ".. info.price .." gold coins,\n") ) end end Script de venda de spell: local spells_t = { -- all ["intense healing"] = {price = 350, vocations = {1,2,3,5,6,7}, level = 1}, -- exura gran } 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:lower(), "spells") then local str = {} local voc = getPlayerVocation(cid) for name, info in pairs(spells_t) do if isInArray(info.vocations, voc) and not getPlayerLearnedInstantSpell(cid, name) then table.insert(str, tostring(" {".. name .."} for ".. info.price .." gold coins,\n") ) end end if next(str) == nil then npcHandler:say("I have no magic to sell you.", cid) else doShowTextDialog(cid, 2175, table.concat(str)) end elseif spells_t[msg:lower()] then if getPlayerLearnedInstantSpell(cid, msg) then npcHandler:say("You have already learned this spell.", cid) return true end if getPlayerLevel(cid) < spells_t[msg:lower()].level then npcHandler:say("You need to be level ".. spells_t[msg:lower()].level.." or older to purchase this spell.", cid) return true end if not isInArray(spells_t[msg:lower()].vocations, getPlayerVocation(cid)) then npcHandler:say("You do not have the vocation to buy is spell.", cid) return true end if doPlayerRemoveMoney(cid, spells_t[msg:lower()].price) then doPlayerLearnInstantSpell(cid, msg) npcHandler:say("You learned ".. msg ..".", cid) else npcHandler:say("You do not have "..spells_t[msg:lower()].price.." gold coins.", cid) end end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Postado Abril 14, 2015 10 anos Tenta isso: local spells_t = { -- all ["intense healing"] = {price = 350, vocations = {1,2,3,5,6,7}, level = 1, word = exura gran}, -- exura gran } 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:lower(), "spells") then local str = {} local voc = getPlayerVocation(cid) for name, info in pairs(spells_t) do if isInArray(info.vocations, voc) and not getPlayerLearnedInstantSpell(cid, name) then table.insert(str, tostring(" {".. name .."} for ".. info.price .." gold coins,\n") ) end end if next(str) == nil then npcHandler:say("I have no magic to sell you.", cid) else doShowTextDialog(cid, 2175, table.concat(str)) end elseif spells_t[msg:lower()] then if getPlayerLearnedInstantSpell(cid, msg) then npcHandler:say("You have already learned this spell.", cid) return true end if getPlayerLevel(cid) < spells_t[msg:lower()].level then npcHandler:say("You need to be level ".. spells_t[msg:lower()].level.." or older to purchase this spell.", cid) return true end if not isInArray(spells_t[msg:lower()].vocations, getPlayerVocation(cid)) then npcHandler:say("You do not have the vocation to buy is spell.", cid) return true end if doPlayerRemoveMoney(cid, spells_t[msg:lower()].price) then doPlayerLearnInstantSpell(cid, msg) npcHandler:say("You learned ".. msg .."! Spell: ["..spells_t[msg].word.."].", cid) else npcHandler:say("You do not have "..spells_t[msg:lower()].price.." gold coins.", cid) end end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Se quiser sua dúvida tirada, mande PM com os links, e não com a dúvida (outros podem ter a mesma dúvida, e o fórum serve para ser usado). Tópicos: [FAQ] BBCODE [LIB] Constant [RME] Administrando bordas. [TALK] Broadcast Editável. [TALK] Sugest. [TALK] Checkpoint. [MOVE] Pântano pegajoso. [ACTION] Piggy Bank. (Cassino). [GLOBAL] Uptime Ad. [C0DE] Consertando 'Invalid Password' [PROGRAM] Quest Maker
Postado Abril 14, 2015 10 anos Solução local spells_t = { -- all ["intense healing"] = {price = 350, vocations = {1,2,3,5,6,7}, level = 1, spell = "Exura Gran"}, -- exura gran } 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:lower(), "spells") then local str = {} local voc = getPlayerVocation(cid) for name, info in pairs(spells_t) do if isInArray(info.vocations, voc) and not getPlayerLearnedInstantSpell(cid, name) then table.insert(str, tostring(" {".. name .."}["..info.spell.."] for ".. info.price .." gold coins,\n") ) end end if next(str) == nil then npcHandler:say("I have no magic to sell you.", cid) else doShowTextDialog(cid, 2175, table.concat(str)) end elseif spells_t[msg:lower()] then if getPlayerLearnedInstantSpell(cid, msg) then npcHandler:say("You have already learned this spell.", cid) return true end if getPlayerLevel(cid) < spells_t[msg:lower()].level then npcHandler:say("You need to be level ".. spells_t[msg:lower()].level .." or older to purchase this spell.", cid) return true end if not isInArray(spells_t[msg:lower()].vocations, getPlayerVocation(cid)) then npcHandler:say("You do not have the vocation to buy is spell.", cid) return true end if doPlayerRemoveMoney(cid, spells_t[msg:lower()].price) then doPlayerLearnInstantSpell(cid, msg) npcHandler:say("You learned ".. msg .."["..spells_t[msg:lower()].spell.."].", cid) else npcHandler:say("You do not have "..spells_t[msg:lower()].price.." gold coins.", cid) end end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) O nome da magia você poe aqui: spell = "Exura Gran" _ .-'` `} _./) / } .'o \ | } '.___.'`.\ {` /`\_/ , `. } ME DA UMA NOZ! \=' .-' _`\ { `'`;/ `, } _\ @ ; } /__`;-...'--' Cluck!
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.