Ir para conteúdo
  • 0
Entre para seguir isso  
potinho

Scripting TalkAction - Spells

Pergunta

potinho    4
potinho

Descreva em algumas palavras a base utilizada. (Nome do servidor / Nome do cliente / Nome do website / etc.).

The OTX Server Version: (2.100 - 6000) - Codename: (FINAL) 7.6

Qual é a sua pergunta?

Tenho uma talkaction que deveria mostrar as spells que os players possuem, mas ela retorna em branco, seguem scripts.

talkactions\talkactions.xml

<talkaction words="/spells" event="script" value="spellbook.lua" />

talkactions\scripts\spellbook.lua

Spoiler

 function onSay(cid, words, param, channel)
	local t, k = {}, getPlayerLevel(cid)
	for i = 0, getPlayerInstantSpellCount(cid) - 1 do
		local spell = getPlayerInstantSpellInfo(cid, i)
		if(spell.level ~= 0 and k >= spell.level) 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 text, 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

 

 

Quando uso o comando, retorna o spellbook vazio

Spoiler

image.png.08f0a2dd23bd85c70c27690a5d05bb29.png

 

Compartilhar este post


Link para o post
Compartilhar em outros sites

3 respostass a esta questão

Recommended Posts

  • 0
potinho    4
potinho

Consegui resolver com o script abaixo:

 

function onSay(cid, words, param, channel)
       local t = {}
    for i = 0, getPlayerInstantSpellCount(cid) - 1 do
        local spell = getPlayerInstantSpellInfo(cid, i)
        if(spell.manapercent > 0) then
            spell.mana = spell.manapercent .. "%"
        end
    
        table.insert(t, spell)
    end
    
    local text = ""
    for i, spell in ipairs(t) do    
        text = text .. "  " .. spell.words .. " - " .. spell.name .. " : " .. spell.mana .. "\n"
    end
    
    doShowTextDialog(cid, 2175, text)
    return true
end

 

Compartilhar este post


Link para o post
Compartilhar em outros sites
  • 0
Eduardo Dantas    23
Eduardo Dantas

Testa esse: 

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
	local text = ""
	local tlvl = {}
	local tml = {}

	for _, spell in ipairs(player:getInstantSpells()) do
		if spell.level ~= 0 or spell.mlevel ~= 0 then
			if spell.manapercent > 0 then
				spell.mana = spell.manapercent .. "%"
			end
			if spell.level > 0 then
				tlvl[#tlvl+1] = spell
			elseif spell.mlevel > 0 then
				tml[#tml+1] = spell
			end
		end
	end

	table.sort(tlvl, function(a, b) return a.level < b.level end)
	local prevLevel = -1
	for i, spell in ipairs(tlvl) 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
	text = text.."\n"
	table.sort(tml, function(a, b) return a.mlevel < b.mlevel end)
	local prevmLevel = -1
	for i, spell in ipairs(tml) do
		local line = ""
		if prevLevel ~= spell.mlevel then
			if i ~= 1 then
				line = "\n"
			end
			line = line .. "Spells for Magic Level " .. spell.mlevel .. "\n"
			prevmLevel = spell.mlevel
		end
		text = text .. line .. "  " .. spell.words .. " - " .. spell.name .. " : " .. spell.mana .. "\n"
	end


	player:showTextDialog(item:getId(), text)
	return true
end

 

Compartilhar este post


Link para o post
Compartilhar em outros sites
  • 0
Eduardo Dantas    23
Eduardo Dantas

Se não funcionar, me manda o link para a base q vc usou, sem ver o código fonte e as funções não dá pra ajudar

Compartilhar este post


Link para o post
Compartilhar em outros sites
Visitante
Este tópico está impedido de receber novos posts.
Entre para seguir isso  

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×