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

MoveEvent [Events][TFS 1.X] Runes backpack Medivia-styled

Fresh

Quack!
Joined
Oct 21, 2009
Messages
1,837
Solutions
18
Reaction score
614
Location
Poland

Runes Emblem Backpack for TFS 1.X by Fresh
Medivia like ` inspired script

TFS "tested" version:
Script tested and works on TFS 1.X (Tested on TFS 1.0)
but I think it should work on higher versions (not tested by myself)

Description "what-is-this-script" doing:

I made an simple `events` script for player.lua that allow players to use specific `emblem runes backpack` to carry runes in (only runes with specific type ex. in sudden death emblem backpack you can only put SD's).
like on preview image
Script is inspired by runes backpacks on popular server Medivia.


Preview:
NeBCinC.png


Open data/events/scripts/player.lua and paste somewhere under
Player : onMoveItem(item, count, fromPosition, toPosition) this code:​
Lua:
 -- Rune emblem system :: backpacks only for certain runes
    local runy = {
        {backpack = 23571, runes = 2287}, -- LMM
        {backpack = 24011, runes = 2285}, -- Poison Field
        {backpack = 24010, runes = 2301}, -- Fire Field
        {backpack = 23569, runes = 2311}, -- Heavy Magic Missile
        {backpack = 23570, runes = 2265}, -- Intense Healing Rune
        {backpack = 24021, runes = 2302}, -- Fireball
        {backpack = 24009, runes = 2277}, -- Energy Field
        {backpack = 24018, runes = 2261}, -- Destroy Field
        {backpack = 24025, runes = 2316}, -- Animate Dead
        {backpack = 24019, runes = 2310}, -- Desintegrate
        {backpack = 24014, runes = 2286}, -- Poison Bomb
        {backpack = 24013, runes = 2305}, -- Fire Bomb
        {backpack = 23568, runes = 2304}, -- Great Fireball
        {backpack = 24023, runes = 2290}, -- Convince Creature
        {backpack = 23575, runes = 2273}, -- Ultimate Healing Rune
        {backpack = 24024, runes = 2291}, -- Chameleon
        {backpack = 24017, runes = 2289}, -- Poison Wall
        {backpack = 23567, runes = 2313}, -- Explosion
        {backpack = 24020, runes = 2308}, -- Soulfire
        {backpack = 23573, runes = 2293}, -- Magic Wall
        {backpack = 24012, runes = 2262}, -- Energy Bomb
        {backpack = 24015, runes = 2279}, -- Energy Wall
        {backpack = 23574, runes = 2268}, -- Sudden Death Rune
        {backpack = 24016, runes = 2303}, -- Fire Wall
        {backpack = 24022, runes = 2278} -- Paralyze
    }

    if toPosition.x == CONTAINER_POSITION and toPosition.y >= 64 then
        local container = self:getContainerById(toPosition.y-64)
        for _, emblem in ipairs(runy) do
                if container:getId() == emblem.backpack then
                if item:getId() ~= emblem.runes then
                    self:sendTextMessage(MESSAGE_STATUS_SMALL, "You may carry only runes of specific type in this backpack, nothing else.")
                    return false
                end
            end
        end
    end
   -- // Rune emblem system

Make sure in events.xml you have (onMoveItem event enabled [set to 1]):
Code:
<event class="Player" method="onMoveItem" enabled="1" />

Configuration spoiler (for braindead copy-paste people who don't read the code):
In "local = runy" (table) you configure certain backpack for runes and runes for backpack :confused:;)
backpack = backpack_ID for certain runes[emblem.runes]
runes
= ID_ of rune to put into specific backpack [emblem.backpack]
Thats all,
Have fun using this script.

  • If you copy this script into other forums like `brasilian ones` please atleast insert author name..

Tag:
Specific backpack contain ONLY runes with one type
 
Last edited by a moderator:
Nice, I didn't know that there are new backpacks

They aren't on RL Tibia. The backpacks are from Medivia. I just simply write a system that allow player to put certain runes in specific backpacks. :)
 
Hello Fresh,

Thanks a lot for the contribution, the community is really needing people like you!

Kindest Regards and Best Wishes
Okke
 
It's working well. You just doesn't pass conditions since you drag it to a tile that is not a container slot.
Try to add a line that checks if toposition is backpack slot.
 
I have fixed version when I came to home I'll upload fixed script with some extra features.
Stay tuned boiiiZzz
 
is possible add 1 more type of rune in 23571backpack for example?

i tested this
Lua:
{backpack = 23571, runes = 2287,  runes = 2288 ,  runes = 2289}, -- LMM
no work perfectly :/

someone help me?
 
Here are a little better script with fixed pushing items directly on container and support multiple items:
Code:
local backpacks = {
--backpackid - id of backpack for certain items
--items - array of id of items that can be put into backpack
--    [backpackid] = {items},

    [1987] = {2148, 2152, 2160},  -- Gold Bag Test
    [23571] = {2287}, -- LMM
    [24011] = {2285}, -- Poison Field
    [24010] = {2301}, -- Fire Field
    [23569] = {2311}, -- Heavy Magic Missile
    [23570] = {2265}, -- Intense Healing Rune
    [24021] = {2302}, -- Fireball
    [24009] = {2277}, -- Energy Field
    [24018] = {2261}, -- Destroy Field
    [24025] = {2316}, -- Animate Dead
    [24019] = {2310}, -- Desintegrate
    [24014] = {2286}, -- Poison Bomb
    [24013] = {2305}, -- Fire Bomb
    [23568] = {2304}, -- Great Fireball
    [24023] = {2290}, -- Convince Creature
    [23575] = {2273}, -- Ultimate Healing Rune
    [24024] = {2291}, -- Chameleon
    [24017] = {2289}, -- Poison Wall
    [23567] = {2313}, -- Explosion
    [24020] = {2308}, -- Soulfire
    [23573] = {2293}, -- Magic Wall
    [24012] = {2262}, -- Energy Bomb
    [24015] = {2279}, -- Energy Wall
    [23574] = {2268}, -- Sudden Death Rune
    [24016] = {2303}, -- Fire Wall
    [24022] = {2278}  -- Paralyze
}

function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if(toPosition.x == 0xFFFF) then
        if(toPosition.y >= 64) then
            local container = self:getContainerById(toPosition.y-64)
            if(container) then
                local backpack = backpacks[container:getId()]
                if(backpack and not(isInArray(backpack, item:getId()))) then
                    self:sendTextMessage(MESSAGE_STATUS_SMALL, "You may carry only runes of specific type in this backpack, nothing else.")
                    return false
                else
                    local slot = toPosition.z
                    if(slot < container:getSize()) then
                        local c = container:getItem(slot)
                        if(c and c:isContainer()) then
                            backpack = backpacks[c:getId()]
                            if(backpack and not(isInArray(backpack, item:getId()))) then
                                self:sendTextMessage(MESSAGE_STATUS_SMALL, "You may carry only runes of specific type in this backpack, nothing else.")
                                return false
                            end
                        end
                    end
                end
            end
        else
            local container = self:getSlotItem(toPosition.y)
            if(container) then
                local backpack = backpacks[container:getId()]
                if(backpack and not(isInArray(backpack, item:getId()))) then
                    self:sendTextMessage(MESSAGE_STATUS_SMALL, "You may carry only runes of specific type in this backpack, nothing else.")
                    return false
                end
            end
        end
    end
    return true
end
But it still has a bug that scripts with "player:addItem" can add items to these backpacks so in my opinion it should be better added in source under "Container::queryAdd".
 
Would it be possible to use this with a server that isn't using data/event folder?

TFS 1.2 Nostalrius
Data folder looks like this:
Code:
Actions
Chatchannels
Creaturescripts
Globalevent
Items
Lib
Monster
Movement
NPC
Raids
Spells
Talkactions
World
XML
Global.lua
 
Would it be possible to use this with a server that isn't using data/event folder?

TFS 1.2 Nostalrius
Data folder looks like this:
Code:
Actions
Chatchannels
Creaturescripts
Globalevent
Items
Lib
Monster
Movement
NPC
Raids
Spells
Talkactions
World
XML
Global.lua


need add events system there.
 
i get this error on tfs 1.3
Code:
data/events/scripts/player.lua:129: attempt to index global 'toPosition' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/events/scripts/player.lua:129: in main chunk
[Warning - Events::load] Can not load script: player.lua

which code should i use instead on toPosition?
thanks
 
i get this error on tfs 1.3
Code:
data/events/scripts/player.lua:129: attempt to index global 'toPosition' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/events/scripts/player.lua:129: in main chunk
[Warning - Events::load] Can not load script: player.lua

which code should i use instead on toPosition?
thanks
you must have done something really wrong, because toPosition is already used in the default code, it shouldn't error:

 
you must have done something really wrong, because toPosition is already used in the default code, it shouldn't error:

i simply copy pasted it where it says that the code shoud be. The first line after the table is the one that is causing troubles
Code:
   if toPosition.x == CONTAINER_POSITION and toPosition.y >= 64 then
        local container = self:getContainerById(toPosition.y-64)
        for _, emblem in ipairs(runy) do
                if container:getId() == emblem.backpack then
                if item:getId() ~= emblem.runes then
                    self:sendTextMessage(MESSAGE_STATUS_SMALL, "You may carry only runes of specific type in this backpack, nothing else.")
                    return false
                end
            end
        end
    end
   -- // Rune emblem system

Lua:
function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if(toPosition.x == 0xFFFF) then
        if(toPosition.y >= 64) then
            local container = self:getContainerById(toPosition.y-64)
            if(container) then
                local backpack = backpacks[container:getId()]
                if(backpack and not(isInArray(backpack, item:getId()))) then
                    self:sendTextMessage(MESSAGE_STATUS_SMALL, "You may carry only runes of specific type in this backpack, nothing else.")
                    return false
                else
                    local slot = toPosition.z
                    if(slot < container:getSize()) then
                        local c = container:getItem(slot)
                        if(c and c:isContainer()) then
                            backpack = backpacks[c:getId()]
                            if(backpack and not(isInArray(backpack, item:getId()))) then
                                self:sendTextMessage(MESSAGE_STATUS_SMALL, "You may carry only runes of specific type in this backpack, nothing else.")
                                return false
                            end
                        end
                    end
                end
            end
        else
            local container = self:getSlotItem(toPosition.y)
            if(container) then
                local backpack = backpacks[container:getId()]
                if(backpack and not(isInArray(backpack, item:getId()))) then
                    self:sendTextMessage(MESSAGE_STATUS_SMALL, "You may carry only runes of specific type in this backpack, nothing else.")
                    return false
                end
            end
        end
    end
    return true
end
-- Rune emblem system :: backpacks only for certain runes
    local runy = {
        {backpack = 5322, runes = 3174}, -- LMM
        {backpack = 5320, runes = 3198}, -- Heavy Magic Missile
        {backpack = 5321, runes = 3152}, -- Intense Healing Rune
        {backpack = 5319, runes = 2304}, -- Great Fireball
        {backpack = 5326, runes = 3160}, -- Ultimate Healing Rune
        {backpack = 5318, runes = 3200}, -- Explosion
        {backpack = 5324, runes = 3180}, -- Magic Wall
        {backpack = 5325, runes = 3155}, -- Sudden Death Rune
 
    }

    if toPosition.x == CONTAINER_POSITION and toPosition.y >= 64 then   <<< LINE 129
        local container = self:getContainerById(toPosition.y-64)
        for _, emblem in ipairs(runy) do
                if container:getId() == emblem.backpack then
                if item:getId() ~= emblem.runes then
                    self:sendTextMessage(MESSAGE_STATUS_SMALL, "You may carry only runes of specific type in this backpack, nothing else.")
                    return false
                end
            end
        end
    end
   -- // Rune emblem system
 
@Diarreamental
This topic is little outdated because its from 2018, but I had fixed version of this script:

Lua:
    -- Rune emblem system :: backpacks only for certain runes // 
    if toPosition.x == CONTAINER_POSITION then
        local niceContainer = nil
        if toCylinder:isCreature() then
            local target = self:getSlotItem(toPosition.y)
            if target then
                niceContainer = NICE_CONTAINERS_SET[target:getId()]
            end
        else
            local target = toCylinder:getItem(toPosition.z)
            if target and target:isContainer() then
                niceContainer = NICE_CONTAINERS_SET[target:getId()]
            else
                niceContainer = NICE_CONTAINERS_SET[toCylinder:getId()]
            end
        end

        if niceContainer then
            local fit = false
            if type(niceContainer) == 'table' then
                if isInArray(niceContainer, item:getId()) then
                    fit = true
                end
            elseif item:getId() == niceContainer then
                fit = true
            end

            if not fit then
                self:sendTextMessage(MESSAGE_STATUS_SMALL, "You may carry only specific items in this backpack.")
                return false
            end
        end
    end
    -- // Rune emblem system

Try this and let me know if it's working properly now :)
 
Last edited:
Back
Top