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

Lua Reward delivery inside a bag

peteralto

Member
Joined
Nov 1, 2020
Messages
93
Solutions
1
Reaction score
17
I have a task system, and in it there is the reward of a fixed item and a random item, which are declared in a lib.

Would it be possible for these two rewards, the fixed and the random one, to be delivered inside a bag in the players depot?

Lua:
    if msgcontains(msg, "report") then
        if player:getStorageValue(DT_STORAGES.HAVE_STARTED) == 1 then
            if player:getStorageValue(DT_STORAGES.EASY) >= DT_NEEDKILL_EASY then
                npcHandler:say("Just in time! Here are your rewards, come back tomorrow for another task!", cid)
                player:setStorageValue(DT_STORAGES.HAVE_STARTED, -2)
                            
                player:addItem(DT_PREMIOFIXO_ID_EASY, DT_PREMIOFIXO_QTDE_EASY) --fixed

                if DT_PREMIOQTDE_EASY > 0 then --random
                    if DT_PREMIOQTDE_EASY == 1 then -- random
                        aa = math.random(#DT_PRIZEID_EASY)
                        player:addItem(DT_PRIZEID_EASY[aa], 1)
                    else
                        for i = 1, tonumber(DT_PREMIOQTDE_EASY) do
                            aa = math.random(#DT_PRIZEID_EASY)
                            player:addItem(DT_PRIZEID_EASY[aa], 1)
                        end
                    end
                end
            else
                npcHandler:say("You haven't finished your task yet. You still have to kill {"..DT_NEEDKILL_EASY - player:getStorageValue(DT_STORAGES.EASY) .."} "..DT_CHOSENTASK_EASY.."(s).", cid)
            end
 
Solution
E
small example:
Lua:
    local depot = player:getDepotChest(1)
    if depot then
        depot:addItem(ITEM_BAG, 1):addItem(DT_PREMIOFIXO_ID_EASY, DT_PREMIOFIXO_QTDE_EASY)
    end
small example:
Lua:
    local depot = player:getDepotChest(1)
    if depot then
        depot:addItem(ITEM_BAG, 1):addItem(DT_PREMIOFIXO_ID_EASY, DT_PREMIOFIXO_QTDE_EASY)
    end
 
Solution
small example:
Lua:
    local depot = player:getDepotChest(1)
    if depot then
        depot:addItem(ITEM_BAG, 1):addItem(DT_PREMIOFIXO_ID_EASY, DT_PREMIOFIXO_QTDE_EASY)
    end
Sorry to ask, but in this case he is inserting only one of the items inside the bag, is that it?

How could I do to including both inside bag on depot?
player:addItem(DT_PREMIOFIXO_ID_EASY, DT_PREMIOFIXO_QTDE_EASY)
player:addItem(DT_PRIZEID_EASY[aa], 1)

Thanks man!
 
Lua:
local depot = player:getDepotChest(1)
if depot then
    local bag = depot:addItem(ITEM_BAG, 1)
    bag:addItem(DT_PREMIOFIXO_ID_EASY, DT_PREMIOFIXO_QTDE_EASY)
    bag:addItem(DT_PRIZEID_EASY[aa], 1)
end

but mark EP's answer as the solution ;)
Thanks!
 
Back
Top