public void AddIgnore(uint characterId, string charName) { // Remove friend status when applying ignore if (HasFriend(characterId)) { RemoveFriend(charName); } Character_social social = new Character_social { CharacterId = _player.Info.CharacterId, DistName = charName, DistCharacterId = characterId, Friend = 0, Ignore = 1 }; CharMgr.Database.AddObject(social); _player.Info.Socials.Add(social); lock (_ignoreCharacterIds) _ignoreCharacterIds.Add(characterId, social); //CharMgr.Database.ForceSave(); SendSocialList(social, SocialListType.SOCIAL_IGNORE); _player.SendLocalizeString(charName, ChatLogFilters.CHATLOGFILTERS_SAY, Localized_text.TEXT_SN_IGNORELIST_ADD_SUCCESS); Player distPlayer = Player.GetPlayer(charName); if (distPlayer != null && distPlayer.SocInterface.HasFriend(_player.CharacterId)) { distPlayer.SocInterface.SendFriend(_player, false); } }
public void AddFriend(string Name) { Player Plr = GetPlayer(); if (Plr == null) { return; } Name = Name.ToLower(); if (Name.Length <= 0 || Name.ToLower() == Plr.Name.ToLower()) { Plr.SendLocalizeString("", GameData.Localized_text.TEXT_SN_FRIENDSLIST_ERR_ADD_SELF); return; } Character_social Social = GetSocial(Name); if (Social != null && Social.Friend > 0) { Plr.SendLocalizeString("", GameData.Localized_text.TEXT_SN_FRIENDSLIST_ERR_EXISTS); return; } Character Char = CharMgr.GetCharacter(Name); if (Char == null) { Plr.SendLocalizeString("", GameData.Localized_text.TEXT_SN_LISTS_ERR_PLAYER_NOT_FOUND); return; } EventInterface Event = null; if (Social != null) { Social.Friend = 1; CharMgr.Database.SaveObject(Social); Event = EventInterface.GetEventInterface((uint)Social.DistCharacterId); } else { Social = new Character_social(); Social.CharacterId = Plr._Info.CharacterId; Social.DistName = Char.Name; Social.DistCharacterId = Char.CharacterId; Social.Friend = 1; Social.Ignore = 0; CharMgr.Database.AddObject(Social); Event = Load(Social); } SendFriends(Social); Plr.SendLocalizeString(Char.Name, GameData.Localized_text.TEXT_SN_FRIENDSLIST_ADD_SUCCESS); }
public void SendFriends(Character_social Social) { PacketOut Out = new PacketOut((byte)Opcodes.F_SOCIAL_NETWORK); Out.WriteUInt16(0); Out.WriteByte(1); Out.WriteByte(1); Out.WriteByte(0); BuildPlayerInfo(ref Out, Social); GetPlayer().SendPacket(Out); }
public void SendSocialList(Character_social Social, SocialListType Type) { PacketOut Out = new PacketOut((byte)Opcodes.F_SOCIAL_NETWORK); Out.WriteUInt16(0); Out.WriteByte((byte)Type); Out.WriteByte(1); Out.WriteByte(0); BuildPlayerInfo(ref Out, Social); Out.WriteByte(0); _player.SendPacket(Out); }
static public void BuildPlayerInfo(ref PacketOut Out, Character_social Social) { EventInterface Interface = Social.GetEvent <EventInterface>(); if (Interface != null && Interface.HasPlayer()) { BuildPlayerInfo(ref Out, Interface.GetPlayer()); } else { BuildPlayerInfo(ref Out, (uint)Social.DistCharacterId, Social.DistName, false, 0, 0, 0); } }
public static void BuildPlayerInfo(ref PacketOut Out, Character_social Social, bool noHide = false) { var player = Player.GetPlayer(Social.DistName); BuildPlayerInfo(ref Out, Social.DistCharacterId, Social.DistName, player != null, //online (bool)(player != null ? player.SocInterface.Anon : true), //anon (byte)(player != null ? player.Level : 0), //level (ushort)(player != null ? player.Info.Career : 0), //career (ushort)(player != null ? player.Zone.ZoneId : 0), //zoneid player != null ? player.GldInterface.GetGuildName() : "", //guild noHide); }
public EventInterface Load(Character_social Social) { if (Social == null || Social.DistCharacterId == 0) { return(null); } EventInterface Interface = EventInterface.GetEventInterface((uint)Social.DistCharacterId); Interface.AddEventNotify(EventName.PLAYING, OnPlayerConnect, true); Interface.AddEventNotify(EventName.LEAVE, OnPlayerLeave, true); Social.Event = Interface; _Socials.Add(Social); return(Interface); }
public void RemoveFriend(string Name) { Log.Success("RemoveFriend", "Name=" + Name); Player Plr = GetPlayer(); if (Plr == null) { return; } Name = Name.ToLower(); Character_social Social = GetSocial(Name); if (Social == null) { Plr.SendLocalizeString("", GameData.Localized_text.TEXT_SN_LISTS_ERR_PLAYER_NOT_FOUND); return; } EventInterface Interface = Social.GetEvent <EventInterface>(); if (Interface == null) { return; } Interface.RemoveEventNotify(EventName.PLAYING, OnPlayerConnect); Interface.RemoveEventNotify(EventName.LEAVE, OnPlayerLeave); PacketOut Out = new PacketOut((byte)Opcodes.F_SOCIAL_NETWORK); Out.WriteUInt16(0); Out.WriteByte(1); Out.WriteByte(1); // Count Out.WriteByte(1); Out.WriteUInt32((uint)Social.DistCharacterId); Plr.SendPacket(Out); Plr.SendLocalizeString(Social.DistName, GameData.Localized_text.TEXT_SN_FRIEND_REMOVE); _Socials.Remove(Social); CharMgr.Database.DeleteObject(Social); }
public bool OnPlayerLeave(Object Sender, object Args) { Log.Success("OnPlayerLeave", "Name=" + Sender.Name); Player Plr = GetPlayer(); if (Plr == null) { return(false); } Character_social Social = _Socials.Find(social => social != null && social.DistName.ToLower() == Sender.Name.ToLower()); if (Social == null || Social.Friend <= 0) { return(true); } Plr.SendLocalizeString(Sender.Name, GameData.Localized_text.TEXT_SN_FRIEND_LOGOFF); SendFriend(Sender.GetPlayer(), false); return(false); }
public override bool Load() { if (Loaded) { return(base.Load()); } if (_player.Info.Socials == null) { _player.Info.Socials = new List <Character_social>(); } else { lock (_player.Info.Socials) { int socialCount = _player.Info.Socials.Count; for (int i = 0; i < socialCount; ++i) { Character_social social = _player.Info.Socials[i]; if (social.Ignore == 1) { lock (_ignoreCharacterIds) { if (_ignoreCharacterIds.ContainsKey(social.DistCharacterId)) { _player.Info.Socials.RemoveAt(i); CharMgr.Database.DeleteObject(social); --i; --socialCount; continue; } _ignoreCharacterIds.Add(social.DistCharacterId, social); } } if (social.Friend == 1) { lock (_friendCharacterIds) if (_friendCharacterIds.ContainsKey(social.DistCharacterId)) { _player.Info.Socials.RemoveAt(i); CharMgr.Database.DeleteObject(social); --i; --socialCount; continue; } _friendCharacterIds.Add(social.DistCharacterId, social); } } } } SendSocialWindowStatusFlags(); NotifyOnline(); SendSocialLists(); return(base.Load()); }
public void AddFriend(string name) { if (name.Length <= 0 || name.Equals(_player.Name, StringComparison.OrdinalIgnoreCase)) { _player.SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_USER_ERROR, Localized_text.TEXT_SN_FRIENDSLIST_ERR_ADD_SELF); return; } string charName = Player.AsCharacterName(name); uint characterId = CharMgr.GetCharacterId(charName); // Character didn't exist if (characterId == 0) { _player.SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_USER_ERROR, Localized_text.TEXT_SN_LISTS_ERR_PLAYER_NOT_FOUND); return; } // Lift any ignore when friending someone if (HasIgnore(characterId)) { RemoveIgnore(characterId, name); } // Check for existing friend lock (_friendCharacterIds) { if (_friendCharacterIds.ContainsKey(characterId)) { _player.SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_USER_ERROR, Localized_text.TEXT_SN_FRIENDSLIST_ERR_EXISTS); return; } } // Players may not add a GM as a friend unless the GM friended them first Character charInfo = CharMgr.GetCharacter(characterId, false); if (charInfo != null && _player.GmLevel == 1) { Account acct = Program.AcctMgr.GetAccountById(charInfo.AccountId); if (acct != null && acct.GmLevel > 1) { lock (charInfo.Socials) { if (!charInfo.Socials.Any(soc => soc.DistCharacterId == _player.Info.CharacterId && soc.Friend == 1)) { _player.SendClientMessage("To prevent abuse of the Friends list for staff harassment, you may not friend staff members unless they friend you first.", ChatLogFilters.CHATLOGFILTERS_CSR_TELL_RECEIVE); return; } } } } Character_social social = new Character_social { CharacterId = _player.Info.CharacterId, DistName = charName, DistCharacterId = characterId, Friend = 1, Ignore = 0 }; CharMgr.Database.AddObject(social); _player.Info.Socials.Add(social); lock (_friendCharacterIds) _friendCharacterIds.Add(characterId, social); //CharMgr.Database.ForceSave(); SendSocialList(social, SocialListType.SOCIAL_FRIEND); _player.SendLocalizeString(charName, ChatLogFilters.CHATLOGFILTERS_SAY, Localized_text.TEXT_SN_FRIENDSLIST_ADD_SUCCESS); Player distPlayer = Player.GetPlayer(name); if (distPlayer != null) { distPlayer.SendLocalizeString(_player.Name, ChatLogFilters.CHATLOGFILTERS_SAY, Localized_text.TEXT_X_FRIENDED_YOU); SendFriend(distPlayer, true); } }
public void AddFriend(string Name) { Log.Success("AddFriend", "Name=" + Name); Player Plr = GetPlayer(); if (Plr == null) return; Name = Name.ToLower(); if (Name.Length <= 0 || Name.ToLower() == Plr.Name.ToLower()) { Plr.SendLocalizeString("", GameData.Localized_text.TEXT_SN_FRIENDSLIST_ERR_ADD_SELF); return; } Character_social Social = GetSocial(Name); if (Social != null && Social.Friend > 0) { Plr.SendLocalizeString("", GameData.Localized_text.TEXT_SN_FRIENDSLIST_ERR_EXISTS); return; } Character Char = CharMgr.GetCharacter(Name); if (Char == null) { Plr.SendLocalizeString("", GameData.Localized_text.TEXT_SN_LISTS_ERR_PLAYER_NOT_FOUND); return; } EventInterface Event = null; if (Social != null) { Social.Friend = 1; CharMgr.Database.SaveObject(Social); Event = EventInterface.GetEventInterface((uint)Social.DistCharacterId); } else { Social = new Character_social(); Social.CharacterId = Plr._Info.CharacterId; Social.DistName = Char.Name; Social.DistCharacterId = Char.CharacterId; Social.Friend = 1; Social.Ignore = 0; CharMgr.Database.AddObject(Social); Event = Load(Social); } SendFriends(new List<Character_social>() { Social }); Plr.SendLocalizeString(Char.Name, GameData.Localized_text.TEXT_SN_FRIENDSLIST_ADD_SUCCESS); }
public static void BuildPlayerInfo(ref PacketOut Out, Character_social Social) { EventInterface Interface = Social.GetEvent<EventInterface>(); if (Interface != null && Interface.HasPlayer()) BuildPlayerInfo(ref Out, Interface.GetPlayer()); else BuildPlayerInfo(ref Out, (uint)Social.DistCharacterId, Social.DistName, false, 0, 0, 0); }
public EventInterface Load(Character_social Social) { if (Social == null || Social.DistCharacterId == 0) return null; EventInterface Interface = EventInterface.GetEventInterface((uint)Social.DistCharacterId); Interface.AddEventNotify("Playing", OnPlayerConnect, true); Interface.AddEventNotify("Leave", OnPlayerLeave, true); Social.Event = Interface; _Socials.Add(Social); return Interface; }
public void Load(Character_social[] Socials) { if(Socials != null) foreach (Character_social Social in Socials) Load(Social); base.Load(); Log.Success("SocialInterface", "Loaded " + _Socials.Count + " Socials of " + Obj.Oid); }