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 inMailWindow: 0MAILBOX_CLOSE, 1MAILBOX_SEND, 2MAILBOX_OPEN_MESSAGE, 3MAILBOX_DELETE_MESSAGE, 4MAILBOX_RETURN_MESSAGE, 5MAILBOX_TAKE_MONEY, 6MAILBOX_TAKE_ITEM, 7MAILBOX_TAKE_ALL, 8MAILBOX_MESSAGE_MARK_READ, 9MAILBOX_MESSAGE_MARK_UNREAD.- mailboxType
number– AGameData.MailboxTypevalue (PLAYERorAUCTION). 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 inslotIds, in the same order.- cod
boolean–trueto 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"",{}andfalseas fillers. - The client copies
recipient,subjectandbodyinto 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
commandabove 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.
codmust 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 )
