Jump to content
  • 0

Spells


ScythePhantom

Question

Olá, gostaria de pedir uma talkaction que funcionasse da seguinte maneira, o player iria falar !spells e apareceriam as informações de todas as spells do servidor, exemplo:

 

Exana mort:

Level: 8

Ml: 8

Mana: 20

Vocação: Knight, Elite Knight.

 

P.S. Editar a action do spellbook de forma semelhante:

 

ACTION:

 

function onUse(cid, item, fromPosition, itemEx, toPosition)
local count = getPlayerInstantSpellCount(cid)
local text = ""
local t = {}
for i = 0, count - 1 do
local spell = getPlayerInstantSpellInfo(cid, i)
if spell.level ~= 0 then
if spell.manapercent > 0 then
spell.mana = spell.manapercent .. "%"
end
table.insert(t, spell)
end
end
table.sort(t, function(a, b) return a.level < b.level end)
local prevLevel = -1
for i, spell in ipairs(t) do
local line = ""
if prevLevel ~= spell.level then
if i ~= 1 then
line = "\n"
end
line = line .. "Spells for Level " .. spell.level .. "\n"
prevLevel = spell.level
end
text = text .. line .. " " .. spell.words .. " - " .. spell.name .. " : " .. spell.mana .. "\n"
end
doShowTextDialog(cid, item.itemid, text)
return TRUE
end

 

 

Obrigado, REP+


@UP


@UP
@UP
Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 0

OT/data/talkactions/scripts cria um arquivo com nome spells.lua

function onSay(cid, words, param)
local count = getPlayerInstantSpellCount(cid)
local text = ""
local t = {}
for i = 0, count - 1 do
local spell = getPlayerInstantSpellInfo(cid, i)
if spell.level ~= 0 then
if spell.manapercent > 0 then
spell.mana = spell.manapercent .. "%"
end
table.insert(t, spell)
end
end
table.sort(t, function(a, b) return a.level < b.level end)
local prevLevel = -1
for i, spell in ipairs(t) do
local line = ""
if prevLevel ~= spell.level then
if i ~= 1 then
line = "\n"
end
line = line .. "Spells for Level " .. spell.level .. "\n"
prevLevel = spell.level
end
text = text .. line .. " " .. spell.words .. " - " .. spell.name .. " : " .. spell.mana .. "\n"
end
doShowTextDialog(cid, 2175, text)
return TRUE
end

depois registre no xml:

<talkaction words="!spells" script="spells.lua" />
Link to comment
Share on other sites

  • 0

 

OT/data/talkactions/scripts cria um arquivo com nome spells.lua

 

function onSay(cid, words, param)
local count = getPlayerInstantSpellCount(cid)
local text = ""
local t = {}
for i = 0, count - 1 do
local spell = getPlayerInstantSpellInfo(cid, i)
if spell.level ~= 0 then
if spell.manapercent > 0 then
spell.mana = spell.manapercent .. "%"
end
table.insert(t, spell)
end
end
table.sort(t, function(a, b) return a.level < b.level end)
local prevLevel = -1
for i, spell in ipairs(t) do
local line = ""
if prevLevel ~= spell.level then
if i ~= 1 then
line = "\n"
end
line = line .. "Spells for Level " .. spell.level .. "\n"
prevLevel = spell.level
end
text = text .. line .. " " .. spell.words .. " - " .. spell.name .. " : " .. spell.mana .. "\n"
end
doShowTextDialog(cid, 2175, text)
return TRUE
end

depois registre no xml:

<talkaction words="!spells" script="spells.lua" />

 

Não... está igual ao dos outros... Eu gostaria que mostrasse daquela forma que citei;

Exana mort:
Level: 8
Ml: 8
Mana: 20
Link to comment
Share on other sites

  • 0


function onSay(cid, words, param)

local count = getPlayerInstantSpellCount(cid)

local text = ""

local t = {}

for i = 0, count - 1 do

local spell = getPlayerInstantSpellInfo(cid, i)

if spell.level ~= 0 then

if spell.manapercent > 0 then

spell.mana = spell.manapercent .. "%"

end

table.insert(t, spell)

end

end

table.sort(t, function(a, b) return a.level < b.level end)

local prevLevel = -1

for i, spell in ipairs(t) do

local line = ""

if prevLevel ~= spell.level then

if i ~= 1 then

line = "\n"

end

line = line .. "Spells for Level " .. spell.level .. "\n"

prevLevel = spell.level

end

text = text .. line .. " " .. spell.words .. " - " .. spell.name .. " : " .. spell.mana .. "\n"

end

doShowTextDialog(cid, 2175, text)

return TRUE

end

Link to comment
Share on other sites

  • 0
function onSay(cid, words, param)
local count = getPlayerInstantSpellCount(cid)
local text = ""
local t = {}
for i = 0, count - 1 do
local spell = getPlayerInstantSpellInfo(cid, i)
if spell.level ~= 0 then
if spell.manapercent > 0 then
spell.mana = spell.manapercent .. "%"
end
table.insert(t, spell)
end
end
table.sort(t, function(a, b) return a.level < b.level end)
local prevLevel = -1
for i, spell in ipairs(t) do
local line = ""
if prevLevel ~= spell.level then
if i ~= 1 then
line = "\n"
end
line = line .. "Spells for Level " .. spell.level .. "\n"
prevLevel = spell.level
end
text = text .. line .. " " .. spell.words .. " - " .. spell.name .. " : " .. spell.mana .. "\n"
end
doShowTextDialog(cid, 2175, text)
return TRUE
end

Continua igual aos outros.

Link to comment
Share on other sites

×
×
  • Create New...