[Release]Guild Member List String Packet

12/05/2011 01:50 12k#1
Well, im sure that this isnt anything new to anyone. But every source I looked at either didnt have the packet added yet, or the member list was bugged. So I just decided to toggle with it until it was working flawlessly for me.

PHP Code:
ushort PacketLengthOffset 0
ushort PacketType
Offset 2
uint GuildID
Offset 4
byte Type
Offset //Value of 0xB for member list
byte CountOffset //How many members are being listed
For Each Member:
byte MemberStringLengthOffset 10 Current Offset
string MemberString
Offset 11 Current Offset 
Then for the member string, I use:
PHP Code:
MemberName " " MemberLevel " " + (byte)MemberOnline "\n" 
Im not 100% sure if the new line char is necessary but I stuck it there anyways haha.

#Edit: This should work for any version.
12/05/2011 02:12 BaussHacker#2
Use StringBuilder.

Code:
StringBuilder sb = new StringBuilder();
sb.Append(MemberName);
sb.Append(" ");
sb.Append(MemberLevel);
sb.Append(" ");
sb.Append(MemberOnline);
sb.Append("\n");
string MemberString = sb.ToString();
12/05/2011 02:56 12k#3
eh, either works, i was just too lazy to write all that out + add the system.text namespace.
is there a performance difference between the two methods?
12/05/2011 14:45 BaussHacker#4
Quote:
Originally Posted by 12k View Post
eh, either works, i was just too lazy to write all that out + add the system.text namespace.
is there a performance difference between the two methods?
Using string += string + string + string + string etc. will create a new string for every time, where StringBuilder writes in memory, so it's way faster and efficient and that's what you should focus at when creating a server, not if it works.
12/05/2011 14:52 Korvacs#5
Fairly certain the '\n' isn't necessary, our implementation doesn't need it.
12/07/2011 01:29 CptSky#6
Hum. Your implementation will fail for big guilds. Imagine a guild with 100+ member? Your packet will be too big... And its limit the members to 255. Not the real implementation. You need to split the members per pages.

It's not the optimal implementation, but it's the way you should do it.
Code:
Player Player = Client.User;
if (Player == null)
    return;

if (Player.Syndicate == null)
    return;

Syndicate.Info Syn = Player.Syndicate;
String[] List = Syn.GetMemberList();

if (Data == -1)
    Data = 0;

Int32 Amount = List.Length - (Data * 10);
if (Amount > 10)
    Amount = 10;

String[] Tmp = new String[Amount];
Array.Copy(List, Data * 10, Tmp, 0, Amount);

Player.Send(MsgName.Create(Data + 1, Tmp, Action.MemberList));
12/07/2011 03:02 nikito157#7
hmmm i have to start learning it, i just know edit npcs, and some system


someone can say where i can start :D
12/07/2011 04:29 pro4never#8
as cpt said I'd combine the idea of using a stringbuilder with a 'sendpage' option. Tq only sends one page of members at a time and when you scroll through them it uses the page index to pull just the next... 10 entries for example to send per packet.

You would still use stringbuilder, just not clog it up with EVERY member in the entire guild.