• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

Anni Quest only 1 item only help

Polarbear72

New Member
Joined
Mar 3, 2013
Messages
63
Solutions
1
Reaction score
3
Location
USA
Im trying to make Anni quest just like original where you can only get 1 item, but right now its allowing you to get all the items. How can I fix this so it shows the other chests are empty once 1 of them is looted?

I'm running TFS 1.4
 

abdala ragab

Banned User
Joined
Aug 18, 2018
Messages
308
Solutions
10
Reaction score
272
Im trying to make Anni quest just like original where you can only get 1 item, but right now its allowing you to get all the items. How can I fix this so it shows the other chests are empty once 1 of them is looted?

I'm running TFS 1.4
In actions xml
Lua:
<action uniqueid="30001" script="RARE-CHEST.lua" />
<action uniqueid="30002" script="RARE-CHEST.lua" />
<action uniqueid="30003" script="RARE-CHEST.lua" />
<action uniqueid="30004" script="RARE-CHEST.lua" />
In actions/scripts /RARE-CHEST.lua
Code:
-- annihilator chests

function onUse(cid, item, frompos, item2, topos)

       if item.uid == 30001 then
           queststatus = getPlayerStorageValue(cid,50009)
           if queststatus == -1 then
               doPlayerSendTextMessage(cid,22,"You have found a RARE-Mega Wand.")
               doPlayerAddItem(cid,7775,1)
               setPlayerStorageValue(cid,50009,1)
           else
               doPlayerSendTextMessage(cid,22,"It is empty.")
           end
       elseif item.uid == 30002 then
           queststatus = getPlayerStorageValue(cid,50009)
           if queststatus == -1 then
               doPlayerSendTextMessage(cid,22,"You have found a RARE-Mega Shot.")
               doPlayerAddItem(cid,7773,1)
               setPlayerStorageValue(cid,50009,1)
           else
               doPlayerSendTextMessage(cid,22,"It is empty.")
           end
       elseif item.uid == 30003 then
           queststatus = getPlayerStorageValue(cid,50009)
           if queststatus == -1 then
               doPlayerSendTextMessage(cid,22,"You have found a RARE-Mega Sword.")
               doPlayerAddItem(cid,7766,1)
               setPlayerStorageValue(cid,50009,1)
           else
               doPlayerSendTextMessage(cid,22,"It is empty.")
           end
       elseif item.uid == 30004 then
        queststatus = getPlayerStorageValue(cid, 50008)
        if queststatus == -1 then
               doPlayerSendTextMessage(cid,22,"You have found a Ficha.")
               doPlayerAddItem(cid,2318,1)
            setPlayerStorageValue(cid,50008,1)
           else
               doPlayerSendTextMessage(cid,22,"It is empty.")
           end
    else
        return 0
       end

       return 1
end
 

Roni123

Hardstyle Never Die < 3 !!!
Joined
Aug 31, 2010
Messages
149
Reaction score
13
This will give you a less manual job in future.
Make new file at data/actions/scripts named system.lua and paste it
Lua:
local specialQuests = {
    [20002] = 20001, -- Annihilator
    [20003] = 20001, -- Annihilator
    [20004] = 20001, -- Annihilator
}

local questsExperience = {
    [30015] = 10000
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local storage = specialQuests[item.uid]
    if(not storage) then
        storage = item.uid
        if(storage > 65535) then
            return false
        end
    end
    if(item.uid == 9008 and cid:getLevel() < 15) then
        cid:sendTextMessage(MESSAGE_INFO_DESCR, "You need level 15 to do this quest.")
        return true
    end
    if(cid:getStorageValue(storage) > 0) then
        cid:sendTextMessage(MESSAGE_INFO_DESCR, "It is empty.")
        return true
    end

    local items = {}
    local reward = 0

    local size = isContainer(item.uid) and getContainerSize(item.uid) or 0
    if(size == 0) then
        reward = doCopyItem(item, false)
    else
        for i = 0, size do
            local tmp = getContainerItem(item.uid, i)
            if(tmp.itemid > 0) then
                table.insert(items, tmp)
            end
        end
    end

    size = table.maxn(items)
    if(size == 1) then
        reward = doCopyItem(items[1], true)
    end

    local result = ""
    if reward ~= 0 then
        local ret = getItemDescriptions(reward.itemid)
        if (reward.type > 0 and isItemRune(reward.itemid)) then
            result = reward.type .. " charges " .. ret.name
        elseif(reward.type > 1 and isItemStackable(reward.itemid)) then
            result = reward.type .. " " .. ret.plural
        else
            result = ret.article .. " " .. ret.name
        end
    else
        if(size > 20) then
            reward = doCopyItem(item, false)
        elseif(size > 8) then
            reward = Game.createItem(1988, 1)
            result = "a backpack"
        else
            reward = Game.createItem(1987, 1)
            result = "a bag"
        end

        for i = 1, size do
            local tmp = doCopyItem(items[i], true)
            if(doAddContainerItemEx(reward.uid, tmp.uid) ~= RETURNVALUE_NOERROR) then
                print("[Warning] QuestSystem:", "Could not add quest reward")
            end
        end
    end

    if(doPlayerAddItemEx(cid, reward.uid, false) ~= RETURNVALUE_NOERROR) then
        if cid:getFreeCapacity() / 100 < getItemWeight(reward.uid) then
            result = "You have found a reward weighing " .. string.format("%.2f",getItemWeight(reward.uid)) .. " oz. It is too heavy."
        else
            result = "You have not enough space."
        end
    else
        result = "You have found " .. result .. "."
        cid:setStorageValue(storage, 1)
        if(questsExperience[storage] ~= nil) then
            doPlayerAddExp(cid, questsExperience[storage])
            doSendAnimatedText(cid:getPosition(), questsExperience[storage], TEXTCOLOR_WHITE)
        end
    end

    cid:sendTextMessage(MESSAGE_INFO_DESCR, result)
    return true
end

Then add into actions.xml
Lua:
<action actionid="2000" script="system.lua"/>

This works very simply in such a way that chest will give storage as 20001 after took a reward and won't allow you to take another reward.
Each chest should have actionid as 2000 and uniqueid 20002 / 20003 / 20004.

If you want to add more quests with such system then you need to make it like this:
Lua:
    [20002] = 20001, -- Annihilator
    [20003] = 20001, -- Annihilator
    [20004] = 20001, -- Annihilator
    [20006] = 20005, -- Annihilator2
    [20007] = 20005, -- Annihilator2
    [20008] = 20005, -- Annihilator2
    [20009] = 20005, -- Annihilator2
I think this should work with your OT. Good luck :)
 
Last edited:
OP
OP
P

Polarbear72

New Member
Joined
Mar 3, 2013
Messages
63
Solutions
1
Reaction score
3
Location
USA
What am I doing wrong?
XML:
    <action uniqueid="30005" script="Inq-Chest.lua" />
    <action uniqueid="30006" script="Inq-Chest.lua" />
    <action uniqueid="30007" script="Inq-Chest.lua" />
    <action uniqueid="30008" script="Inq-Chest.lua" />
    <action uniqueid="30009" script="Inq-Chest.lua" />
    <action uniqueid="30010" script="Inq-Chest.lua" />
    <action uniqueid="30011" script="Inq-Chest.lua" />
    <action uniqueid="30012" script="Inq-Chest.lua" />


Lua:
-- Inq chests

function onUse(cid, item, frompos, item2, topos)

       if item.uid == 30005 then
           queststatus = getPlayerStorageValue(cid,50008)
           if queststatus == -1 then
               doPlayerSendTextMessage(cid,22,"You have found Robe of the Underworld.")
               doPlayerAddItem(cid,8890,1)
               setPlayerStorageValue(cid,50008,1)
           else
               doPlayerSendTextMessage(cid,22,"It is empty.")
           end
       elseif item.uid == 30006 then
           queststatus = getPlayerStorageValue(cid,50008)
           if queststatus == -1 then
               doPlayerSendTextMessage(cid,22,"You have found Spellbook of Dark Mysteries.")
               doPlayerAddItem(cid,8918,1)
               setPlayerStorageValue(cid,50008,1)
           else
               doPlayerSendTextMessage(cid,22,"It is empty.")
           end
       elseif item.uid == 30007 then
           queststatus = getPlayerStorageValue(cid,50008)
           if queststatus == -1 then
               doPlayerSendTextMessage(cid,22,"You have found Master Archer's Armor.")
               doPlayerAddItem(cid,8888,1)
               setPlayerStorageValue(cid,50008,1)
           else
               doPlayerSendTextMessage(cid,22,"It is empty.")
           end
       elseif item.uid == 30008 then
        queststatus = getPlayerStorageValue(cid, 50008)
        if queststatus == -1 then
               doPlayerSendTextMessage(cid,22,"You have found a Royal Crossbow.")
               doPlayerAddItem(cid,8851,1)
            setPlayerStorageValue(cid,50008,1)
           else
               doPlayerSendTextMessage(cid,22,"It is empty.")
           end
                  if item.uid == 30009 then
           queststatus = getPlayerStorageValue(cid,50008)
           if queststatus == -1 then
               doPlayerSendTextMessage(cid,22,"You have found Fireborn Giant Armor.")
               doPlayerAddItem(cid,8881,1)
               setPlayerStorageValue(cid,50008,1)
           else
               doPlayerSendTextMessage(cid,22,"It is empty.")
           end
       elseif item.uid == 30010 then
           queststatus = getPlayerStorageValue(cid,50008)
           if queststatus == -1 then
               doPlayerSendTextMessage(cid,22,"You have found a Hellforged Axe.")
               doPlayerAddItem(cid,8924,1)
               setPlayerStorageValue(cid,50008,1)
           else
               doPlayerSendTextMessage(cid,22,"It is empty.")
           end
       elseif item.uid == 30011 then
           queststatus = getPlayerStorageValue(cid,50008)
           if queststatus == -1 then
               doPlayerSendTextMessage(cid,22,"You have found Obsidian Truncheon.")
               doPlayerAddItem(cid,8928,1)
               setPlayerStorageValue(cid,50008,1)
           else
               doPlayerSendTextMessage(cid,22,"It is empty.")
           end
       elseif item.uid == 30012 then
        queststatus = getPlayerStorageValue(cid, 50008)
        if queststatus == -1 then
               doPlayerSendTextMessage(cid,22,"You have found Emerald Sword.")
               doPlayerAddItem(cid,8930,1)
            setPlayerStorageValue(cid,50008,1)
           else
               doPlayerSendTextMessage(cid,22,"It is empty.")
           end
    else
        return 0
       end

       return 1
end



I did this with the Anni and it worked so copied pasted changed to what I needed, used AID 2000 and lined up all the UID. Now all I can do is open chest and item is sitting in it.
 

mano368

Well-Known Member
Joined
Sep 2, 2011
Messages
210
Solutions
25
Reaction score
84
Location
Brazil
What am I doing wrong?
XML:
    <action uniqueid="30005" script="Inq-Chest.lua" />
    <action uniqueid="30006" script="Inq-Chest.lua" />
    <action uniqueid="30007" script="Inq-Chest.lua" />
    <action uniqueid="30008" script="Inq-Chest.lua" />
    <action uniqueid="30009" script="Inq-Chest.lua" />
    <action uniqueid="30010" script="Inq-Chest.lua" />
    <action uniqueid="30011" script="Inq-Chest.lua" />
    <action uniqueid="30012" script="Inq-Chest.lua" />


Lua:
-- Inq chests

function onUse(cid, item, frompos, item2, topos)

       if item.uid == 30005 then
           queststatus = getPlayerStorageValue(cid,50008)
           if queststatus == -1 then
               doPlayerSendTextMessage(cid,22,"You have found Robe of the Underworld.")
               doPlayerAddItem(cid,8890,1)
               setPlayerStorageValue(cid,50008,1)
           else
               doPlayerSendTextMessage(cid,22,"It is empty.")
           end
       elseif item.uid == 30006 then
           queststatus = getPlayerStorageValue(cid,50008)
           if queststatus == -1 then
               doPlayerSendTextMessage(cid,22,"You have found Spellbook of Dark Mysteries.")
               doPlayerAddItem(cid,8918,1)
               setPlayerStorageValue(cid,50008,1)
           else
               doPlayerSendTextMessage(cid,22,"It is empty.")
           end
       elseif item.uid == 30007 then
           queststatus = getPlayerStorageValue(cid,50008)
           if queststatus == -1 then
               doPlayerSendTextMessage(cid,22,"You have found Master Archer's Armor.")
               doPlayerAddItem(cid,8888,1)
               setPlayerStorageValue(cid,50008,1)
           else
               doPlayerSendTextMessage(cid,22,"It is empty.")
           end
       elseif item.uid == 30008 then
        queststatus = getPlayerStorageValue(cid, 50008)
        if queststatus == -1 then
               doPlayerSendTextMessage(cid,22,"You have found a Royal Crossbow.")
               doPlayerAddItem(cid,8851,1)
            setPlayerStorageValue(cid,50008,1)
           else
               doPlayerSendTextMessage(cid,22,"It is empty.")
           end
                  if item.uid == 30009 then
           queststatus = getPlayerStorageValue(cid,50008)
           if queststatus == -1 then
               doPlayerSendTextMessage(cid,22,"You have found Fireborn Giant Armor.")
               doPlayerAddItem(cid,8881,1)
               setPlayerStorageValue(cid,50008,1)
           else
               doPlayerSendTextMessage(cid,22,"It is empty.")
           end
       elseif item.uid == 30010 then
           queststatus = getPlayerStorageValue(cid,50008)
           if queststatus == -1 then
               doPlayerSendTextMessage(cid,22,"You have found a Hellforged Axe.")
               doPlayerAddItem(cid,8924,1)
               setPlayerStorageValue(cid,50008,1)
           else
               doPlayerSendTextMessage(cid,22,"It is empty.")
           end
       elseif item.uid == 30011 then
           queststatus = getPlayerStorageValue(cid,50008)
           if queststatus == -1 then
               doPlayerSendTextMessage(cid,22,"You have found Obsidian Truncheon.")
               doPlayerAddItem(cid,8928,1)
               setPlayerStorageValue(cid,50008,1)
           else
               doPlayerSendTextMessage(cid,22,"It is empty.")
           end
       elseif item.uid == 30012 then
        queststatus = getPlayerStorageValue(cid, 50008)
        if queststatus == -1 then
               doPlayerSendTextMessage(cid,22,"You have found Emerald Sword.")
               doPlayerAddItem(cid,8930,1)
            setPlayerStorageValue(cid,50008,1)
           else
               doPlayerSendTextMessage(cid,22,"It is empty.")
           end
    else
        return 0
       end

       return 1
end



I did this with the Anni and it worked so copied pasted changed to what I needed, used AID 2000 and lined up all the UID. Now all I can do is open chest and item is sitting in it.
Why you use aid 2000? The script only uses uid 30005+

Remove aid from inq boxs
 

froy

Active Member
Joined
Sep 30, 2009
Messages
140
Solutions
2
Reaction score
27
Are you testing this on a gamemaster character? If so then there is your problem, gamemaster characters can loot quests multiple times.
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
6,107
Solutions
506
Reaction score
4,274
Untested, but this should work.

Lua:
--[[

    Anni-style chests.
   
    This script goes into data/scripts as a .lua file

    1) Place 2+ chests into map editor
    2) Place Same ActionId onto all chests. (example: 45000)
    3) Place UniqueId onto all chests. (example: 45001, 45002, 45003...)
    4) Update config table here, to match the chests in map editor (ActionId, UniqueId's)
    5) Update table with itemId's, count's and an unused storage number
    6) Restart Server, and test

]]--

local rewardChests = {
----[actionId] = {
----    [uniqueId] = {itemId = ####, count = #},
----    [uniqueId] = {itemId = ####, count = #},
----    [uniqueId] = {itemId = ####, count = #},
----    [uniqueId] = {itemId = ####, count = #},
----    storage = #####
----},
    [45000] = {
        [45001] = {itemId = 1111, count = 1},
        [45002] = {itemId = 1111, count = 1},
        [45003] = {itemId = 1111, count = 1},
        [45004] = {itemId = 1111, count = 1},
        storage = 45000
    },
    [45005] = {
        [45006] = {itemId = 1111, count = 1},
        [45007] = {itemId = 1111, count = 1},
        [45008] = {itemId = 1111, count = 1},
        [45009] = {itemId = 1111, count = 1},
        storage = 45005
    }
}

local anni_style_chest = Action()

function anni_style_chest.onUse(player, item, fromPosition, target, toPosition, isHotkey)

    local index = rewardChests[item:getActionId()][item:getUniqueId()]
    if not index then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Inform gamemaster of error with quest.")
        print("Error: UniqueId does not exist in table.")
        return true
    end
   
    if player:getStorageValue(index.storage) == 1 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "It is empty.")
        return true
    end

    local reward = ItemType(index.itemId)
    local rewardWeight = reward:getWeight() * index.count
    if rewardWeight > player:getFreeCapacity() then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have found a " .. reward:getName() .. " weighing " .. rewardWeight .. " oz. It's too heavy.")
        return true
    end
   
    player:addItem(index.itemId, index.count, true)
    player:setStorageValue(index.storage, 1)
   
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have found a " .. reward:getName() .. ".")
    return true
end

for v, k in pairs(rewardChests) do
    anni_style_chest:aid(v)
end
anni_style_chest:register()
 
OP
OP
P

Polarbear72

New Member
Joined
Mar 3, 2013
Messages
63
Solutions
1
Reaction score
3
Location
USA
Untested, but this should work.

Lua:
--[[

    Anni-style chests.
  
    This script goes into data/scripts as a .lua file

    1) Place 2+ chests into map editor
    2) Place Same ActionId onto all chests. (example: 45000)
    3) Place UniqueId onto all chests. (example: 45001, 45002, 45003...)
    4) Update config table here, to match the chests in map editor (ActionId, UniqueId's)
    5) Update table with itemId's, count's and an unused storage number
    6) Restart Server, and test

]]--

local rewardChests = {
----[actionId] = {
----    [uniqueId] = {itemId = ####, count = #},
----    [uniqueId] = {itemId = ####, count = #},
----    [uniqueId] = {itemId = ####, count = #},
----    [uniqueId] = {itemId = ####, count = #},
----    storage = #####
----},
    [45000] = {
        [45001] = {itemId = 1111, count = 1},
        [45002] = {itemId = 1111, count = 1},
        [45003] = {itemId = 1111, count = 1},
        [45004] = {itemId = 1111, count = 1},
        storage = 45000
    },
    [45005] = {
        [45006] = {itemId = 1111, count = 1},
        [45007] = {itemId = 1111, count = 1},
        [45008] = {itemId = 1111, count = 1},
        [45009] = {itemId = 1111, count = 1},
        storage = 45005
    }
}

local anni_style_chest = Action()

function anni_style_chest.onUse(player, item, fromPosition, target, toPosition, isHotkey)

    local index = rewardChests[item:getActionId()][item:getUniqueId()]
    if not index then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Inform gamemaster of error with quest.")
        print("Error: UniqueId does not exist in table.")
        return true
    end
  
    if player:getStorageValue(index.storage) == 1 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "It is empty.")
        return true
    end

    local reward = ItemType(index.itemId)
    local rewardWeight = reward:getWeight() * index.count
    if rewardWeight > player:getFreeCapacity() then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have found a " .. reward:getName() .. " weighing " .. rewardWeight .. " oz. It's too heavy.")
        return true
    end
  
    player:addItem(index.itemId, index.count, true)
    player:setStorageValue(index.storage, 1)
  
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have found a " .. reward:getName() .. ".")
    return true
end

for v, k in pairs(rewardChests) do
    anni_style_chest:aid(v)
end
anni_style_chest:register()


I was able to make this work for 1 quest, I copied and pasted and changed the UID and AID. There's no errors the chest just keeps telling me it's empty
Post automatically merged:

What am I missing?



Lua:
--[[

    inquistion-style chests.
   
    This script goes into data/scripts as a .lua file

    1) Place 2+ chests into map editor
    2) Place Same ActionId onto all chests. (example: 45000)
    3) Place UniqueId onto all chests. (example: 45001, 45002, 45003...)
    4) Update config table here, to match the chests in map editor (ActionId, UniqueId's)
    5) Update table with itemId's, count's and an unused storage number
    6) Restart Server, and test

]]--

local rewardChests = {
----[actionId] = {
----    [uniqueId] = {itemId = ####, count = #},
----    [uniqueId] = {itemId = ####, count = #},
----    [uniqueId] = {itemId = ####, count = #},
----    [uniqueId] = {itemId = ####, count = #},
----    storage = #####
----},
    [45030] = {
        [45031] = {itemId = 9778, count = 1},
        [45032] = {itemId = 9776, count = 1},
        [45033] = {itemId = 9777, count = 1},
        storage = 45030
    },
}

local yala_style_chest = Action()

function yala_style_chest.onUse(player, item, fromPosition, target, toPosition, isHotkey)

    local index = rewardChests[item:getActionId()][item:getUniqueId()]
    if not index then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Inform gamemaster of error with quest.")
        print("Error: UniqueId does not exist in table.")
        return true
    end
   
    if player:getStorageValue(index.storage) == 1 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "It is empty.")
        return true
    end

    local reward = ItemType(index.itemId)
    local rewardWeight = reward:getWeight() * index.count
    if rewardWeight > player:getFreeCapacity() then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have found a " .. reward:getName() .. " weighing " .. rewardWeight .. " oz. It's too heavy.")
        return true
    end
   
    player:addItem(index.itemId, index.count, true)
    player:setStorageValue(index.storage, 1)
   
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have found a " .. reward:getName() .. ".")
    return true
end

for v, k in pairs(rewardChests) do
    yala_style_chest:aid(v)
end
yala_style_chest:register()
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
6,107
Solutions
506
Reaction score
4,274
I was able to make this work for 1 quest, I copied and pasted and changed the UID and AID. There's no errors the chest just keeps telling me it's empty
Post automatically merged:

What am I missing?



Lua:
--[[

    inquistion-style chests.
  
    This script goes into data/scripts as a .lua file

    1) Place 2+ chests into map editor
    2) Place Same ActionId onto all chests. (example: 45000)
    3) Place UniqueId onto all chests. (example: 45001, 45002, 45003...)
    4) Update config table here, to match the chests in map editor (ActionId, UniqueId's)
    5) Update table with itemId's, count's and an unused storage number
    6) Restart Server, and test

]]--

local rewardChests = {
----[actionId] = {
----    [uniqueId] = {itemId = ####, count = #},
----    [uniqueId] = {itemId = ####, count = #},
----    [uniqueId] = {itemId = ####, count = #},
----    [uniqueId] = {itemId = ####, count = #},
----    storage = #####
----},
    [45030] = {
        [45031] = {itemId = 9778, count = 1},
        [45032] = {itemId = 9776, count = 1},
        [45033] = {itemId = 9777, count = 1},
        storage = 45030
    },
}

local yala_style_chest = Action()

function yala_style_chest.onUse(player, item, fromPosition, target, toPosition, isHotkey)

    local index = rewardChests[item:getActionId()][item:getUniqueId()]
    if not index then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Inform gamemaster of error with quest.")
        print("Error: UniqueId does not exist in table.")
        return true
    end
  
    if player:getStorageValue(index.storage) == 1 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "It is empty.")
        return true
    end

    local reward = ItemType(index.itemId)
    local rewardWeight = reward:getWeight() * index.count
    if rewardWeight > player:getFreeCapacity() then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have found a " .. reward:getName() .. " weighing " .. rewardWeight .. " oz. It's too heavy.")
        return true
    end
  
    player:addItem(index.itemId, index.count, true)
    player:setStorageValue(index.storage, 1)
  
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have found a " .. reward:getName() .. ".")
    return true
end

for v, k in pairs(rewardChests) do
    yala_style_chest:aid(v)
end
yala_style_chest:register()
Only way that happens is if you've used that storage value before
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
6,107
Solutions
506
Reaction score
4,274
I have no clue and I keep switching it because i was using like 45010, then went to 45020 and just keeps telling me empty
Added some prints.
Check your server log
Lua:
--[[
    
    inquistion-style chests.
    
    This script goes into data/scripts as a .lua file
    
    1) Place 2+ chests into map editor
    2) Place Same ActionId onto all chests. (example: 45000)
    3) Place UniqueId onto all chests. (example: 45001, 45002, 45003...)
    4) Update config table here, to match the chests in map editor (ActionId, UniqueId's)
    5) Update table with itemId's, count's and an unused storage number
    6) Restart Server, and test
    
]]--

local rewardChests = {
----[actionId] = {
----    [uniqueId] = {itemId = ####, count = #},
----    [uniqueId] = {itemId = ####, count = #},
----    [uniqueId] = {itemId = ####, count = #},
----    [uniqueId] = {itemId = ####, count = #},
----    storage = #####
----},
    [45030] = {
        [45031] = {itemId = 9778, count = 1},
        [45032] = {itemId = 9776, count = 1},
        [45033] = {itemId = 9777, count = 1},
        storage = 45030
    },
}

local yala_style_chest = Action()

function yala_style_chest.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    
    local index = rewardChests[item:getActionId()][item:getUniqueId()]
    if not index then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Inform gamemaster of error with quest.")
        print("Error: UniqueId does not exist in table.")
        return true
    end
    
    print("Checking storage..")
    print(index.storage)
    print(player:getStorageValue(index.storage))
    if player:getStorageValue(index.storage) == 1 then
        print("Player storage == 1. Quest has been completed before.")
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "It is empty.")
        return true
    end
    print("Player storage ~= 1. Continuing..")
    
    local reward = ItemType(index.itemId)
    local rewardWeight = reward:getWeight() * index.count
    if rewardWeight > player:getFreeCapacity() then
        print("Player does not have enough free capacity. No reward or storage given.")
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have found a " .. reward:getName() .. " weighing " .. rewardWeight .. " oz. It's too heavy.")
        return true
    end
    
    print("Player storage updated to 1. Reward given.")
    player:addItem(index.itemId, index.count, true)
    player:setStorageValue(index.storage, 1)
    
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have found a " .. reward:getName() .. ".")
    return true
end

for v, k in pairs(rewardChests) do
    yala_style_chest:aid(v)
end
yala_style_chest:register()
 
Top