• 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.X+ Use item with uid x set storage id x

Raikou

Well-Known Member
Joined
Jul 18, 2007
Messages
145
Solutions
2
Reaction score
54
I'm trying to do something simple, so at least i think. But can't get it to work.
I have an item(book) with uid 6600, as soon as a player reads(use) it player.storage 6600 needs to be set.

I thought I could do this with actionid 15000 (the standard reward box thing) but then I can't use the book anymore.
 
Solution
Try
actions/actions.xml
XML:
<action itemid="ITEM ID GOES HERE" script="myBook.lua"/>

actions/scripts/myBook.lua
Lua:
function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
    local player = Player(cid)
    if not player then
        return true
    end
    
    if player:getStorageValue(6600) ~= 1 then
        player:setStorageValue(6600, 1)
    end
    
    return true
end
Try
actions/actions.xml
XML:
<action itemid="ITEM ID GOES HERE" script="myBook.lua"/>

actions/scripts/myBook.lua
Lua:
function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
    local player = Player(cid)
    if not player then
        return true
    end
    
    if player:getStorageValue(6600) ~= 1 then
        player:setStorageValue(6600, 1)
    end
    
    return true
end
 
Solution
Lua:
function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
    local player = Player(cid)
    if not player then
        return true
    end
    
    if player:getStorageValue(item.uid) ~= 1 then
        player:setStorageValue(item.uid, 1)
    end
    
    return true
end

I turned it a bit so it will be multi usable. But yes your code works. :)
 
Back
Top