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

Learn spell with storage

Lopaskurwa

Well-Known Member
Joined
Oct 6, 2017
Messages
936
Solutions
2
Reaction score
57
Hello,
i have spell which i want to make it work only when you have storage 66655, basically why i need it because i have tile which gives you effect so i dont want to let cast this spell until he didnt stepped on that tile so basically if he dont have that storage it wont let you cast spell
XML:
<instant name="light" words="light" lvl="1" maglv="0" mana="20" prem="0" exhaustion="1000"  script="light.lua"></instant>
LUA:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, false)
 
local condition = Condition(CONDITION_LIGHT)
condition:setParameter(CONDITION_PARAM_LIGHT_LEVEL, 10)
condition:setParameter(CONDITION_PARAM_LIGHT_COLOR, 215)
condition:setParameter(CONDITION_PARAM_TICKS, (6 * 60 + 10) * 1000)
combat:setCondition(condition)
 
local storageLoadEffect = 66655
function onCastSpell(creature, variant)
    if combat:execute(creature, variant) then
        local loadEffect = math.max(1, creature:getStorageValue(storageLoadEffect))
        Position(creature:getPosition() + Position(1, 0, 0)):sendMagicEffect(loadEffect)
        return true
    end
    return false
end
 
Solution
Not tested.
Here is your movements script.
LUA:
---# Movement script
local effects = {
    [14724] = 93,
    [14719] = 94,
    [14720] = 82,
    [14721] = 83,
    [14722] = 95,
    [14723] = 72,
    [14725] = 84
}

local config = {
    teleport = {x=663, y=396, z=7}
}

function onStepIn(creature, item)
    if creature:isPlayer() then
        local loadEffect = effects[item:getId()]
        if loadEffect then
            creature:teleportTo(config.teleport)
            creature:sendTextMessage(MESSAGE_INFO_DESCR, 'Congratulations!')
            creature:setStorageValue(66655, loadEffect)
        end
    end
    return true
end

function onStepOut(creature, item)
    if creature:isPlayer() then
        creature:setStorageValue(66655, -1)
    end
    return true
end
...
Hello,
i have spell which i want to make it work only when you have storage 66655, basically why i need it because i have tile which gives you effect so i dont want to let cast this spell until he didnt stepped on that tile so basically if he dont have that storage it wont let you cast spell
XML:
<instant name="light" words="light" lvl="1" maglv="0" mana="20" prem="0" exhaustion="1000"  script="light.lua"></instant>
LUA:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, false)

local condition = Condition(CONDITION_LIGHT)
condition:setParameter(CONDITION_PARAM_LIGHT_LEVEL, 10)
condition:setParameter(CONDITION_PARAM_LIGHT_COLOR, 215)
condition:setParameter(CONDITION_PARAM_TICKS, (6 * 60 + 10) * 1000)
combat:setCondition(condition)

local storageLoadEffect = 66655
function onCastSpell(creature, variant)
    if combat:execute(creature, variant) then
        local loadEffect = math.max(1, creature:getStorageValue(storageLoadEffect))
        Position(creature:getPosition() + Position(1, 0, 0)):sendMagicEffect(loadEffect)
        return true
    end
    return false
end
Instead of preventing a player from casting the spell because of a storage value. Assign the spell to the player when they step on the tile.
 
Instead of preventing a player from casting the spell because of a storage value. Assign the spell to the player when they step on the tile.
Hmm?
LUA:
---# Movement script
local effects = {
    [14724] = 93,
    [14719] = 94,
    [14720] = 82,
    [14721] = 83,
    [14722] = 95,
    [14723] = 72,
    [14725] = 84
}
 
function onStepIn(creature, item)
    local config = {
        teleport = {x=663, y=396, z=7}
    }

    if not creature:isPlayer() then
        return true
    end
    local loadEffect = effects[item:getId()]
    creature:teleportTo(config.teleport)
    creature:sendTextMessage(MESSAGE_INFO_DESCR, 'Congratulations!')
    if loadEffect then
        creature:setStorageValue(66655, loadEffect)
    end
    return true
end
 
LUA:
---# Movement script
local effects = {
    [14724] = 93,
    [14719] = 94,
    [14720] = 82,
    [14721] = 83,
    [14722] = 95,
    [14723] = 72,
    [14725] = 84
}

-- place the spell names in the quotes
local spells = {
    [14724] = "",
    [14719] = "",
    [14720] = "",
    [14721] = "",
    [14722] = "",
    [14723] = "",
    [14725] = ""
}

local config = {
    teleport = {x=663, y=396, z=7}
}

function onStepIn(creature, item)
    if not creature:isPlayer() then
        return true
    end
    local itemid = item:getId()
    local spellname = spells[itemid]
    local loadEffect = effects[itemid]
    creature:teleportTo(config.teleport)
    creature:sendTextMessage(MESSAGE_INFO_DESCR, 'Congratulations!')
    if loadEffect and spellname then
        creature:setStorageValue(66655, loadEffect)
        if not creature:hasLearnedSpell(spellname) then
            creature:learnspell(spellname)
        end
    end
    return true
end
I left the storages in the script because I don't know what they're for or even if you still need them.
You can also use player:forgetSpell(spellName) to remove the spell.
 
LUA:
---# Movement script
local effects = {
    [14724] = 93,
    [14719] = 94,
    [14720] = 82,
    [14721] = 83,
    [14722] = 95,
    [14723] = 72,
    [14725] = 84
}

-- place the spell names in the quotes
local spells = {
    [14724] = "",
    [14719] = "",
    [14720] = "",
    [14721] = "",
    [14722] = "",
    [14723] = "",
    [14725] = ""
}

local config = {
    teleport = {x=663, y=396, z=7}
}

function onStepIn(creature, item)
    if not creature:isPlayer() then
        return true
    end
    local itemid = item:getId()
    local spellname = spells[itemid]
    local loadEffect = effects[itemid]
    creature:teleportTo(config.teleport)
    creature:sendTextMessage(MESSAGE_INFO_DESCR, 'Congratulations!')
    if loadEffect and spellname then
        creature:setStorageValue(66655, loadEffect)
        if not creature:hasLearnedSpell(spellname) then
            creature:learnspell(spellname)
        end
    end
    return true
end
I left the storages in the script because I don't know what they're for or even if you still need them.
You can also use player:forgetSpell(spellName) to remove the spell.
What it do not work it should not let use spell until you didnt get effect from local effects = {
 
What it do not work it should not let use spell until you didnt get effect from local effects = {
I modified the movement script so that you can assign the player a spell when they step on the tile. The whole point of this was so that you don't have to make modifications to the spell to check if the player has a storage value.

This code I don't see what the point is of it.
LUA:
        local loadEffect = math.max(1, creature:getStorageValue(storageLoadEffect))
        Position(creature:getPosition() + Position(1, 0, 0)):sendMagicEffect(loadEffect)
 
I modified the movement script so that you can assign the player a spell when they step on the tile. The whole point of this was so that you don't have to make modifications to the spell to check if the player has a storage value.

This code I don't see what the point is of it.
LUA:
        local loadEffect = math.max(1, creature:getStorageValue(storageLoadEffect))
        Position(creature:getPosition() + Position(1, 0, 0)):sendMagicEffect(loadEffect)
The point is why there is storage and etc is because when you step on tyle you get effect if you type that spell name it sends that effect, so those tiles contains different effect if you step on 4 tile that spell with send 4 tile effect.
 
Not tested.
Here is your movements script.
LUA:
---# Movement script
local effects = {
    [14724] = 93,
    [14719] = 94,
    [14720] = 82,
    [14721] = 83,
    [14722] = 95,
    [14723] = 72,
    [14725] = 84
}

local config = {
    teleport = {x=663, y=396, z=7}
}

function onStepIn(creature, item)
    if creature:isPlayer() then
        local loadEffect = effects[item:getId()]
        if loadEffect then
            creature:teleportTo(config.teleport)
            creature:sendTextMessage(MESSAGE_INFO_DESCR, 'Congratulations!')
            creature:setStorageValue(66655, loadEffect)
        end
    end
    return true
end

function onStepOut(creature, item)
    if creature:isPlayer() then
        creature:setStorageValue(66655, -1)
    end
    return true
end
and this is your spell.
LUA:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, false)

local condition = Condition(CONDITION_LIGHT)
condition:setParameter(CONDITION_PARAM_LIGHT_LEVEL, 10)
condition:setParameter(CONDITION_PARAM_LIGHT_COLOR, 215)
condition:setParameter(CONDITION_PARAM_TICKS, (6 * 60 + 10) * 1000)
combat:setCondition(condition)


local storageLoadEffect = 66655
function onCastSpell(creature, variant)
    if creature:isPlayer() then
        local value = creature:getStorageValue(storageLoadEffect)
        if value ~= -1 then
            local loadEffect = math.max(1, value)
            local pos = creature:getPosition()
            pos.x = pos.x + 1
            Position(pos):sendMagicEffect(loadEffect)
            return combat:execute(creature, variant)
        end
    end
    return false
end
 
Solution
I may be wrong, but so far, this will break your client most of the times, unless you have 66655 effects on your source.
Also, unless you use the :forgetSpell("") the spell will remain on their spellbook, the only thing is that it wont be usable.
 
Not tested.
Here is your movements script.
LUA:
---# Movement script
local effects = {
    [14724] = 93,
    [14719] = 94,
    [14720] = 82,
    [14721] = 83,
    [14722] = 95,
    [14723] = 72,
    [14725] = 84
}

local config = {
    teleport = {x=663, y=396, z=7}
}

function onStepIn(creature, item)
    if creature:isPlayer() then
        local loadEffect = effects[item:getId()]
        if loadEffect then
            creature:teleportTo(config.teleport)
            creature:sendTextMessage(MESSAGE_INFO_DESCR, 'Congratulations!')
            creature:setStorageValue(66655, loadEffect)
        end
    end
    return true
end

function onStepOut(creature, item)
    if creature:isPlayer() then
        creature:setStorageValue(66655, -1)
    end
    return true
end
and this is your spell.
LUA:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, false)

local condition = Condition(CONDITION_LIGHT)
condition:setParameter(CONDITION_PARAM_LIGHT_LEVEL, 10)
condition:setParameter(CONDITION_PARAM_LIGHT_COLOR, 215)
condition:setParameter(CONDITION_PARAM_TICKS, (6 * 60 + 10) * 1000)
combat:setCondition(condition)


local storageLoadEffect = 66655
function onCastSpell(creature, variant)
    if creature:isPlayer() then
        local value = creature:getStorageValue(storageLoadEffect)
        if value ~= -1 then
            local loadEffect = math.max(1, value)
            local pos = creature:getPosition()
            pos.x = pos.x + 1
            Position(pos):sendMagicEffect(loadEffect)
            return combat:execute(creature, variant)
        end
    end
    return false
end
Yep works perfectly.
I may be wrong, but so far, this will break your client most of the times, unless you have 66655 effects on your source.
Also, unless you use the :forgetSpell("") the spell will remain on their spellbook, the only thing is that it wont be usable.
How is that? 66655 is a storage number not a effect number
 
Back
Top