Lua functions

AddPlayerMail

Registered in this checkout as EQ2Emu_lua_AddPlayerMail; implementation found at WorldServer/Lua/LuaFunctions.cpp:14307.

Historical signature: AddPlayerMail(Spawn, FromName, SubjectName, MailBody, MailType, Copper, Silver, Gold, Platinum, ItemID, StackSize, ExpireTime, SentTime)

Parameter and behavior details in the historical explanation are under review against the current implementation.

Function: AddPlayerMail(Spawn, FromName, SubjectName, MailBody, MailType, Copper, Silver, Gold, Platinum, ItemID, StackSize, ExpireTime, SentTime)

Description: Sends a mail message to the Spawn.

Parameters:

  • Spawn: Spawn - The Spawn (Player) to send the mail.
  • FromName: string - From header name.
  • SubjectName: string - Subject header name.
  • MailBody: string - Body value.
  • MailType: UInt8 - Type of mail, 0 = Regular, 1 = Spam, 2 = GM.
  • Copper: UInt32 - Amount of copper included in the mail.
  • Silver: UInt32 - Amount of silver included in the mail.
  • Gold: UInt32 - Amount of gold included in the mail.
  • Platinum: UInt32 - Amount of platinum included in the mail.
  • ItemID: UInt32 - ItemID to provide to the Spawn in the mail.
  • StackSize: UInt16 - Quantity of the item. Zero or omission delivers one item.
  • ExpireTime: Int64 - Expiration in Unix seconds. Zero keeps the message without a scheduled expiration; negative or out-of-range values fail.
  • SentTime: Int64 - Sent time in Unix seconds. Zero or omission uses the current time; negative or out-of-range values fail. A future value stores the row now but hides it from loading until server time reaches that value.

Returns: Boolean: True after the database accepts a new mail row for the original Player. False for an invalid Player, a missing or stale connection at admission, invalid timestamps, unavailable delivery admission, or a rejected insert.

Connection lifetime: The native call retains the original Player and connection while copying the mail intent and inserting it. Online admission uses a preallocated record in that original Player's mailbox. A connection change during database work cannot redirect the row to another Player. Before insertion, the native call registers owned delivery metadata. After the database returns a new row identity, admission to the original mailbox and the commit signal require no allocating replacement-session lookup. A World-owned delivery pass then requests a reload for the current matching character session. Rejected inserts cancel the delivery metadata. An unavailable delivery queue rejects admission before insertion. A lost database response can still leave an uncertain outcome; an error is not proof that no row was stored.

Checked example

No checked example is published for this function yet. No suitable maintained runtime-script example passed the argument and source review.

Current registration: WorldServer/Lua/LuaInterface.cpp. Historical explanation: EQ2Emu Lua documentation.