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

Solved offline letters

whitevo

Feeling good, thats what I do.
Joined
Jan 2, 2015
Messages
3,452
Solutions
1
Reaction score
626
Location
Estonia
In LUA, how to send items directly to player depot or mailbox to players who are offline?
These items are unique.

For now I store them to global table, which will disappear on server reset. But I prefer easier solution what does not including making extra table to database.
 
https://github.com/otland/forgottenserver/blob/master/src/mailbox.cpp#L112-L122

As this section shows, sending mail through mailboxes creates a "dummy" player object for offline players. You could add a new Lua function that works the same way.
If you don't want to edit the source a possible workaround would be to place a mailbox on the map that is inaccessible to players. Let the script put the items in a parcel with a label and then put the parcel on the mailbox.
That's what I can think of, wish there is something I have overlooked.
 
https://github.com/otland/forgottenserver/blob/master/src/mailbox.cpp#L112-L122

As this section shows, sending mail through mailboxes creates a "dummy" player object for offline players. You could add a new Lua function that works the same way.
If you don't want to edit the source a possible workaround would be to place a mailbox on the map that is inaccessible to players. Let the script put the items in a parcel with a label and then put the parcel on the mailbox.
That's what I can think of, wish there is something I have overlooked.
already tried before made this thread.
mail must be moved by player.
 
:eek:
nop, gona try later today.
I just had a look and tile:queryAdd does not seem to work. What does work is item:moveTo(position).

I made this test talk action (/test Name), if you face a mailbox it sends a parcel to the player whose name matches param. Hard code the position of your "secret" mailbox and put the receiver's name instead of param. Hope that helps, obviously don't use a talkaction for the actual script.
Code:
function onSay(player, words, param)
    local pos = player:getPosition()
    pos:getNextPosition(player:getDirection())
   
    local parcel = Game.createItem(2595, 1)
    local label = parcel:addItem(2599)
    label:setAttribute(ITEM_ATTRIBUTE_TEXT, param)

    -- add your items here
    -- parcel:addItem(itemid, count) or parcel:addItemEx(item)

    parcel:moveTo(pos)
    return false
end
 
I'm curious about it..
solved?
I don't understand much what you want, you want just send some item to inbox of the player ?
 
Totally forgot about this thread xD

Yeah, solved by creating my own "mailbox".
Player receives the letter when getting online.
Code:
function checkWarMails(player)
local playerName = player:getName()
local warMailT = warMails[playerName]

    if warMailT then
        for i, mailT in pairs(warMailT) do
            local guildName = mailT.attackerGuildName
            local killAmount = mailT.kills
            local time = mailT.time
            local warzoneID = mailT.ID
           
            if time+warMailExpireTime > os.time() then
                addWarLetter(player, guildName, killAmount, warzoneID)
            end
        end
       
        warMails[playerName] = nil
    end
end
 
Back
Top