API:InitiateTrade
From RoR Wiki
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–1to trade with the player's current target. Any other value usestargetId.- targetId
number– Object ID of the player to trade with. Ignored whenuseCurrentTargetis1.
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.Nameand 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
useCurrentTargetother than1,targetIdis used as given (cut to a 16-bit value) andGameData.Player.TradeTarget.Nameis 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
