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

Recommended Answers

All 2 Replies

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?

ya thats the idea working on it now :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.