Skip to content
Next Next commit
Fix: It possible KeyAlreadyExistException workarounded
It apparently is possible to have 2 Players with Same Steam ID but different Serial ID. Cause unknown.

For both of them the same Identity ID is looked up because that ignores the Serial ID. And therefore I can just replace the value.

Could auso check with if(!containsKey) but since the result will be identical I didn't bother.
  • Loading branch information
LordTylus committed Dec 29, 2023
commit c76055de6b7a0e03f3561a2dff38e2f2c1fad3f1
12 changes: 11 additions & 1 deletion Essentials/Commands/EcoModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,19 @@ public void EcoTop() {
ecodata.AppendLine("Summary of balanaces accross the server");
Dictionary<ulong, long> balances = new Dictionary<ulong, long>();
foreach (var p in MySession.Static.Players.GetAllPlayers()) {

long IdentityID = MySession.Static.Players.TryGetIdentityId(p.SteamId);
long balance = MyBankingSystem.GetBalance(IdentityID);
balances.Add(p.SteamId, balance);

/*
* Add or Update. We have seen that it is possible to have
* two players with the same SteamID but different SerialIDs.
*
* Those also had different identities. But one of which was dead.
* TryGetIdentityId() Returned the same value in both cases. So no damage done if
* Value is just overwritten.
*/
balances[p.SteamId] = balance;
}
var sorted = balances.OrderByDescending(x => x.Value).ThenBy(x => x.Key);
foreach (var value in sorted) {
Expand Down