Exemple #1
0
 ///<summary>
 /// This event happens every time a player leaves the server.
 ///</summary>
 ///<param name="args">Containing event data.</param>
 private void OnLeave(LeaveEventArgs args)
 {
     if (this.myPlayersData.ContainsKey(TShock.Players[args.Who].Index))
     {
         this.myPlayersData.Remove(TShock.Players[args.Who].Index);
     }
 }
Exemple #2
0
        public static void OnLeave(LeaveEventArgs args)
        {
            if (args.Who >= TShockB.Players.Length || args.Who < 0)
            {
                //Something not right has happened
                return;
            }

            var tsplr = TShockB.Players[args.Who];

            TShockB.Players[args.Who] = null;

            if (tsplr != null && tsplr.ReceivedInfo)
            {
                if (!tsplr.SilentKickInProgress && tsplr.State >= 3)
                {
                    string playername = $"[c/4747BF:{tsplr.Name}]";
                    if (!tsplr.TPlayer.Male)
                    {
                        playername = $"[c/800080:{tsplr.Name}]";
                    }
                    TShock.AllSendMessagev2($"{playername} saiu do servidor.",
                                            $"{playername} has left the server.", Color.Gray);
                }

                Logger.doLog($"{tsplr.Name} has left the server.", Config.DebugLevel.Info);

                if (tsplr.IsLoggedIn && !tsplr.IgnoreActionsForClearingTrashCan && Main.ServerSideCharacter && (!tsplr.Dead || tsplr.TPlayer.difficulty != 2))
                {
                    tsplr.PlayerData.CopyCharacter(tsplr);
                    TShock.CharacterDB.InsertPlayerData(tsplr);
                }

                if (TShock.Config.RememberLeavePos && !tsplr.LoginHarassed)
                {
                    TShock.RememberedPos.InsertLeavePos(tsplr.Name, tsplr.IP, (int)(tsplr.X / 16), (int)(tsplr.Y / 16));
                }

                if (tsplr.tempGroupTimer != null)
                {
                    tsplr.tempGroupTimer.Stop();
                }
            }

            // Fire the OnPlayerLogout hook too, if the player was logged in and they have a TSPlayer object.
            if (tsplr != null && tsplr.IsLoggedIn)
            {
                TShockAPI.Hooks.PlayerHooks.OnPlayerLogout(tsplr);
            }

            // The last player will leave after this hook is executed.
            if (UtilsB.ActivePlayers() == 1)
            {
                if (TShock.Config.SaveWorldOnLastPlayerExit)
                {
                    SaveManagerB.Instance.SaveWorld();
                }
                TShockB.SetConsoleTitle(true);
            }
        }
Exemple #3
0
 /// <summary>
 /// Nulls out the index of the players list when a player leaves
 /// </summary>
 /// <param name="args">The leave event arguments</param>
 private void OnLeave(LeaveEventArgs args)
 {
     lock (Players)
     {
         Players[args.Who] = null;
     }
 }
Exemple #4
0
 private void OnServerLeave(LeaveEventArgs args)
 {
     if (args.Who >= 0)
     {
         _disable[args.Who] = false;
     }
 }
Exemple #5
0
 public void OnLeave(LeaveEventArgs args)
 {
     if (ShutdownInProgress && !ShutdownPaused)
     {
         CheckOnline(args.Who);
     }
 }
Exemple #6
0
        private void OnLeave(LeaveEventArgs args)
        {
            if (args.Who < 0 || args.Who >= Main.maxPlayers)
            {
                return;
            }

            var player = TShock.Players[args.Who];

            if (player != null)
            {
                var session = GetSession(player);
                if (session.Party != null)
                {
                    if (session.CurrentQuest != null && session.CurrentQuest.MainQuestTask.Status == TaskStatus.Running)
                    {
                        session.CurrentQuest.TryAddRejoinablePlayer(player);
                    }

                    session.Dispose();
                    Debug.Print("Disabled SetQuestState() in OnLeave().");
                    //session.SetQuestState(null);
                }

                LeaveParty(player);
                _sessionManager.Remove(player);
            }
        }
Exemple #7
0
        public void CompareElementIsNotEqualOfRaisedEventArgsTest()
        {
            var args = new LeaveEventArgs(fakePlane, time1.ToString());

            fakeILeaveEvent.RaisedLeaveEvent += Raise.EventWith(args);
            Assert.That(fakePlane, Is.Not.EqualTo(args.Message.plane1.Tag));
        }
Exemple #8
0
 private void RemoveLeavingPlayerFromIgnoredList(LeaveEventArgs args)
 {
     if (_ignoredPlayerIndexes[args.Who])
     {
         _ignoredPlayerIndexes[args.Who] = false;
     }
 }
Exemple #9
0
 private void onLeave(LeaveEventArgs e)
 {
     if (e.Who >= 0 || e.Who < Main.maxNetPlayers)
     {
         Exchanging[e.Who] = null;
     }
 }
Exemple #10
0
 private void OnLeave(LeaveEventArgs e)
 {
     if (players.Exists(x => x.who == e.Who))
     {
         players.RemoveAll(x => x.who == e.Who);
     }
 }
Exemple #11
0
 private void OnLeave(LeaveEventArgs e)
 {
     if (Players[e.Who] != null)
     {
         Players[e.Who] = null;
     }
 }
Exemple #12
0
        public static void PlayerLeave(LeaveEventArgs args)
        {
            var plr  = Main.player[args.Who];
            var tsp  = plr.TSPlayer();
            var eplr = tsp.EPlayer();

            if (eplr != null)
            {
                eplr.Save();
                EternalLand.EPlayers[args.Who].Dispose();
                EternalLand.EPlayers[args.Who] = null;
                Log.Info($"玩家 {eplr.Name} 数据已保存.");
                if (eplr.TerritoryUUID != Guid.Empty && MapManager.GetMapFromUUID(eplr.TerritoryUUID, out var map))
                {
                    if (map.Player.Contains(eplr.ID))
                    {
                        map.Player.Remove(eplr.ID);
                    }
                    if (!map.Player.Any() && map.Save())
                    {
                        map.Dispose();
                    }
                }
            }
        }
Exemple #13
0
        private void OnLeave(LeaveEventArgs e)
        {
            if ((e.Who < 0) || (e.Who > Main.maxNetPlayers))
            {
                return;
            }
            TSPlayer player = TShock.Players[e.Who];

            if (player != null)
            {
                PlayerInfo info = player.GetPlayerInfo();
                info.Restore(Main.ServerSideCharacter, player);
            }
            foreach (TSPlayer plr in TShock.Players)
            {
                if ((plr == null) || !plr.Active || !plr.ContainsData(PlayerInfo.KEY))
                {
                    continue;
                }

                PlayerInfo info = plr.GetPlayerInfo();
                if (info.CopyingPlayerIndex == e.Who)
                {
                    info.CopyingPlayerIndex = -1;
                }
            }
        }
Exemple #14
0
 private void OnLeave(LeaveEventArgs e)
 {
     if (TShock.Players[e.Who] != null && ChatPlayers[e.Who] != null)
     {
         UpdateList(e.Who, false);
     }
 }
        void OnLeave(LeaveEventArgs e)
        {
            lock (this)
            {
                Player plr = players[e.Who];
                if (TShock.Players[e.Who] == null || plr == null)
                {
                    return;
                }

                if (!TShock.Players[e.Who].IsLoggedIn)
                {
                    players[e.Who] = null;
                    return;
                }

                if (StatDB.PlayerExists(plr.Name))
                {
                    StatDB.UpdatePlayer(plr);
                }
                else
                {
                    StatDB.AddPlayer(plr);
                }

                players[e.Who] = null;
            }
        }
Exemple #16
0
 private void OnLeave(LeaveEventArgs args)
 {
     if (storage.ContainsKey(args.Who))
     {
         storage.Remove(args.Who);
     }
 }
Exemple #17
0
        private void OnServerLeave(LeaveEventArgs args)
        {
            if (args.Who >= TShock.Players.Length || args.Who < 0)
            {
                //Something not right has happened
                return;
            }

            TSPlayer tsplr = TShock.Players[args.Who];

            if (tsplr == null || String.IsNullOrEmpty(tsplr.Name))
            {
                return;
            }

            string message = Configs.LogoutMessageFormat.Replace(Config.CHARACTER_NAME_FORMAT, tsplr.Name);

            List <string> players = TShock.Utils.GetPlayers(false);

            players.Remove(tsplr.Name);
            int activePlayers = TShock.Utils.ActivePlayers();

            if (0 < activePlayers)
            {
                activePlayers--;
            }
            string currentPlayersMessage = Configs.CurrentPlayersMessageFormat.Replace(Config.CURRENT_PLAYERS_FORMAT, (activePlayers).ToString()).Replace(Config.SERVER_NAME_FORMAT, TShock.Config.ServerName);

            message = $"{message}\n{currentPlayersMessage}\n{String.Join(", ", players.ToArray())}";

            //Console.WriteLine("OnServerLeave: {0}", message);
            PostMessageToDiscord(message);
        }
Exemple #18
0
 private void OnLeave(LeaveEventArgs args)
 {
     if (UnoGame.state != "inactive" && UnoGame.isPlaying(args.Who))
     {
         UnoGame.LeaveGame(args.Who);
     }
 }
 public void OnLeave(LeaveEventArgs args)
 {
     if (scPlayers[args.Who] != null && scPlayers[args.Who].Cooldowns.Count > 0)
     {
         OfflineCooldowns.Add(TShock.Players[args.Who].Name, scPlayers[args.Who].Cooldowns);
     }
     scPlayers[args.Who] = null;
 }
Exemple #20
0
        public void TestHandleLeaveEvent()
        {
            var args = new LeaveEventArgs(testPlane, "20181006123456789");

            fakeAirspace.RaisedLeaveEvent += Raise.EventWith(args);
            Assert.That(nEventsReceived, Is.EqualTo(1));
            Assert.AreEqual(receivedData2.plane1, args.Message.plane1);
        }
Exemple #21
0
 public void onLeave(LeaveEventArgs e)
 {
     try
     {
         dPlayers[e.Who] = null;
     }
     catch { }
 }
 /// <summary>
 /// Called when a player leaves the server
 /// </summary>
 /// <param name="args">event arguments passed by hook</param>
 private void OnLeave(LeaveEventArgs args)
 {
     if (TShock.Players[args.Who] == null)
     {
         return;
     }
     collector.Dec(1);
 }
        private void OnServerLeave(LeaveEventArgs args)
        {
            Debug.Print("OnServerLeave");

            var player = new TSPlayer(args.Who);

            RunScript(ScriptServerLeave, player);
        }
Exemple #24
0
        private void OnServerLeave(LeaveEventArgs args)
        {
            int who = args.Who;

            for (int i = 0; i < Main.maxPlayers; i++)
            {
                GPAPI.CanSee[who, i] = GPAPI.CanSee[i, who] = true;
            }
        }
Exemple #25
0
 public static void OnLeave(LeaveEventArgs args)
 {
     if (storage.ContainsKey(args.Who))
     {
         WorldGen.KillTile((int)storage[args.Who].tentpos.X, (int)storage[args.Who].tentpos.Y);
         TSPlayer.All.SendTileSquare((int)storage[args.Who].tentpos.X, (int)storage[args.Who].tentpos.Y);
         storage.Remove(args.Who);
     }
 }
 void LeavePlayer(LeaveEventArgs args)
 {
     if (TShock.Players[args.Who] != null)
     {
         JObject json = new JObject();
         json.Add("name", TShock.Players[args.Who].Name);
         json.Add("index", TShock.Players[args.Who].Index);
         socket.Emit("playerleave", json.ToString());
     }
 }
Exemple #27
0
 void OnServerLeave(LeaveEventArgs args)
 {
     if (args != null)
     {
         if (TShockAPI.TShock.Players[args.Who] != null)
         {
             AsynchronousSocketSender.Send($"ServerLeave: {TShockAPI.TShock.Players[args.Who].Name}\n{TShockAPI.TShock.Players[args.Who].IP}");
         }
     }
 }
Exemple #28
0
 public void OnLeave(LeaveEventArgs e)
 {
     //  Team Set
     if (Delegates.Instance.kickOnLeave)
     {
         Utils.RemoveFromTeam(TShock.Players[e.Who].Name);
     }
     //  Item Classes
     hasChosenClass[e.Who] = false;
 }
Exemple #29
0
 private void OnLeave(LeaveEventArgs args)
 {
     if (args.Who == TShock.Players.Count(p => p != null))
     {
         return;
     }
     if (!_playerList.ContainsKey(TShock.Players[args.Who].UUID))
     {
         _playerList.Remove(TShock.Players[args.Who].UUID);
     }
 }
Exemple #30
0
 private void OnLeave(LeaveEventArgs e)
 {
     foreach (var i in invp)
     {
         if (i.who == e.Who)
         {
             invp.Remove(i);
             break;
         }
     }
 }
 protected virtual void HandleLeaveEvent(object o, LeaveEventArgs args)
 {
     SlideIn ();
     args.RetVal = true;
 }
 protected virtual void HandleLeaveEvent(object o, LeaveEventArgs args)
 {
     button.State &= 2;
     args.RetVal = !BubbleEvents;
 }
 protected void HandleLeaveEvent(object o, LeaveEventArgs args)
 {
     alphabet.Animatev ((ulong) AnimationMode.EaseOutExpo, CoverManager.MaxAnimationSpan, new string[] { "opacity" }, new GLib.Value[] {new GLib.Value((byte) 0)});
     args.RetVal = true;
 }