Skip to main content
Billable Resource
Register a trade event between Agent NPCs in your instance. Trade events represent the exchange of wealth between characters, forming the basis of your game’s economy. Each trade event specifies an amount of wealth to be transferred and the recipient Agent NPC. These transactions affect the wealth distribution in your game world and can influence the behavior and relationships between Agent NPCs.
// Set the amount to trade
double amount = 100.0;

// Register a trade event between two Agent NPCs
TradeEvent tradeEvent = PixocracySDK.AgentNPCManager().registerTradeEvent(
    instance,
    trader,      // The Agent NPC giving the wealth
    recipient,   // The Agent NPC receiving the wealth
    amount       // The amount of wealth to transfer
);

// The wealth has been transferred from the trader to the recipient
double traderNewWealth = trader.getWealth();
double recipientNewWealth = recipient.getWealth();