• 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!

Solved TFS 1.0 Forget ALL spells

Michael Orsino

Premium User
Staff member
Premium User
Support Team
Joined
Nov 15, 2007
Messages
864
Solutions
10
Reaction score
452
Location
Western Australia
Hey guys,

I'm sure I can work this one out with a bit more trial and error, but its doing my head in and some help would be appreciated!
Okay so I need a way to forget all known spells in one hit.

This is where I am at so far..

(talkaction for debug purposes)
Code:
function onSay(cid, words, param)
    local player = Player(cid)
    local count = getPlayerInstantSpellCount(cid)

    for i = 0, count - 1 do
        local spell = getPlayerInstantSpellInfo(cid, i)
        if spell.level ~= 0 then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, spell.name)
        player:forgetSpell(spell.name)   
        end
    end

    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "success")
    return true
end

The server throws the following error:
Code:
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/debugspells.lua:onSay
LuaScriptInterface::luaGetPlayerInstantSpellInfo(). Spell not found
stack traceback:
        [C]: in function 'getPlayerInstantSpellInfo'
        data/talkactions/scripts/debugspells.lua:8: in function <data/talkaction
s/scripts/debugspells.lua:1>

Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/debugspells.lua:onSay
data/talkactions/scripts/debugspells.lua:9: attempt to index local 'spell' (a bo
olean value)
stack traceback:
        [C]: in function '__index'
        data/talkactions/scripts/debugspells.lua:9: in function <data/talkaction
s/scripts/debugspells.lua:1>

The script half works at the moment..if ran a few times it will forget all the spells, i'll take another look at it after dinner anyway.
If anyone is able to help in the meantime, thanks!
 
I took another look at it after eating, this now works:
Code:
function onSay(cid, words, param)
    local player = Player(cid)
    local count = getPlayerInstantSpellCount(cid)
    local t = {}
    for i = 0, count - 1 do
        local spell = getPlayerInstantSpellInfo(cid, i)
        if spell.level ~= 0 then
            t[#t+1] = spell
        end
    end

    for i, spell in ipairs(t) do
        player:forgetSpell(spell.name)

    end
    return true
end
 
Back
Top