Skip to content

Return of Reckoning

Wiki

RoR Wiki

API:SendMailboxCommand

From RoR Wiki

UI Lua API · Social functions
Version: WAR 1.4.8

Sends a mailbox command to the server: send a letter, open, delete or return a message, take money or items, mark a message read or unread, or close the mailbox.

SendMailboxCommand(command, mailboxType, messageId, recipient, subject, body, value, slotIds, backpackTypes, cod)

Arguments

command
number – The command. The stock UI uses the constants in MailWindow: 0 MAILBOX_CLOSE, 1 MAILBOX_SEND, 2 MAILBOX_OPEN_MESSAGE, 3 MAILBOX_DELETE_MESSAGE, 4 MAILBOX_RETURN_MESSAGE, 5 MAILBOX_TAKE_MONEY, 6 MAILBOX_TAKE_ITEM, 7 MAILBOX_TAKE_ALL, 8 MAILBOX_MESSAGE_MARK_READ, 9 MAILBOX_MESSAGE_MARK_UNREAD.
mailboxType
number – A GameData.MailboxType value (PLAYER or AUCTION). Sent as an 8-bit value.
messageId
number – Id of the message the command applies to; 0 for send and close.
recipient
wstring – Name of the receiver (send only).
subject
wstring – Subject line (send only).
body
wstring – Message text (send only).
value
number – For send: the money attached (or asked for, with COD), in brass. For take item: the 0-based index of the attachment. Otherwise 0.
slotIds
number-table – Backpack slot numbers of the items to attach (send only); {} for none.
backpackTypes
number-table – The backpack type of each entry in slotIds, in the same order.
cod
boolean – true to send the letter cash on delivery (send only).

Returns

Nothing.

Details

  • All ten arguments must always be passed with the right types; the stock UI passes 0, L"", {} and false as fillers.
  • The client copies recipient, subject and body into buffers of 24, 30 and 300 characters.
  • Each attachment slot is converted to an inventory slot number using its backpack type. Pairing stops at the end of the shorter table.
  • Any command above 9 sends nothing.
  • If there is no player object, or the Lua state is not available, nothing is sent.
  • The function needs at least ten arguments and only reads the last ten. cod must be a real boolean.

Errors

None besides the generic Invalid Parameters message when an argument has the wrong type.

Example

Sending a letter, from default/ea_mailwindow/source/mailwindowtabsend.lua:

SendMailboxCommand(MailWindow.MAILBOX_SEND,                             -- Msg type, according to warinterface::LuaSendMailboxCommand
                   GameData.MailboxType.PLAYER,                         -- Messagebox Type
                   0,                                                   -- Message ID
                   L""..MailWindowTabSendToEditBox.Text,                -- WString for who the message is going to
                   L""..MailWindowTabSendSubjectEditBox.Text,           -- WString for the subject line
                   L""..MailWindowTabSendMessageBodyEditBox.Text,       -- WSring for the body of the message
                   money,                                               -- Total value of coins attached
                   attachmentSlotIDs,                                   -- IDs (which correspond to backpack slot #'s) of attachments
                   attachmentSlotBackpacks,                             -- Backpack types of corresponding slot ids
                   ButtonGetPressedFlag("MailWindowTabSendCODCheckBoxButton") -- COD
                   )

Taking one attachment, from default/ea_mailwindow/source/mailwindowtabmessage.lua:

-- Note: Be sure to subtract 1 from the MailWindowTabMessage.attachmentSlot since LUA is 1-based
SendMailboxCommand(MailWindow.MAILBOX_TAKE_ITEM, GameData.MailboxType.PLAYER, MailWindowTabInbox.SelectedMessageID, L"", L"", L"", MailWindowTabMessage.attachmentSlot-1, {}, {}, false )

See also