• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[Talkaction] !spell command?

flaxe

the one and only
Joined
Jun 12, 2009
Messages
336
Reaction score
2
Location
Sweden
Hello, I would like to have a !spell command that shows you a list of all spells that you have. If possible it would be good if it could synchronise with the spellbook :p Hope you understand what I mean, thanks.
 
You can look at actions/scripts/other/spellbook.lua, and try to make from it talkaction. Its really easy believe me! ;) I hope you can do it yourself.
 
thats spellbook.lua i dont think so he can just simple make it talkaction...
Lua:
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
 
thats spellbook.lua i dont think so he can just simple make it talkaction...
Lua:
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

Just need to replace:

function onUse(cid, item, fromPosition, itemEx, toPosition)

to

function onSay(cid, words, param)

and

doShowTextDialog(cid, item.itemid, text)

to

doShowTextDialog(cid, 2160, text)

finito!
 
I cant understand anything :D I guess this is to complicated for me if you dont make it for me or if you dont explain where to write it all.. ^^
 
1. Copy all what Wiw3K posted, place it, for example in talkactions/scripts/spellbook.lua

2. Replace in this script all what I said in previous post.

3. Now in talkactions.xml add:
Code:
<talkaction words="!spells" script="spellbook.lua"/>

I can't describe it simpler :thumbup:
 
PHP:
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

save it as Spells.lua

works for tfs 0.3+ 99% sure :p

PHP:
<talkaction words="!spells" event="script" value="spells.lua"/>
 
1. Copy all what Wiw3K posted, place it, for example in talkactions/scripts/spellbook.lua

2. Replace in this script all what I said in previous post.

3. Now in talkactions.xml add:
Code:
<talkaction words="!spells" script="spellbook.lua"/>

I can't describe it simpler :thumbup:

Thank you ;) I thought that I had to write all the spell names and such in the script -.- But nowadays everything goes automaticly in scripts, I think i'm too old for the new generation :D ^^

And Anco, since the one that Wiw3k worked perfectly I will use it, but thanks for your post anyways! Or is there any difference between those 2 scripts? If it is I maybe should use yours Anco.

And again. thanks
 
The script that Wiw3k posted is a normal spell book script aka Actions OnUse


so if you want like !spells aka talkactions then use the script i posted above.
 
Hm ok.. but I tested your script, and it was no difference between them :/ I still got up the spellbook window when I wrote !spells
 
How could you use his script when its OnUse which is actions and not talkaction? that's impossible lol

if u used his script and talkactions you would get error lol
 
ah, next time you could inform me about that lol

had no idea you've changed the lines that slawkens said, then the scripts are same.

lol
 
PHP:
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

save it as Spells.lua

works for tfs 0.3+ 99% sure :p

PHP:
<talkaction words="!spells" event="script" value="spells.lua"/>
Thanks ! =P
 
Back
Top