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

need a chest script

wafuboe

Member
Joined
Dec 24, 2010
Messages
881
Solutions
2
Reaction score
22
hello i need a script for chests quest so you can only pick one like annihi and poi
since my 2000aid is not working can anyone help me? ty
TFS 1.3
 
Last edited:
hello i need a script for chests quest so you can only pick one like annihi and poi
since my 2000aid is not working can anyone help me? ty
TFS 1.3
Untested, just grabbed from tfs repo and change a few things. If there's any issues let me know and I'll fix them.

Lua:
--[[
    - Set each chest with a different uid, and register them all in actions.xml
    - Give each chest the same aid and this is used for the storage value
    - Place the item you want the chest to give inside using rme, bags with items will work as well
    - This script is reusable for another quests with a different action id

    NOTE: Be careful not to use the action id elsewhere besides the quest chests
]]

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getStorageValue(item.actionid) > 0 then
        return player:sendTextMessage(MESSAGE_INFO_DESCR, "It is empty.")
    end

    local reward = item:getItem(0):clone()
    local playerCap = player:getFreeCapacity()
    local itemType = reward:getType()

    local count = reward:getCount()
    local article = count > 1 and count or "a"
    local name = count > 1 and reward:getPluralName() or itemType:getName()

    if playerCap >= reward:getWeight() then
        player:addItemEx(reward)
        player:sendTextMessage(MESSAGE_INFO_DESCR, 'You have found ' .. article .. ' ' .. name .. '.')
        player:setStorageValue(item.actionid, 1)
    else
        player:sendTextMessage(MESSAGE_INFO_DESCR, 'You have found ' .. article .. ' ' .. name .. ' weighing ' .. reward:getWeight() / 100 .. ' oz it\'s too heavy.')
    end
    return true
end
 
Last edited:
Back
Top