Example #1
0
        public static void StatusOptions(TShockAPI.CommandArgs args)
        {
            string text = null;

            if (args.Parameters.Count > 0)
            {
                text = args.Parameters[0].ToLower();
            }
            switch (text)
            {
            default:
                args.Player.SendErrorMessage("Uzycie: /status <opcja>");
                args.Player.SendInfoMessage("Opcje: cale, online, ping, konto, zgony, pvp, waznosc, postep");
                break;

            case "cale":
                if (SavingFormat.IsTrue(SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions, 0))
                {
                    SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions = SavingFormat.Change(SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions, 0, false);
                    args.Player.SendSuccessMessage("Status zostal calkowice wylaczony.");
                    args.Player.SendData(PacketTypes.Status);
                }
                else
                {
                    SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions = SavingFormat.Change(SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions, 0, true);
                    args.Player.SendSuccessMessage("Status zostal wlaczony.");
                }
                break;

            case "online":
                if (SavingFormat.IsTrue(SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions, 1))
                {
                    SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions = SavingFormat.Change(SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions, 1, false);
                    args.Player.SendSuccessMessage("Online w statusie zostal wylaczony.");
                }
                else
                {
                    SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions = SavingFormat.Change(SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions, 1, true);
                    args.Player.SendSuccessMessage("Online w statusie zostal wlaczony.");
                }
                break;

            case "konto":
                if (SavingFormat.IsTrue(SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions, 2))
                {
                    SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions = SavingFormat.Change(SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions, 2, false);
                    args.Player.SendSuccessMessage("Konto w statusie zostalo wylaczone.");
                }
                else
                {
                    SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions = SavingFormat.Change(SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions, 2, true);
                    args.Player.SendSuccessMessage("Konto w statusie zostalo wlaczone.");
                }
                break;

            case "zgony":
                if (SavingFormat.IsTrue(SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions, 3))
                {
                    SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions = SavingFormat.Change(SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions, 3, false);
                    args.Player.SendSuccessMessage("Zgony w statusie zostaly wylaczone.");
                }
                else
                {
                    SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions = SavingFormat.Change(SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions, 3, true);
                    args.Player.SendSuccessMessage("Zgony w statusie zostaly wlaczone.");
                }
                break;

            case "waznosc":
                if (SavingFormat.IsTrue(SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions, 4))
                {
                    SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions = SavingFormat.Change(SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions, 4, false);
                    args.Player.SendSuccessMessage("Waznosc w statusie zostala wylaczona.");
                }
                else
                {
                    SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions = SavingFormat.Change(SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions, 4, true);
                    args.Player.SendSuccessMessage("Waznosc w statusie zostala wlaczona.");
                }
                break;

            case "Postep":
                if (SavingFormat.IsTrue(SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions, 5))
                {
                    SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions = SavingFormat.Change(SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions, 5, false);
                    args.Player.SendSuccessMessage("Postep w statusie zostal wylaczony.");
                }
                else
                {
                    SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions = SavingFormat.Change(SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions, 5, true);
                    args.Player.SendSuccessMessage("Postep w statusie zostal wlaczony.");
                }
                break;

            case "pvp":
                if (SavingFormat.IsTrue(SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions, 6))
                {
                    SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions = SavingFormat.Change(SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions, 6, false);
                    args.Player.SendSuccessMessage("PVP w statusie zostalo wylaczone.");
                }
                else
                {
                    SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions = SavingFormat.Change(SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions, 6, true);
                    args.Player.SendSuccessMessage("PVP w statusie zostalo wlaczone.");
                }
                break;

            case "ping":
                if (SavingFormat.IsTrue(SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions, 7))
                {
                    SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions = SavingFormat.Change(SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions, 7, false);
                    args.Player.SendSuccessMessage("Ping w statusie zostal wylaczony.");
                }
                else
                {
                    SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions = SavingFormat.Change(SurvivalCore.SrvPlayers[args.Player.Index].StatusOptions, 7, true);
                    args.Player.SendSuccessMessage("Ping w statusie zostal wlaczony.");
                }
                break;
            }
        }
Example #2
0
        private void OneSecondThread()
        {
            while (true)
            {
                try
                {
                    while (true)
                    {
                        Thread.Sleep(1000);



                        byte[] array = new byte[201];
                        foreach (int key2 in Guardians.Keys)
                        {
                            if ((DateTime.UtcNow - Guardians[key2]).TotalMilliseconds >= 5888.0)
                            {
                                Main.npc[key2].active = false;
                                TSPlayer.All.SendData(PacketTypes.NpcUpdate, "", key2);
                                array[key2] = (byte)key2;
                            }
                        }
                        byte[] array2 = array;
                        foreach (byte key in array2)
                        {
                            Guardians.Remove(key);
                        }

                        TSPlayer[] players = TShock.Players;
                        Goal       goal    = Goals.GetCurrentGoal();
                        foreach (TSPlayer tSPlayer in players)
                        {
                            if (tSPlayer != null && tSPlayer.Account != null)
                            {
                                if (SavingFormat.IsTrue(SrvPlayers[tSPlayer.Index].StatusOptions, 0) && !IsStatusBusy[tSPlayer.Index])
                                {
                                    string text2 = string.Format("{7} [c/595959:───── «] [c/52e092:Powelder] [c/595959:» ───── ]{0}{1}{2}{3}{4}{5}{6} \n\r [c/595959:───── «] [c/52e092:Survival] [c/595959:» ───── ]",
                                                                 SavingFormat.IsTrue(SrvPlayers[tSPlayer.Index].StatusOptions, 1)                //0
                                                                                        ? $"\n\r[c/66ff66:Online][c/595959::] {TShock.Utils.GetActivePlayerCount()}"
                                                                                        : null,
                                                                 (!SavingFormat.IsTrue(SrvPlayers[tSPlayer.Index].StatusOptions, 7))                //1
                                                                                        ? null
                                                                                        : (Ping.ContainsKey((byte)tSPlayer.Index)
                                                                                                ? ("\n\r[c/66ff66:Ping][c/595959::] " + Ping[(byte)tSPlayer.Index])
                                                                                                : "\n\r[c/66ff66:Ping][c/595959::] -ms"),
                                                                 SavingFormat.IsTrue(SrvPlayers[tSPlayer.Index].StatusOptions, 2)                //2
                                                                                        ? $"\n\r[c/66ff66:Konto][c/595959::] {SrvPlayers[tSPlayer.Index].Money:n0} {Economy.Economy.Config.ValueName}"
                                                                                        : null,
                                                                 SavingFormat.IsTrue(SrvPlayers[tSPlayer.Index].StatusOptions, 3)                //3
                                                                                        ? $"\n\r[c/66ff66:Zgony][c/595959::] {SrvPlayers[tSPlayer.Index].Deaths}"
                                                                                        : null,
                                                                 SavingFormat.IsTrue(SrvPlayers[tSPlayer.Index].StatusOptions, 6)                //4
                                                                                        ? $"\n\r[c/66ff66:PvP][c/595959::] {SrvPlayers[tSPlayer.Index].PvpKills}/{SrvPlayers[tSPlayer.Index].PvpDeaths} | {((SrvPlayers[tSPlayer.Index].PvpDeaths == 0) ? ((double) SrvPlayers[tSPlayer.Index].PvpKills) : Math.Round((double) SrvPlayers[tSPlayer.Index].PvpKills / (double) SrvPlayers[tSPlayer.Index].PvpDeaths, 2))}"
                                                                                        : null,
                                                                 null,
                                                                 (!SavingFormat.IsTrue(SrvPlayers[tSPlayer.Index].StatusOptions, 5))                //5
                                                                                        ? null
                                                                                        : $"\n\r[c/66ff66:{goal.Name}][c/595959::] {goal.Progress}/{goal.ToComplete} ({Math.Round((float)goal.Progress / (float)goal.ToComplete, 3) * 100}%)",
                                                                 RepeatLineBreaks(10)
                                                                 );
                                    tSPlayer.SendData(PacketTypes.Status, text2, 0, 3);
                                }
                            }
                        }
                    }
                }
                catch (NullReferenceException)
                {
                }
            }
        }