need a chest script

wafuboe

Intermediate OT User
Joined
Dec 24, 2010
Messages
799
Reaction score
12
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:

Apollos

Dude who does stuff
Joined
Apr 22, 2009
Messages
562
Reaction score
338
Location
United States
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:
Top