Skip to content

Return of Reckoning

Wiki

RoR Wiki

API:InitiateTrade

From RoR Wiki
Revision as of 19:45, 16 October 2026 by Maintenance script (talk | contribs) (UI Lua API import (WAR 1.4.8))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

UI Lua API · Trade functions
Version: WAR 1.4.8

Asks the server to open a trade with the current target or with a given player.

InitiateTrade(useCurrentTarget, targetId)

Arguments

useCurrentTarget
number – 1 to trade with the player's current target. Any other value uses targetId.
targetId
number – Object ID of the player to trade with. Ignored when useCurrentTarget is 1.

Returns

Nothing.

Details

  • With useCurrentTarget = 1:
    • If there is no current target, nothing happens.
    • If the target's ID is not valid, nothing happens.
    • Otherwise the target's name is written to GameData.Player.TradeTarget.Name and the target's ID is used.
  • The chosen ID is stored as the current trade partner, and a "start trade" status is sent to the server. ChangeTrade, AcceptTrade and CancelTrade all use this stored partner.
  • With useCurrentTarget other than 1, targetId is used as given (cut to a 16-bit value) and GameData.Player.TradeTarget.Name is not changed.
  • The client does not check what kind of object the target is. The server decides whether the trade can start.
  • Does nothing if the player object does not exist yet.
  • The function needs at least two arguments and only reads the last two.

Errors

None besides the generic Invalid Parameters message when an argument is not a number.

Example

From default/ea_tradewindow/source/tradewindow.lua:

if not EA_Window_Trade.TradeOpen() then
	InitiateTrade( 1, 0 )
	EA_Window_Trade.RefreshItemData (REFRESH_BOTH)
	EA_Window_Trade.Show()
end

See also