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

[TFS 1.3]If you have 4 estrutuctures and and you use 12 items on each of them

Eduardo170

Well-Known Member
Joined
Jan 7, 2014
Messages
422
Solutions
3
Reaction score
66
Location
Caracas, Venezuela
Hi guys,I want to requests this. I will be working watching the scripts. I was thinking about this so many times.
TFS 1.3
8.6

Example
1.You have 4 estrutuctures and and you use 12 items on each of them
2.After doing this, when all of them have used the 12 articles in each structure, 48 items total, the teleported to a room
efR579e.png

Obelisk = item to use in estructure 8298
Inferno wall= item to use in estructure 8299
Ice wall = item to use in estructure 8302
Energy wall = item to use in estructure 8303
 
Last edited:
actions.xml
XML:
<action itemid="8298" script="other/structures/obelisk.lua" />

actions/scripts/other/structures/obelisk.lua
Lua:
local storage = {
obelisk = 119191,
inferno = 119192,
ice = 119193,
energy = 119194,
}

local tploc = Position(1000, 1000, 7) -- Location to be teleported if all of them has 12 activations CHANGE THIS

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if target.actionid == 11919 then -- action id to set to the obelisk.
print(player:getStorageValue(storage.obelisk)) -- debug to see if the storage value changes, this happens before it changes it.
    if player:getStorageValue(storage.obelisk) >= 1 then
        if player:getStorageValue(storage.obelisk) < 12 then
            item:remove()
            player:setStorageValue(storage.obelisk, player:getStorageValue(storage.obelisk) + 1)
        elseif player:getStorageValue(storage.obelisk) == 12 and player:getStorageValue(storage.inferno) == 12 and player:getStorageValue(storage.ice) == 12 and player:getStorageValue(storage.energy) == 12 then
            player:teleportTo(tploc)
        else
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Nothing happened.')
        end
    else
        item:remove()
        player:setStorageValue(storage.obelisk, 1)
    end
end
end
Its ugly as fuck, but should work.
Have no way of testing right now, so try checking it out.
I think you can figure out how to do the other 3 by using this one as a template.
 
Last edited:
actions.xml
XML:
<action itemid="8298" script="other/structures/obelisk.lua" />

actions/scripts/other/structures/obelisk.lua
Lua:
local storage = {
obelisk = 119191,
inferno = 119192,
ice = 119193,
energy = 119194,
}

local tploc = Position(1000, 1000, 7) -- Location to be teleported if all of them has 12 activations CHANGE THIS

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if target.actionid == 119190 then -- action id to set to the obelisk.
print(player:getStorageValue(storage.obelisk)) -- debug to see if the storage value changes, this happens before it changes it.
    if player:getStorageValue(storage.obelisk) >= 1 then
        if player:getStoragevalue(storage.obelisk) <= 12 then
            item:remove()
            player:setStorageValue(storage.obelisk, player:getStorageValue(storage.obelisk) + 1)
        elseif player:getStorageValue(storage.obelisk) == 12 and player:getStorageValue(storage.inferno) == 12 and player:getStorageValue(storage.ice) == 12 and player:getStorageValue(storage.energy) == 12 then
            player:teleportTo(tploc)
        else
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Nothing happened.')
        end
    else
        item:remove()
        player:setStorageValue(storage.obelisk, 1)
    end
Its ugly as fuck, but should work.
Have no way of testing right now, so try checking it out.
I think you can figure out how to do the other 3 by using this one as a template.
It was to use item, example: like a ruby(configurable)on top of the obelisk xD. Sorry, my english is a shit.
 
Yeah, and where the actions.xml is thats where you change it to an item that you want to use.

So its right click on the item you want to use, then click on obelisk.
and thats exactly what I made
 
Yeah, and where the actions.xml is thats where you change it to an item that you want to use.

So its right click on the item you want to use, then click on obelisk.
and thats exactly what I made
it needed an
Code:
end
doesn't work you use 1 item and when you use the second item. I get
Code:
 storage nil value
 
Okay this code is actually semi hard to make. In the sense that you have to make it so the code knows how to check if all 12 items have been used and they cannot reuse items, ect. We have to keep it all in the database in-case the server resets or something while the player is trying to get all the items.

This is a base, it should work. Let me know if it doesn't.

Code:
-- I can add a lot more to this code if you want, just pm me and I will give you some ideas.

local oblisks = {
    -- [ObliskID] = {aid = from, to}, items = {12 items} --
    -- It is set up like this so we can save the items the player has used in the database.
    -- If we don't do this we cannot stop the player from using the same item over and over 12 times.
    [1] = {aid = {from = 11900, to = 11911}, items = {1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111}},
    [2] = {aid = {from = 11912, to = 11923}, items = {1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111}},
    [3] = {aid = {from = 11924, to = 11935}, items = {1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111}},
    [4] = {aid = {from = 11936, to = 11947}, items = {1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111}}
}

local mainStorages = { -- This is used so we can remove all the storages that were needed to keep items saved in database.
-- This will make it so when a player has all items for an oblisk it will remove all 12 storages and save 1 that it can use to understand the player has all the items.
-- [ObliskID] = randomStorageValue
    [1] = 11940,
    [2] = 11941,
    [3] = 11942,
    [4] = 11943
}

local MESSAGETYPE = MESSAGE_STATUS_CONSOLE_ORANGE
local MESSAGESUCCESS = "You have sacrificed your item to the gods."

local teleportPos = Position(1000, 1000, 7)

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local TARGET = oblisks[target.itemid]
    
    if not TARGET then return player:sendCancelMessage("Nothing interesting happened.") end
    
    if TARGET.actionid == 0 then return player:sendCancelMessage("Nothing interesting happened.") end
    
    if not isInArray(TARGET.items, item.itemid) then return player:sendCancelMessage("Nothing interesting happened.") end
    
    local MAINSTORAGE = mainStorages[target.itemid]
    
    if not MAINSTORAGE then return false end
    
    local continue = true
    
    for i = TARGET.aid.from, TARGET.aid.to do
        if player:getStorageValue(i) == item.itemid then
            continue = false
            break
        end
    end
    
    if not continue then return player:sendCancelMessage("You have already sacrificed this item.") end
    
    if continue then
        for i = TARGET.aid.from, TARGET.aid.to do
            if player:getStorageValue(i) == -1 then
                player:setStorageValue(i, item.itemid)
                break
            end
        end
    player:removeItem(item.uid, 1)
    player:sendTextMessage(MESSAGETYPE, MESSAGESUCCESS)
    
    local continue2 = true
    
    for i = TARGET.aid.from, TARGET.aid.to do
        if player:getStorageValue(i) == -1 then
            continue2 = false
            break
        end
    end
        
    if continue2 then
        
    for i = TARGET.aid.from, TARGET.aid.to do
        player:setStorageValue(i, -1)
    end
    
    player:setStorageValue(MAINSTORAGE, 1)
        
        
    local teleportPlayer = true
    for i, v in ipairs(mainStorages) do
        if player:getStorageValue(v) == -1 then
            teleportPlayer = false
            break
        end
    end
        
    if teleportPlayer then
        player:teleportTo(teleportPos)
    end
    end
    end
return true
end
 
Last edited:
Okay this code is actually semi hard to make. In the sense that you have to make it so the code knows how to check if all 12 items have been used and they cannot reuse items, ect. We have to keep it all in the database in-case the server resets or something while the player is trying to get all the items.

This is a base, it should work. Let me know if it doesn't.

Code:
-- I can add a lot more to this code if you want, just pm me and I will give you some ideas.

local oblisks = {
    -- [ObliskID] = {aid = from, to}, items = {12 items} --
    -- It is set up like this so we can save the items the player has used in the database.
    -- If we don't do this we cannot stop the player from using the same item over and over 12 times.
    [1] = {aid = {from = 11900, to = 11911}, items = {1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111}},
    [2] = {aid = {from = 11912, to = 11923}, items = {1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111}},
    [3] = {aid = {from = 11924, to = 11935}, items = {1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111}},
    [4] = {aid = {from = 11936, to = 11947}, items = {1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111}}
}

local mainStorages = { -- This is used so we can remove all the storages that were needed to keep items saved in database.
-- This will make it so when a player has all items for an oblisk it will remove all 12 storages and save 1 that it can use to understand the player has all the items.
-- [ObliskID] = randomStorageValue
    [1] = 11940,
    [2] = 11941,
    [3] = 11942,
    [4] = 11943
}

local MESSAGETYPE = MESSAGE_STATUS_CONSOLE_ORANGE
local MESSAGESUCCESS = "You have sacrificed your item to the gods."

local teleportPos = Position(1000, 1000, 7)

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local TARGET = oblisks[target.itemid]

    if not TARGET then return player:sendCancelMessage("Nothing interesting happened.") end

    if TARGET.actionid == 0 then return player:sendCancelMessage("Nothing interesting happened.") end

    if not isInArray(TARGET.items, item.itemid) then return player:sendCancelMessage("Nothing interesting happened.") end

    local MAINSTORAGE = mainStorages[target.itemid]

    if not MAINSTORAGE then return false end

    local continue = true

    for i = TARGET.aid.from, TARGET.aid.to do
        if player:getStorageValue(i) == item.itemid then
            continue = false
            break
        end
    end

    if not continue then return player:sendCancelMessage("You have already sacrificed this item.") end

    if continue then
        for i = TARGET.aid.from, TARGET.aid.to do
            if player:getStorageValue(i) == -1 then
                player:setStorageValue(i, item.itemid)
                break
            end
        end
    player:removeItem(item.uid, 1)
    player:sendTextMessage(MESSAGETYPE, MESSAGESUCCESS)

    local continue2 = true

    for i = TARGET.aid.from, TARGET.aid.to do
        if player:getStorageValue(i) == -1 then
            continue2 = false
            break
        end
    end

    if continue2 then

    for i = TARGET.aid.from, TARGET.aid.to do
        player:setStorageValue(i, -1)
    end

    player:setStorageValue(MAINSTORAGE, 1)


    local teleportPlayer = true
    for i, v in ipairs(mainStorages) do
        if player:getStorageValue(v) == -1 then
            teleportPlayer = false
            break
        end
    end

    if teleportPlayer then
        player:teleportTo(teleportPos)
    end
    end
    end
return true
end
it just let me use 1 item and when you use not remove any item.
example:
1 energy soil on obelisk.
1 natural soil on mossy stone.
1 iced soil on blue shrine stone.
1 glimmering soil on red shrine stone.
and then is teleported to me.

Code:
You have sacrificed your item to the gods.
after you use 1 item
Code:
You have already sacrificed this item.







This is actually the script.
Code:
    <action itemid="8298" script="obelisk.lua" />
    <action itemid="8299" script="obelisk.lua" />
    <action itemid="8302" script="obelisk.lua" />
    <action itemid="8303" script="obelisk.lua" />
Code:
-- I can add a lot more to this code if you want, just pm me and I will give you some ideas.

local oblisks = {
    -- [ObliskID] = {aid = from, to}, items = {12 items} --
    -- It is set up like this so we can save the items the player has used in the database.
    -- If we don't do this we cannot stop the player from using the same item over and over 12 times.
    [1560] = {aid = {from = 11920, to = 11923}, items = {8299, 8299, 8299, 8299, 8299, 8299, 8299, 8299, 8299, 8299, 8299, 8299}},
    [1354] = {aid = {from = 11920, to = 11923}, items = {8302, 8302, 8302, 8302, 8302, 8302, 8302, 8302, 8302, 8302, 8302, 8302}},
    [1355] = {aid = {from = 11920, to = 11923}, items = {8303, 8303, 8303, 8303, 8303, 8303, 8303, 8303, 8303, 8303, 8303, 8303}},
    [1353] = {aid = {from = 11920, to = 11923}, items = {8298, 8298, 8298, 8298, 8298, 8298, 8298, 8298, 8298, 8298, 8298, 8298}}
}

local mainStorages = { -- This is used so we can remove all the storages that were needed to keep items saved in database.
-- This will make it so when a player has all items for an oblisk it will remove all 12 storages and save 1 that it can use to understand the player has all the items.
-- [ObliskID] = randomStorageValue
    [1560] = 11940,
    [1354] = 11941,
    [1355] = 11942,
    [1353] = 11943
}

local MESSAGETYPE = MESSAGE_STATUS_CONSOLE_ORANGE
local MESSAGESUCCESS = "You have sacrificed your item to the gods."

local teleportPos = Position(1000, 1000, 7)

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local TARGET = oblisks[target.itemid]
  
    if not TARGET then return player:sendCancelMessage("Nothing interesting happened.") end
  
    if TARGET.actionid == 0 then return player:sendCancelMessage("Nothing interesting happened.") end
  
    if not isInArray(TARGET.items, item.itemid) then return player:sendCancelMessage("Nothing interesting happened.") end
  
    local MAINSTORAGE = mainStorages[target.itemid]
  
    if not MAINSTORAGE then return false end
  
    local continue = true
  
    for i = TARGET.aid.from, TARGET.aid.to do
        if player:getStorageValue(i) == item.itemid then
            continue = false
            break
        end
    end
  
    if not continue then return player:sendCancelMessage("You have already sacrificed this item.") end
  
    if continue then
        for i = TARGET.aid.from, TARGET.aid.to do
            if player:getStorageValue(i) == -1 then
                player:setStorageValue(i, item.itemid)
                break
            end
        end
    player:removeItem(item.uid, 1)
    player:sendTextMessage(MESSAGETYPE, MESSAGESUCCESS)
  
    local continue2 = true
  
    for i = TARGET.aid.from, TARGET.aid.to do
        if player:getStorageValue(i) == -1 then
            continue2 = false
            break
        end
    end
      
    if continue2 then
      
    for i = TARGET.aid.from, TARGET.aid.to do
        player:setStorageValue(i, -1)
    end
  
    player:setStorageValue(MAINSTORAGE, 1)
      
      
    local teleportPlayer = true
    for i, v in ipairs(mainStorages) do
        if player:getStorageValue(v) == -1 then
            teleportPlayer = false
            break
        end
    end
      
    if teleportPlayer then
        player:teleportTo(teleportPos)
    end
    end
    end
return true
end
 
Last edited:
Okay I didn't unstand exactly what you wanted. I will create a new code for this.


USE THIS CODE
Code:
local oblisks = {
    [1560] = {storage = 11920, item = 8299, magicEffect = 12},
    [1354] = {storage = 11921, item = 8302, magicEffect = 13},
    [1355] = {storage = 11922, item = 8303, magicEffect = 14},
    [1353] = {storage = 11923, item = 8298, magicEffect = 15}
}

local storages = {11920, 11921, 11922, 11923}
local itemsRequied = 12

local MESSAGETYPE = MESSAGE_STATUS_CONSOLE_ORANGE

local teleportPos = Position(1000, 1000, 7)
local teleportMessage = "You have added all items needed for each oblisk. You have been teleported to..."

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local TARGET = oblisks[target.itemid]
    
    if not TARGET then return player:sendCancelMessage("Nothing interesting happened.") end
    
    if TARGET.actionid == 0 then return player:sendCancelMessage("Nothing interesting happened.") end
    
    if item.itemid ~= TARGET.item then return player:sendCancelMessage("Nothing interesting happened.") end
    
    if player:getStorageValue(TARGET.storage) == -1 then
        player:setStorageValue(TARGET.storage, 0)
    end
    
    if player:getStorageValue(TARGET.storage) < itemsRequied then
        player:removeItem(item.uid, 1)
        player:setStorageValue(TARGET.storage, player:getStorageValue(TARGET.storage) + 1)
            if player:getStorageValue(TARGET.storage) < itemsRequied then
                local left = itemsRequied - player:getStorageValue(TARGET.storage)
                player:sendTextMessage(MESSAGETYPE, "You have added your item to the oblisk. You need to add"..left.." more.")
                toPosition():sendMagicEffect(TARGET.magicEffect)
            end
    end
    
    local teleport = true
    for i = 1, #storages do
        if player:getStorageValue(storages[i]) ~= itemsRequied then
            teleport = false
            break
        end
    end
    
    if teleport then
        player:teleportTo(teleportPos)
        teleportPos:sendMagicEffect(CONST_ME_TELEPORT)
        player:sendTextMessage(MESSAGETYPE, teleportMessage)
        for i = 1, #storages do
            player:setStorageValue(storages[i], 0)
        end
    end
return true
end
 
Last edited:
Back
Top