Am currently using the following code to build my userlist but the down side to this is it will loop names over and over making duplicate names so am having to do extra code to stop same names showing up in list so am wondering if there a more professional less resource and hassle code for building userlist for rooms or lobbys?

function TLobbyServer.GetLobbyUsers(const LobbyID: string): string;
  i: Integer;
  HostID: string;
  Result := '';
  for i := 0 to (SocketServer.ClientCount -1) do
   if (CompareText(SocketServer.Client[i].Lobby, LobbyID) = 0) then
     HostID := '';
     HostID := IntToStr(Integer(CompareText(SocketServer.Client[i].LobbyOwner, SocketServer.Client[i].Name) = 0));
     Result := Result + 'š02œ' + LobbyID + 'œ' // lobby name
        + SocketServer.Client[i].Name + 'œ' // username
        + SocketServer.Client[i].Rank + 'œ' // current user rank (paid/free/staff)
        + SocketServer.Client[i].IconNumber + 'œ' // current Icon
        + SocketServer.Client[i].BIconNumber + 'œ' // custom paid icons
        + MBoolToStr(SocketServer.Client[i].IsLAFK) + 'œ' // away from keybored user
        + HostID + 'œ' // is lobby owner
        + SocketServer.Client[i].HasTrophy + 'œ'; // has won a nice shiney trophy

thanks for the help

Rather than regularly rebuilding the list, can you maintain it? Every time a new user appears add him/her to your list, and remove them from your list when they go away?

This question has already been answered. Start a new discussion instead.