Eu fiz uma talk parecida ela exibia as spells que o player pode usar o processo e o mesmo usando gmatch
.
- Forums
- OTServ
- Recursos
- Scripting
- Actions e Talkactions
- [TalkAction] Spell informations
SK
talkaction
[TalkAction] Spell informations
By Skymagnum, 24 de abr. de 2013 in Actions e Talkactions
script
5
780
info
Group: Infante
Joined: 04/03/11
Posts: 1.6k
Reputation: +393
Tibia Character: No Have

24 de abril de 2013 às 21:34
info
Group: Marquês
Joined: 02/08/12
Posts: 1k
Reputation: +234
Tibia Character: Maurolkit

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

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


info
Group: Marquês
Joined: 02/08/12
Posts: 1k
Reputation: +234
Tibia Character: 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.
Edited Abril 24 by Skymagnum