Exemplo n.º 1
0
    public static void KickPlayer(ulong steamid, int duration = -1, string message = "HOST_KICKED_YOU")
    {
        BoltConnection connection;
        BoltEntity     playerEntity;

        MpPlayerList.GetConnectionAndEntity(steamid, out connection, out playerEntity);
        CoopKick.KickPlayer(connection, playerEntity, duration, message);
    }
Exemplo n.º 2
0
        public void Kick(ulong steamid)
        {
            BoltEntity entityFromSteamID = this.GetEntityFromSteamID(steamid);

            if (entityFromSteamID)
            {
                CoopKick.KickPlayer(entityFromSteamID, -1, "Host kicked you from the game");
                base.Invoke("Refresh", 0.1f);
            }
        }
Exemplo n.º 3
0
		public void Kick(ulong steamid)
		{
			if (CoopPeerStarter.Dedicated && CoopSteamClientStarter.IsAdmin)
			{
				CoopAdminCommand.Send("kick", steamid.ToString());
			}
			else
			{
				CoopKick.KickPlayer(steamid, 1, "HOST_KICKED_YOU");
				base.Invoke("Refresh", 0.1f);
			}
		}
Exemplo n.º 4
0
        public void Ban(string reason, TimeSpan duration)
        {
            Scene.HudGui.MpPlayerList.Ban(steamId);
            CoopKick.SaveList();

            var entity = Scene.SceneTracker.allPlayerEntities.FirstOrDefault(e => e.source.RemoteEndPoint.SteamId.Id == steamId);

            if (entity != null)
            {
                CoopKick.KickPlayer(entity, (int)duration.TotalMinutes, reason);
            }
        }
Exemplo n.º 5
0
        public bool IsSleeping => Scene.Atmosphere.Sleeping; // TODO: Fix

        #endregion

        #region Administration

        /// <summary>
        /// Bans the user for the specified reason and duration
        /// </summary>
        /// <param name="reason"></param>
        /// <param name="duration"></param>
        public void Ban(string reason, TimeSpan duration = default(TimeSpan))
        {
            if (IsBanned)
            {
                return;
            }

            Scene.HudGui.MpPlayerList.Ban(steamId);
            CoopKick.SaveList();
            if (IsConnected)
            {
                CoopKick.KickPlayer(entity, (int)duration.TotalMinutes, reason);
            }
        }
Exemplo n.º 6
0
 public void KickByName(string name)
 {
     if (CoopPeerStarter.Dedicated && CoopSteamClientStarter.IsAdmin)
     {
         CoopAdminCommand.Send("kick", name);
     }
     else
     {
         BoltEntity entityFromName = MpPlayerList.GetEntityFromName(name, null);
         if (entityFromName)
         {
             CoopKick.KickPlayer(entityFromName, -1, "HOST_KICKED_YOU");
             base.Invoke("Refresh", 0.1f);
         }
     }
 }
Exemplo n.º 7
0
 public void Kick(ulong steamid)
 {
     if (CoopPeerStarter.Dedicated && CoopSteamClientStarter.IsAdmin)
     {
         CoopAdminCommand.Send("kick", steamid.ToString());
     }
     else
     {
         BoltEntity entityFromSteamID = MpPlayerList.GetEntityFromSteamID(steamid);
         if (entityFromSteamID)
         {
             CoopKick.KickPlayer(entityFromSteamID, -1, "HOST_KICKED_YOU");
             base.Invoke("Refresh", 0.1f);
         }
     }
 }
Exemplo n.º 8
0
        /// <summary>
        /// Bans the user for the specified reason and duration
        /// </summary>
        /// <param name="reason"></param>
        /// <param name="duration"></param>
        public void Ban(string reason, TimeSpan duration = default(TimeSpan))
        {
            // Check already banned
            if (IsBanned)
            {
                return;
            }

            // Set to banned
            Scene.HudGui.MpPlayerList.Ban(steamId);
            CoopKick.SaveList();

            if (entity != null)
            {
                CoopKick.KickPlayer(entity, (int)duration.TotalMinutes, reason);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Bans the player for the specified reason and duration
        /// </summary>
        /// <param name="reason"></param>
        /// <param name="duration"></param>
        public void Ban(string reason, TimeSpan duration = default(TimeSpan))
        {
            // Check already banned
            if (IsBanned)
            {
                return;
            }

            // Set to banned
            Scene.HudGui.MpPlayerList.Ban(steamId);
            CoopKick.SaveList();

            var entity = Scene.SceneTracker.allPlayerEntities.FirstOrDefault(e => e.source.RemoteEndPoint.SteamId.Id == steamId);

            if (entity != null)
            {
                CoopKick.KickPlayer(entity, (int)duration.TotalMinutes, reason);
            }
        }
Exemplo n.º 10
0
 /// <summary>
 /// Kicks the user from the game
 /// </summary>
 /// <param name="reason"></param>
 public void Kick(string reason) => CoopKick.KickPlayer(player, -1, reason);
Exemplo n.º 11
0
    public static void Recv(string command, string data, BoltConnection source)
    {
        if (CoopPeerStarter.DedicatedHost && source.IsDedicatedServerAdmin() && command != null)
        {
            if (CoopAdminCommand.< > f__switch$map2 == null)
            {
                CoopAdminCommand.< > f__switch$map2 = new Dictionary <string, int>(12)
                {
                    {
                        "save",
                        0
                    },
                    {
                        "restart",
                        1
                    },
                    {
                        "shutdown",
                        2
                    },
                    {
                        "openlogs",
                        3
                    },
                    {
                        "closelogs",
                        4
                    },
                    {
                        "kick",
                        5
                    },
                    {
                        "ban",
                        6
                    },
                    {
                        "unban",
                        7
                    },
                    {
                        "treeregrowmode",
                        8
                    },
                    {
                        "allowbuildingdestruction",
                        9
                    },
                    {
                        "allowenemiescreative",
                        10
                    },
                    {
                        "allowcheats",
                        11
                    }
                };
            }
            int num;
            if (CoopAdminCommand.< > f__switch$map2.TryGetValue(command, out num))
            {
                switch (num)
                {
                case 0:
                {
                    int slot;
                    if (!string.IsNullOrEmpty(data) && int.TryParse(data, out slot))
                    {
                        GameSetup.SetSlot((Slots)slot);
                    }
                    LevelSerializer.Checkpoint();
                    SaveSlotUtils.SaveHostGameGUID();
                    CoopAdminCommand.SendNetworkMessage("Game saved to slot " + (int)GameSetup.Slot, source);
                    break;
                }

                case 1:
                    CoopAdminCommand.SendNetworkMessageAll("Server shuting down for restart, please reconnect.");
                    TheForest.Utils.Scene.ActiveMB.StartCoroutine(CoopAdminCommand.ShutDownRoutine(true));
                    break;

                case 2:
                    CoopAdminCommand.SendNetworkMessageAll("Server is shuting down (no restart)");
                    TheForest.Utils.Scene.ActiveMB.StartCoroutine(CoopAdminCommand.ShutDownRoutine(false));
                    break;

                case 3:
                    if (!SteamDSConfig.ShowLogs)
                    {
                        ConsoleWriter.Open();
                        if (CoopAdminCommand.< > f__mg$cache0 == null)
                        {
                            CoopAdminCommand.< > f__mg$cache0 = new Application.LogCallback(CoopAdminCommand.Application_logMessageReceived);
                        }
                        Application.logMessageReceived += CoopAdminCommand.< > f__mg$cache0;
                        SteamDSConfig.ShowLogs          = true;
                        CoopAdminCommand.SendNetworkMessage("Opened logs console", source);
                    }
                    else
                    {
                        CoopAdminCommand.SendNetworkMessage("Error: console already opened", source);
                    }
                    break;

                case 4:
                    ConsoleWriter.Close();
                    if (CoopAdminCommand.< > f__mg$cache1 == null)
                    {
                        CoopAdminCommand.< > f__mg$cache1 = new Application.LogCallback(CoopAdminCommand.Application_logMessageReceived);
                    }
                    Application.logMessageReceived -= CoopAdminCommand.< > f__mg$cache1;
                    SteamDSConfig.ShowLogs          = false;
                    CoopAdminCommand.SendNetworkMessage("Closed logs console", source);
                    break;

                case 5:
                {
                    ulong num2;
                    if (ulong.TryParse(data, out num2))
                    {
                        BoltEntity entityFromSteamID = MpPlayerList.GetEntityFromSteamID(num2);
                        if (entityFromSteamID)
                        {
                            CoopKick.KickPlayer(entityFromSteamID, 1, "ADMIN_KICKED_YOU");
                            CoopAdminCommand.SendNetworkMessage("Kicked " + data, source);
                        }
                        else
                        {
                            CoopAdminCommand.SendNetworkMessage("Failed to kick " + data, source);
                        }
                    }
                    else
                    {
                        BoltEntity entityFromName = MpPlayerList.GetEntityFromName(data, source);
                        if (entityFromName)
                        {
                            CoopKick.KickPlayer(entityFromName, 1, "ADMIN_KICKED_YOU");
                            CoopAdminCommand.SendNetworkMessage("Kicked " + data, source);
                        }
                        else
                        {
                            CoopAdminCommand.SendNetworkMessage("Invalid SteamId or Name, kick failed (data=" + data + ")", source);
                        }
                    }
                    break;
                }

                case 6:
                {
                    ulong num2;
                    if (ulong.TryParse(data, out num2))
                    {
                        BoltEntity entityFromSteamID2 = MpPlayerList.GetEntityFromSteamID(num2);
                        if (entityFromSteamID2)
                        {
                            CoopKick.BanPlayer(entityFromSteamID2);
                            CoopAdminCommand.SendNetworkMessage("Banned " + data, source);
                        }
                        else
                        {
                            CoopAdminCommand.SendNetworkMessage("Failed to ban " + data, source);
                        }
                    }
                    else
                    {
                        BoltEntity entityFromName2 = MpPlayerList.GetEntityFromName(data, source);
                        if (entityFromName2)
                        {
                            CoopKick.BanPlayer(entityFromName2);
                            CoopAdminCommand.SendNetworkMessage("Banned " + data, source);
                        }
                        else
                        {
                            CoopAdminCommand.SendNetworkMessage("Invalid SteamId or Name, ban failed (data=" + data + ")", source);
                        }
                    }
                    break;
                }

                case 7:
                {
                    ulong num2;
                    if (ulong.TryParse(data, out num2))
                    {
                        CoopKick.UnBanPlayer(num2);
                        CoopAdminCommand.SendNetworkMessage("Unbanned " + data, source);
                    }
                    else if (CoopKick.UnBanPlayer(data))
                    {
                        CoopAdminCommand.SendNetworkMessage("Unbanned " + data, source);
                    }
                    else
                    {
                        CoopAdminCommand.SendNetworkMessage("Invalid SteamId or Name, unban failed (data=" + data + ")", source);
                    }
                    break;
                }

                case 8:
                    if (data == "on")
                    {
                        SteamDSConfig.TreeRegrowMode = true;
                        PlayerPreferences.SetLocalTreeRegrowth(SteamDSConfig.TreeRegrowMode);
                        CoopAdminCommand.SendNetworkMessage("TreeRegrowMode set to on", source);
                    }
                    else if (data == "off")
                    {
                        SteamDSConfig.TreeRegrowMode = false;
                        PlayerPreferences.SetLocalTreeRegrowth(SteamDSConfig.TreeRegrowMode);
                        CoopAdminCommand.SendNetworkMessage("TreeRegrowMode set to off", source);
                    }
                    else
                    {
                        CoopAdminCommand.SendNetworkMessage("Invalid parameter (data=" + data + ")", source);
                    }
                    break;

                case 9:
                    if (data == "on")
                    {
                        SteamDSConfig.AllowBuildingDestruction = true;
                        PlayerPreferences.SetLocalNoDestructionMode(!SteamDSConfig.AllowBuildingDestruction);
                        CoopAdminCommand.SendNetworkMessage("allowbuildingdestruction set to on", source);
                    }
                    else if (data == "off")
                    {
                        SteamDSConfig.AllowBuildingDestruction = false;
                        PlayerPreferences.SetLocalNoDestructionMode(!SteamDSConfig.AllowBuildingDestruction);
                        CoopAdminCommand.SendNetworkMessage("allowbuildingdestruction set to off", source);
                    }
                    else
                    {
                        CoopAdminCommand.SendNetworkMessage("Invalid parameter (data=" + data + ")", source);
                    }
                    break;

                case 10:
                    if (data == "on")
                    {
                        SteamDSConfig.AllowEnemiesCreative = true;
                        PlayerPreferences.SetLocalAllowEnemiesCreativeMode(SteamDSConfig.AllowEnemiesCreative);
                        CoopAdminCommand.SendNetworkMessage("AllowEnemiesCreative set to on", source);
                    }
                    else if (data == "off")
                    {
                        SteamDSConfig.AllowEnemiesCreative = false;
                        PlayerPreferences.SetLocalAllowEnemiesCreativeMode(SteamDSConfig.AllowEnemiesCreative);
                        CoopAdminCommand.SendNetworkMessage("AllowEnemiesCreative set to off", source);
                    }
                    else
                    {
                        CoopAdminCommand.SendNetworkMessage("Invalid parameter (data=" + data + ")", source);
                    }
                    break;

                case 11:
                    if (data == "on")
                    {
                        SteamDSConfig.AllowCheats = true;
                        PlayerPreferences.SetAllowCheatsMode(SteamDSConfig.AllowCheats);
                        CoopAdminCommand.SendNetworkMessage("allowcheats set to on", source);
                    }
                    else if (data == "off")
                    {
                        SteamDSConfig.AllowCheats = false;
                        PlayerPreferences.SetAllowCheatsMode(SteamDSConfig.AllowCheats);
                        CoopAdminCommand.SendNetworkMessage("allowcheats set to off", source);
                    }
                    else
                    {
                        CoopAdminCommand.SendNetworkMessage("Invalid parameter (data=" + data + ")", source);
                    }
                    break;
                }
            }
        }
    }
Exemplo n.º 12
0
 public static void KickPlayer(BoltEntity playerEntity, int duration, string message = "HOST_KICKED_YOU")
 {
     CoopKick.KickPlayer(null, playerEntity, duration, message);
 }
Exemplo n.º 13
0
 private static void KickPlayer(ulong steamId, BoltConnection source, string message)
 {
     CoopKick.KickPlayer(steamId, 1, message);
     CoopAdminCommand.SendNetworkMessage("Kicked " + steamId, source);
 }
Exemplo n.º 14
0
 public static void BanPlayer(BoltConnection connection, BoltEntity playerEntity)
 {
     CoopKick.KickPlayer(connection, playerEntity, 0, "HOST_BANNED_YOU_PERMANANTLY");
 }
Exemplo n.º 15
0
    public static void KickPlayerByConnectionId(int connectionId, int duration = -1, string message = "HOST_KICKED_YOU")
    {
        BoltConnection connectionFromConnectionId = MpPlayerList.GetConnectionFromConnectionId(connectionId);

        CoopKick.KickPlayer(connectionFromConnectionId, null, duration, message);
    }
Exemplo n.º 16
0
 /// <summary>
 /// Kicks the user from the game
 /// </summary>
 /// <param name="reason"></param>
 public void Kick(string reason) => CoopKick.KickPlayer(entity, -1, reason);
Exemplo n.º 17
0
 public static void BanPlayer(BoltEntity playerEntity)
 {
     CoopKick.KickPlayer(playerEntity, 0, "Host banned you permanently from his games");
 }