public void AddFriend(string datas) { if (Program.GameServer.Clients.Any(x => x.Characters.Any(f => f.Name == datas))) { var charact = Program.GameServer.Clients.First(x => x.Characters.Any(f => f.Name == datas)); if (!character.NClient.Friends.Contains(charact.Infos.Pseudo)) { character.NClient.Friends.Add(charact.Infos.Pseudo); bool seeLevel = (charact.Friends.Contains(character.NClient.Infos.Pseudo) ? true : false); var packet = string.Format("{0};?;{1};{2};{3};{4};{5};{6}|", charact.Infos.Pseudo, charact.Player.Name, (seeLevel ? charact.Player.Level.ToString() : "?"), (seeLevel ? charact.Player.Faction.ID.ToString() : "-1"), charact.Player.Class.ToString(), charact.Player.Sex.ToString(), charact.Player.Skin.ToString()); character.NClient.Send(string.Concat("FAK", packet)); AccountsRequests.UpdateFriend(character.NClient.Infos.ID, charact.Infos.Pseudo, true); } else { character.NClient.Send("FAEa"); } } else { character.NClient.Send("FAEf"); } }
static void Main(string[] args) { Basic.StartTime = DateTime.Now; try { Config = Config.Get(); Loggers.InitializeLoggers(); DBHelper = new MySQLHelper(); AccountsRequests.ResetConnectedValue(); Console.Title = string.Format("{0} | Server '{1}'", string.Concat("SunDofus v", Config.Version(Assembly.GetExecutingAssembly().FullName.Split(',')[1].Replace("Version=", "").Trim())), Config.GameID); Entities.Requests.LevelsRequests.LoadLevels(); Entities.Requests.ItemsRequests.LoadItems(); Entities.Requests.ItemsRequests.LoadItemsSets(); Entities.Requests.ItemsRequests.LoadUsablesItems(); Entities.Requests.SpellsRequests.LoadSpells(); Entities.Requests.SpellsRequests.LoadSpellsToLearn(); Entities.Requests.MonstersRequests.LoadMonsters(); Entities.Requests.MonstersRequests.LoadMonstersLevels(); Entities.Requests.MapsRequests.LoadMaps(); Entities.Requests.TriggersRequests.LoadTriggers(); Entities.Requests.ZaapsRequests.LoadZaaps(); Entities.Requests.ZaapisRequests.LoadZaapis(); Entities.Requests.NoPlayerCharacterRequests.LoadNPCsAnswers(); Entities.Requests.NoPlayerCharacterRequests.LoadNPCsQuestions(); Entities.Requests.NoPlayerCharacterRequests.LoadNPCs(); Entities.Requests.BanksRequests.LoadBanks(); Entities.Requests.CharactersRequests.LoadCharacters(); Entities.Requests.GuildsRequest.LoadGuilds(); Entities.Requests.CollectorsRequests.LoadCollectors(); World.World.Save.InitSaveThread(); RealmServer = new Network.Realm.RealmServer(); RealmServer.Start(); GameServer = new Network.Game.GameServer(); GameServer.Start(); } catch (Exception error) { Console.WriteLine(error); } Console.ReadLine(); }
public void ParseCharacters() { foreach (var name in Infos.CharactersNames) { if (CharactersRequests.CharactersList.Any(x => x.Name == name)) { Characters.Add(CharactersRequests.CharactersList.First(x => x.Name == name)); } else { AccountsRequests.UpdateCharacters(Infos.ID, name, Program.Config.GameID, false); } } }
public void RemoveFriend(string datas) { var name = datas.Substring(1); if (datas.Substring(0, 1) == "*") { if (character.NClient.Friends.Contains(name)) { character.NClient.Friends.Remove(name); character.NClient.Send("FDK"); AccountsRequests.UpdateFriend(character.NClient.Infos.ID, name, true); } else { character.NClient.Send("FDEf"); } } else if (datas.Substring(0, 1) == "%") { if (Program.GameServer.Clients.Any(x => x.Characters.Any(f => f.Name == name))) { var client = Program.GameServer.Clients.First(x => x.Characters.Any(f => f.Name == name)); if (character.NClient.Friends.Contains(client.Infos.Pseudo)) { character.NClient.Friends.Remove(client.Infos.Pseudo); character.NClient.Send("FDK"); AccountsRequests.UpdateFriend(character.NClient.Infos.ID, client.Infos.Pseudo, true); } else { character.NClient.Send("FDEf"); } } else { character.NClient.Send("FDEf"); } } }
public void AddEnemy(string datas) { if (Program.GameServer.Clients.Any(x => x.Characters.Any(f => f.Name == datas))) { var charact = Program.GameServer.Clients.First(x => x.Characters.Any(f => f.Name == datas)); if (!character.NClient.Enemies.Contains(charact.Infos.Pseudo)) { character.NClient.Enemies.Add(charact.Infos.Pseudo); character.NClient.Send(string.Format("iAK{0};2;{1};36;10;0;100.FL.", charact.Infos.Pseudo, charact.Player.Name)); AccountsRequests.UpdateEnemy(character.NClient.Infos.ID, charact.Infos.Pseudo, true); } character.NClient.Send("iAEA"); } else { character.NClient.Send("FDEf"); } }
private void Disconnected() { if (Authentified == true) { AccountsRequests.UpdateConnectedValue(Infos.ID, false); if (Player != null) { Player.GetMap().DelPlayer(Player); Player.IsConnected = false; if (Player.State.OnExchange) { SunDofus.World.Exchanges.ExchangesManager.LeaveExchange(Player); } if (Player.State.OnWaitingGuild) { if (Player.State.ReceiverInviteGuild != -1 || Player.State.SenderInviteGuild != -1) { if (SunDofus.Entities.Requests.CharactersRequests.CharactersList.Any (x => x.ID == (Player.State.ReceiverInviteGuild != -1 ? Player.State.ReceiverInviteGuild : Player.State.SenderInviteGuild))) { var character = SunDofus.Entities.Requests.CharactersRequests.CharactersList.First (x => x.ID == (Player.State.ReceiverInviteGuild != -1 ? Player.State.ReceiverInviteGuild : Player.State.SenderInviteGuild)); if (character.IsConnected) { character.State.SenderInviteGuild = -1; character.State.ReceiverInviteGuild = -1; character.State.OnWaitingGuild = false; character.NClient.Send("gJEc"); } Player.State.ReceiverInviteGuild = -1; Player.State.SenderInviteGuild = -1; Player.State.OnWaitingGuild = false; } } } if (Player.State.OnWaitingParty) { if (Player.State.ReceiverInviteParty != -1 || Player.State.SenderInviteParty != -1) { if (SunDofus.Entities.Requests.CharactersRequests.CharactersList.Any (x => x.ID == (Player.State.ReceiverInviteParty != -1 ? Player.State.ReceiverInviteParty : Player.State.SenderInviteParty))) { var character = SunDofus.Entities.Requests.CharactersRequests.CharactersList.First (x => x.ID == (Player.State.ReceiverInviteParty != -1 ? Player.State.ReceiverInviteParty : Player.State.SenderInviteParty)); if (character.IsConnected) { character.State.SenderInviteParty = -1; character.State.ReceiverInviteParty = -1; character.State.OnWaitingParty = false; character.NClient.Send("PR"); } Player.State.ReceiverInviteParty = -1; Player.State.SenderInviteParty = -1; Player.State.OnWaitingParty = false; } } } if (Player.State.Party != null) { Player.State.Party.LeaveParty(Player.Name); } if (Player.State.IsFollowing) { if (SunDofus.Entities.Requests.CharactersRequests.CharactersList.Any(x => x.State.Followers.Contains(Player) && x.ID == Player.State.FollowingID)) { SunDofus.Entities.Requests.CharactersRequests.CharactersList.First(x => x.ID == Player.State.FollowingID).State.Followers.Remove(Player); } } if (Player.State.IsFollow) { Player.State.Followers.Clear(); Player.State.IsFollow = false; } if (Player.State.IsChallengeAsked) { if (SunDofus.Entities.Requests.CharactersRequests.CharactersList.Any(x => x.State.ChallengeAsked == Player.ID)) { var character = SunDofus.Entities.Requests.CharactersRequests.CharactersList.First(x => x.State.ChallengeAsked == Player.ID); Player.State.ChallengeAsker = -1; Player.State.IsChallengeAsked = false; character.State.ChallengeAsked = -1; character.State.IsChallengeAsker = false; character.NClient.Send(string.Format("GA;902;{0};{1}", character.ID, Player.ID)); } } if (Player.State.IsChallengeAsker) { if (SunDofus.Entities.Requests.CharactersRequests.CharactersList.Any(x => x.State.ChallengeAsker == Player.ID)) { var character = SunDofus.Entities.Requests.CharactersRequests.CharactersList.First(x => x.State.ChallengeAsker == Player.ID); Player.State.ChallengeAsked = -1; Player.State.IsChallengeAsker = false; character.State.ChallengeAsker = -1; character.State.IsChallengeAsked = false; character.NClient.Send(string.Format("GA;902;{0};{1}", character.ID, Player.ID)); } } } } lock (Program.GameServer.Clients) Program.GameServer.Clients.Remove(this); }