diff --git a/sources/Gameplay/BaseClasses/KillingFloor/Frontend/Trading/ATradingComponent.uc b/sources/Gameplay/BaseClasses/KillingFloor/Frontend/Trading/ATradingComponent.uc index 2fe9a2a..9622bac 100644 --- a/sources/Gameplay/BaseClasses/KillingFloor/Frontend/Trading/ATradingComponent.uc +++ b/sources/Gameplay/BaseClasses/KillingFloor/Frontend/Trading/ATradingComponent.uc @@ -92,6 +92,16 @@ public final function Trading_OnSelect_Slot OnTraderSelected( */ public function array GetTraders(); +/** + * Returns a trader with a given name `traderName`. + * If several traders are assigned the same name - returns any arbitrary one. + * + * @param traderName Name of the trader to return. Case-sensitive. + * @return `ETrader` with a given `traderName`. `none` if either `traderName` + * is `none` or there is no trader with such a name. + */ +public function ETrader GetTrader(Text traderName); + /** * Checks whether trading is currently active. * diff --git a/sources/Gameplay/KF1Frontend/Trading/KF1_TradingComponent.uc b/sources/Gameplay/KF1Frontend/Trading/KF1_TradingComponent.uc index a3ec4d0..d636f10 100644 --- a/sources/Gameplay/KF1Frontend/Trading/KF1_TradingComponent.uc +++ b/sources/Gameplay/KF1Frontend/Trading/KF1_TradingComponent.uc @@ -84,6 +84,26 @@ public function array GetTraders() return result; } +public function ETrader GetTrader(Text traderName) +{ + local int i; + local Text nextTraderName; + if (traderName == none) { + return none; + } + for (i = 0; i < registeredTraders.length; i += 1) + { + nextTraderName = registeredTraders[i].GetName(); + if (traderName.Compare(nextTraderName)) + { + _.memory.Free(nextTraderName); + return ETrader(registeredTraders[i].Copy()); + } + _.memory.Free(nextTraderName); + } + return none; +} + public function bool IsTradingActive() { local KFGameType kfGame;