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

How to check Storage in movevent event="AddItem"

lucastiond

New Member
Joined
Jul 14, 2013
Messages
35
Reaction score
0
Hello guys.

I would like to know how can I check if a player have one storage value in an onAddItem function.
I'm using tfs 1.2

My script is like this:

Code:
local trees = {Position(33205, 32537, 6)}

function onAddItem(moveitem, tileitem, position)
    if moveitem.itemid ~= 2419 then
        return true
    end


    for i = 1, #trees do
        local scimitarItem = Tile(trees):getItemById(2419)
        local scimitarItem2 = Tile(trees):getItemById(5858)

        if not scimitarItem2 and Game.getStorageValue(46140) == 1 then
            Game.createItem(5858, 1, Position(33205, 32537, 6))
            trees:sendMagicEffect(CONST_ME_MAGIC_BLUE)
            scimitarItem:remove()
        end
    end
    return true
end

The problem is that i can't get this "getStorageValue" function to work.

Thanks for your time.
 
Last edited by a moderator:
Hello guys.

I would like to know how can I check if a player have one storage value in an onAddItem function.
I'm using tfs 1.2

My script is like this:

local trees = { Position(33205, 32537, 6)}


function onAddItem(moveitem, tileitem, position)
if moveitem.itemid ~= 2419 then
return true
end


for i = 1, #trees do
local scimitarItem = Tile(trees):getItemById(2419)
local scimitarItem2 = Tile(trees):getItemById(5858)

if not scimitarItem2 and Game.getStorageValue(46140) == 1 then
Game.createItem(5858, 1, Position(33205, 32537, 6))
trees:sendMagicEffect(CONST_ME_MAGIC_BLUE)
scimitarItem:remove()
end
end
return true
end


The problem is that i can't get this "getStorageValue" function to work.

Thanks for your time.
where are you even using this script?
in 1.2 the moveitem script should be in events/scripts/player.lua (@Player : onMoveItem)
to check storage value there, use the keyword self since that's the object of the method (Player)
self:getStorageValue
 
where are you even using this script?
in 1.2 the moveitem script should be in events/scripts/player.lua (@Player : onMoveItem)
to check storage value there, use the keyword self since that's the object of the method (Player)
self:getStorageValue

I think he wants to check a global storage value. (If I am understanding him correctly)
 
I think he wants to check a global storage value. (If I am understanding him correctly)
oh oops i didnt even read the code, probably should have

Game.getStorageValue(key)
Game.setStorageValue(key, value)

it should work if you set the same key to value 1 and get it afterwards
 
I did what you are suggesting Xeraphus, but it doesn't work.

I checked if Game.getStorageValue(46140) == 1 , but nothing happens. When I test it in the game, i am able to do the script without the storage.

What I am trying to do, as the script suggests, is to create the item with id 5858 on the given position when i put a scimitar on the tile. I am able to do that, but not checking the player storageValue.
 
I want to check the player storage value. I thought that if i used the "game." function it would work, but I was wrong.

I tried to do that @Beto06 but i get this error: attempt to index global 'self' (a nil value).

I am trying to do this at movements scripts, so i am using function onAddItem(moveitem, tileitem, position)
 
I want to check the player storage value. I thought that if i used the "game." function it would work, but I was wrong.

I tried to do that @Beto06 but i get this error: attempt to index global 'self' (a nil value).

I am trying to do this at movements scripts, so i am using function onAddItem(moveitem, tileitem, position)
if you're wanting to check player storage value, use the method i said in the first post i made
 
Back
Top