Eu fiz uma talk parecida ela exibia as spells que o player pode usar o processo e o mesmo usando gmatch
.
- Fórum
- OTServ
- Recursos
- Scripting
- Actions e Talkactions
- [TalkAction] Spell informations
SK
talkaction
[TalkAction] Spell informations
Por Skymagnum, 24 de abr. de 2013 em Actions e Talkactions
script
5
727
info
Grupo: Infante
Registrado: 04/03/11
Posts: 1.6k
Reputação: +393
Char no Tibia: No Have

24 de abril de 2013 às 21:34
info
Grupo: Marquês
Registrado: 02/08/12
Posts: 1k
Reputação: +234
Char no Tibia: Maurolkit

24 de abril de 2013 às 21:35
Não é a mesma coisa que o comando, !spells que já vem no server?
info
Grupo: Infante
Registrado: 04/03/11
Posts: 1.6k
Reputação: +393
Char no Tibia: No Have

24 de abril de 2013 às 21:39
Mais ou menos tinha suas diferenças mais era parecido sim.


info
Grupo: Marquês
Registrado: 02/08/12
Posts: 1k
Reputação: +234
Char no Tibia: Maurolkit
Tipo: Talkaction.
Autor:Eu e o Maxwelden(não sei escreve nome dele heuheeuhe).
Vá em /data/talkactions/scripts, crie um arquivo .lua e renomeie para spellinfo, e adicione isso dentro:
function getSpellAttribute(name, att) local file = io.open("data/spells/spells.xml", "r") for info in string.gmatch(file:read("*a"), "<instant(.-)</instant>") do if tostring(info:match("name=\"(.-)\"")):lower() == name:lower() then local att = info:match(att .. "=\"(.-)\"") return tonumber(att) or tostring(att) end end file:close() return nil end function getSpellAttributes(name) local atts = {"instantName", "words", "lvl", "mana", "prem", "exhaustion", "groups", "icon", "needlearn", "vocations",} local att = {} for _, v in pairs(atts) do att[v] = getSpellAttribute(name, v) end return att end function onSay(cid, words, param, channel) local file = io.open("data/spells/spells.xml", "r") local openFile = file:read("*a") local names = {} local str = "" for i in openFile:gmatch('<instant(.-)</instant>') do local name = tostring(i:match('name="(.-)"')) table.insert(names, name) end if not isInArray(names, param) then doPlayerSendCancel(cid, "Essa magia não existe.") return true end for k, v in in pairs(getSpellAttributes(param)) do str = str .. k .. " = " .. v end doShowTextDialog(cid, 2160, str) return true endem talkactions.xml adicione essa linha:
Qualquer erro comente e eu arrumarei.
Editado Abril 24 por Skymagnum