• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Solved Storage with spells TFS 1.2

Aeronx

Intermediate OT User
Joined
Dec 17, 2015
Messages
746
Solutions
9
Reaction score
125
Hello everybody, and thanks for your time and help!

I've been going around this spells for some hours now, but I cant solve how to make it to set a storage and after X seconds, set another storage.

This is as far as i got:

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

local condition = Condition(CONDITION_ATTRIBUTES)
condition:setParameter(CONDITION_PARAM_TICKS, 5000)
condition:setParameter(CONDITION_PARAM_BUFF_SPELL, 1)
combat:setCondition(condition)

function setstorage(player, var)
creature:setStorageValue(8888,0)
end

function onCastSpell(creature, player, var)
    creature:setStorageValue(8888, 1)
    addEvent(setstorage, 5000)
    combat:execute(creature, var)
    creature:sendTextMessage(MESSAGE_STATUS_DEFAULT, "test")
return true
end
 
Tell us what you want the spell to do, instead of just providing a "solution" that might be really bad in this case. Also, everyone left already nobody here. Sorry :oops::oops:
 
Well, im trying by casting a spell set a storage, after 5 seconds as in the exemple, set that storage to 0.
this is what i have now: So far no errors on console, i get the storage 8888 set to 1, but after 5 seconds, buffs dissapears but i never get storage 8888 set to 0.
Code:
local function storage(cid)
     local player = Player(cid)
     if player then
          player:setStorageValue(8888, 0)
     end
end



function onCastSpell(creature, var)
    creature:setStorageValue(8888, 1)
    addEvent(storage, 5 * 1000, cid)
    combat:execute(creature, var)
    creature:sendTextMessage(MESSAGE_STATUS_DEFAULT, "test")
return true
end

BTW: where did everybody go? :/ any other forum or something? lol
 
use
Code:
addEvent(setPlayerStorageValue, 5*1000, creature, 8888, 0)
in ur first post you use creature:setStorageValue with a function that has a player argument, aka creature is never defined inside that function

in ur second exampe you call addEvent(storage,...) with cid, where cid is not defined
it would work if you changed cid to creature in ur second post i think (in the onCastSpell)
 
Now i get the storage working right, but get this error and then it crashes.

Code:
Lua Script Error: [Spell Interface]
data/spells/scripts/custom/vampiric.lua:onCastSpell
LuaScriptInterface::luaAddEvent(). Argument #3 is unsafe
stack traceback:
        [C]: in function 'addEvent'
        data/spells/scripts/custom/vampiric.lua:14: in function <data/spells/scripts/custom/vampiric.lua:11>

@tokenzz Because when the storage is active, im appling combat bonuses with another script. But the spell does only that. Set storage to 1 and after 5 seconds to 0.
 
oh shit my bad i missed that it was 1.2, thought it was 0.4
in 1.x creature/player is userdata and you need to use creature id for addEvents, ill fix it in a min
Code:
function onCastSpell(creature, var)
    local player = Player(creature)
    if player then
        setPlayerStorageValue(player.uid, 8888, 1)
        addEvent(setPlayerStorageValue, 5 * 1000, player.uid, 8888, 0)
    end
 
    combat:execute(creature, var)
    creature:sendTextMessage(MESSAGE_STATUS_DEFAULT, "test")
    return true
end
this should work

in 1.x setPlayerStorageValue(cid,...) takes creature id as argument, and onCastSpell(creature,...)
creature argument is actually userdata, so you have to use for example creature.uid to pass it to setstorage, or in this case i use Player(creature) to make sure the caster is actually a player (because there is only setPlayerStorageValue in 1.x, no setStorageValue for creatures afaik)
 
Back
Top