0

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;
var
  i: Integer;
  HostID: string;
begin
  Result := '';
  for i := 0 to (SocketServer.ClientCount -1) do
  begin
   if (CompareText(SocketServer.Client[i].Lobby, LobbyID) = 0) then
   begin
     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
      end;
   end;
end;

thanks for the help

2
Contributors
2
Replies
18
Views
2 Years
Discussion Span
Last Post by Simon180
1

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.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.