Complete re-write, code refactoring, performance enhancing.
CONFIG FILE HAS CHANGED!
I will not lie, this is very different from a code perspective so please don't get upset about bugs we will fix them if any arise. I have done a ton of testing and it all seems to work well. If you have major issues just go back to the old version and help me fix it. Thanks!!
CHANGES:
Added the ability to save groups and players. So the plugin works the same where it only shows players online but if you leave the game and rejoin you are still in the same group.
Added Ban List for if you leave a group or are kicked and want to try and rejoin it (config option)
I added custom chat tags, colors, logos, and group names.
I added an Onscreen UI Menu button.. (see image below) ->> can be disabled in config.
The names and logos don'y really have any purpose within LFG but I am actually use it in other plugins to render group images within UI and such (attaching a picture to show how that can work).
I added LustyMap support so group members see each-other on the map.
Added a BetterChat hook to ensure you don't get double chat messages when talking within group private chat.
Added several APIs for plugin development.
When a player creates a group or becomes the leader they are given instructions for changing the group variables stated above. For the purpose of this post they are as follows:
/lfg name <type name - can include spaces>
/lfg logo <image url>
/lfg tag <chat tag max 5 characters>
/lfg color <color> --> if wrong color is typed it provides a list of acceptable colors
API HOOKS ADDED:
C#:
[HookMethod("GetGroupInfo")]
object GetGroupInfo(ushort ID, string request)
{
if (ID == 0 || !data.SavedGroups.ContainsKey(ID)) return false;
switch (request.ToLower())
{
case "name":
return data.SavedGroups[ID].GroupName;
case "logo":
return data.SavedGroups[ID].logo;
case "tag":
return data.SavedGroups[ID].tag;
case "color":
return data.SavedGroups[ID].color;
case "members":
return data.SavedGroups[ID].Members;
case "leader":
return data.SavedGroups[ID].Leader;
default:
return false;
}
}
[HookMethod("GetPlayerGroup")]
ushort GetPlayerGroup(ulong id)
{
if (data.PlayerGroup.ContainsKey(id))
return data.PlayerGroup[id].ActiveGroup;
return 0;
}
[HookMethod("GetGroupLeader")]
BasePlayer GetGroupLeader(ushort groupId)
{
if (ActiveGroups.ContainsKey(groupId))
return ActiveGroups[groupId].OnlineMembers.Where(k=>k.userID == ActiveGroups[groupId].groupData.Leader).Select(k=>k).FirstOrDefault();
return null;
}
[HookMethod("GetLeaderDisplayName")]
string GetLeaderDisplayName(ushort groupId)
{
if (ActiveGroups.ContainsKey(groupId))
return GetDisplayName(ActiveGroups[groupId].groupData.Leader);
return "UNKNOWN";
}
[HookMethod("isGroup")]
bool isGroup(ushort groupId)
{
if (data.SavedGroups.ContainsKey(groupId)) return true;
return false;
}
[HookMethod("BroadcastGroup")]
void BroadcastGroup(string msg, ushort groupId)
{
if (!ActiveGroups.ContainsKey(groupId)) return;
foreach (var entry in ActiveGroups[groupId].OnlineMembers)
OnScreen(entry, msg);
}