• 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 Spell Id Talkaction

Codinablack

Dreamer
Content Editor
Joined
Dec 26, 2013
Messages
2,124
Solutions
14
Reaction score
1,518
Location
USA
GitHub
Codinablack
Greetings again Otland. I come asking for help with a new talkaction I was trying to make and release because I need it and I believe many others will find it useful for making custom servers. Anyways I was trying to make a talkaction that creates a condition on the person using it, the condition only being spellcooldown, but also changes which spell id the spell cools you down from the number used as param in the talkaction. Sure it could be buggy if player said something different than a number, but I couldn't even get to that part, first I tried only creating the condition and using doAddCondition() but that didn't work, so then I tried setting the condition to the combat (combat turned out to be nice idea, can give an animation too) and use combat:execute(cid, cid)
but that didn't work... I suspect this is where the problem is, but I don't know how to fix this, anyone got an idea.

Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, 0)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_YELLOW_RINGS)

local cooldown = Condition(CONDITION_SPELLCOOLDOWN)
function onSay(cid, words, param)
local player = Player(cid)
    local spellid = tonumber(param)
    cooldown:setParameter(CONDITION_PARAM_SUBID, spellid)
    cooldown:setParameter(CONDITION_PARAM_TICKS, 5000)
    combat:setCondition(cooldown)
    combat:execute(cid, cid)
    -- doAddCondition(cid, cooldown)
    return false
end

when using that, I get this

Code:
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/spellid.lua:onSay
attempt to index a number value
stack traceback:
        [C]: at 0x013f3139a0
        [C]: in function 'execute'
        data/talkactions/scripts/spellid.lua:12: in function <data/talkactions/s
cripts/spellid.lua:6>
 
Nope, it's bugged, it keeps adding the icons, so each time u try a new one, the old ones and the new one shows up
It seems like each time we call combat:setCondition(cooldown), a new "instance" of the condition is added to the combat object. I haven't figured out a way to remove a condition from a Combat object or make a new "copy" of the combat object inside the function.
However, this should be sufficient in this case anyway:
Code:
local cooldown = Condition(CONDITION_SPELLCOOLDOWN)
cooldown:setParameter(CONDITION_PARAM_TICKS, 5000)

function onSay(cid, words, param)
    local player = Player(cid)
    local spellid = tonumber(param)
    cooldown:setParameter(CONDITION_PARAM_SUBID, spellid)
    player:addCondition(cooldown)
    return false
end
 
Back
Top