Ejemplo n.º 1
0
 /// <summary>
 /// Sends a console message to a <see cref="ReferenceHub"/>
 /// </summary>
 /// <param name="player"></param>
 /// <param name="message"></param>
 /// <param name="color"></param>
 public static void SendConsoleMessage(this ReferenceHub player, string message, string color)
 {
     player.characterClassManager.TargetConsolePrint(player.GetConnection(), message, color);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Sets a player's UserID
 /// </summary>
 /// <param name="player"></param>
 /// <param name="newId"></param>
 /// <returns></returns>
 public static void SetUserId(this ReferenceHub player, string newId) => player.characterClassManager.NetworkSyncedUserId = newId;
Ejemplo n.º 3
0
 /// <summary>
 /// Unmutes a <see cref="ReferenceHub">player</see>.
 /// </summary>
 /// <param name="player"></param>
 public static void Unmute(this ReferenceHub player) => player.characterClassManager.NetworkMuted = false;
Ejemplo n.º 4
0
 /// <summary>
 /// Gets the <see cref="Team"/> a <see cref="ReferenceHub"/> belongs to.
 /// </summary>
 /// <param name="player">Player</param>
 /// <returns>Team</returns>
 public static Team GetTeam(this ReferenceHub player) => player.GetRole().GetTeam();
Ejemplo n.º 5
0
        /// <summary>
        /// Gets the reference hub belonging to the player who's name most closely matches the string given, if any.
        /// </summary>
        /// <param name="args">Player's Name</param>
        /// <returns>ReferenceHub or null</returns>
        public static ReferenceHub GetPlayer(string args)
        {
            try
            {
                if (StrHubs.ContainsKey(args))
                {
                    return(StrHubs[args]);
                }

                ReferenceHub playerFound = null;

                if (short.TryParse(args, out short playerId))
                {
                    return(GetPlayer(playerId));
                }

                if (args.EndsWith("@steam") || args.EndsWith("@discord") || args.EndsWith("@northwood") || args.EndsWith("@patreon"))
                {
                    Log.Debug("Trying to find by UserID...");

                    foreach (ReferenceHub player in GetHubs())
                    {
                        if (player.GetUserId() == args)
                        {
                            playerFound = player;

                            Log.Debug("Found UserID match.");
                        }
                    }
                }
                else
                {
                    Log.Debug($"Trying to find by name... {args}");

                    if (args == "WORLD" || args == "SCP-018" || args == "SCP-575" || args == "SCP-207")
                    {
                        return(null);
                    }

                    int    maxNameLength = 31, lastnameDifference = 31;
                    string str1 = args.ToLower();

                    foreach (ReferenceHub player in GetHubs())
                    {
                        if (!player.GetNickname().ToLower().Contains(args.ToLower()))
                        {
                            continue;
                        }

                        if (str1.Length < maxNameLength)
                        {
                            int    x    = maxNameLength - str1.Length;
                            int    y    = maxNameLength - player.GetNickname().Length;
                            string str2 = player.GetNickname();

                            for (int i = 0; i < x; i++)
                            {
                                str1 += "z";
                            }

                            for (int i = 0; i < y; i++)
                            {
                                str2 += "z";
                            }

                            int nameDifference = LevenshteinDistance.Compute(str1, str2);
                            if (nameDifference < lastnameDifference)
                            {
                                lastnameDifference = nameDifference;
                                playerFound        = player;

                                Log.Debug("Found name match.");
                            }
                        }
                    }
                }

                if (playerFound != null)
                {
                    StrHubs.Add(args, playerFound);
                }

                return(playerFound);
            }
            catch (Exception exception)
            {
                Log.Error($"GetPlayer error: {exception}");
                return(null);
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Shows the tag of a <see cref="ReferenceHub"/>.
 /// </summary>
 /// <param name="player"></param>
 /// <param name="isGlobal"></param>
 private static void ShowTag(this ReferenceHub player, bool isGlobal = false) => player.characterClassManager.CallCmdRequestShowTag(isGlobal);
Ejemplo n.º 7
0
 public static void Broadcast(this ReferenceHub player, uint time, string message) => Map.BroadcastComponent.TargetAddElement(player.scp079PlayerScript.connectionToClient, message, time, false);
Ejemplo n.º 8
0
 /// <summary>
 /// Sets the position of a <see cref="ReferenceHub"/> using a <see cref="Vector3"/>.
 /// </summary>
 public static void SetPosition(this ReferenceHub player, Vector3 position) => player.SetPosition(position.x, position.y, position.z);
Ejemplo n.º 9
0
 /// <summary>
 /// Sets the position of a <see cref="ReferenceHub"/> using the x, y, and z of the destination position.
 /// </summary>
 public static void SetPosition(this ReferenceHub player, float x, float y, float z) => player.plyMovementSync.OverridePosition(new Vector3(x, y, z), player.transform.rotation.eulerAngles.y);
Ejemplo n.º 10
0
 /// <summary>
 /// Gets the rotations from a <see cref="ReferenceHub"/>
 /// </summary>
 /// <returns>A <see cref="Vector2"/>, representing the directions he's looking at</returns>
 public static Vector2 GetRotations(this ReferenceHub player) => player.plyMovementSync.NetworkRotations;
Ejemplo n.º 11
0
 /// <summary>
 /// Gets the rotation of a <see cref="ReferenceHub"/>.
 /// </summary>
 /// <returns>The direction he's looking at, useful for Raycasts</returns>
 public static Vector3 GetRotationVector(this ReferenceHub player) => player.characterClassManager.Scp049.plyCam.transform.forward;
Ejemplo n.º 12
0
 /// <summary>
 /// Gets the position of a <see cref="ReferenceHub"/>
 /// </summary>
 public static Vector3 GetPosition(this ReferenceHub player) => player.plyMovementSync.GetRealPosition();
Ejemplo n.º 13
0
 public LockerInteractionEvent(ReferenceHub rh, Locker locker, int lockerId)
 {
     Player   = rh;
     Locker   = locker;
     LockerId = lockerId;
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Sets the players Friendly Fire value.
 /// Note: This only allows them to DEAL FF damage, not TAKE FF damage.
 /// </summary>
 /// <param name="player"></param>
 /// <param name="value"></param>
 public static void SetFriendlyFire(this ReferenceHub player, bool value) =>
 player.weaponManager.NetworkfriendlyFire = value;
Ejemplo n.º 15
0
 /// <summary>
 /// Sets the nickname of a <see cref="ReferenceHub"/> to <paramref name="nickname"/>
 /// </summary>
 public static void SetNickname(this ReferenceHub player, string nickname)
 {
     player.nicknameSync.Network_myNickSync = nickname;
     MEC.Timing.RunCoroutine(BlinkTag(player));
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Sets the rotation of a <see cref="ReferenceHub"/> using a <see cref="Vector2"/>.
 /// </summary>
 public static void SetRotation(this ReferenceHub player, Vector2 rotations) => player.SetRotation(rotations.x, rotations.y);
Ejemplo n.º 17
0
 /// <summary>
 /// Hides the tag of a <see cref="ReferenceHub"/>.
 /// </summary>
 /// <param name="player"></param>
 private static void HideTag(this ReferenceHub player) => player.characterClassManager.CallCmdRequestHideTag();
Ejemplo n.º 18
0
 /// <summary>
 /// Sets the rotation of a <see cref="ReferenceHub"/> using the x and y values of the desired rotation.
 /// </summary>
 public static void SetRotation(this ReferenceHub player, float x, float y) => player.plyMovementSync.NetworkRotations = new Vector2(x, y);
Ejemplo n.º 19
0
 public static void GiveItem(this ReferenceHub player, ItemType itemType, float duration = float.NegativeInfinity, int sight = 0, int barrel = 0, int other = 0) => player.inventory.AddNewItem(itemType, duration, sight, barrel, other);
Ejemplo n.º 20
0
 /// <summary>
 /// Sets the rank of a <see cref="ReferenceHub"/> to a <see cref="UserGroup"/>.
 /// Can be null.
 /// </summary>
 public static UserGroup GetRank(this ReferenceHub player) => player.serverRoles.Group;
Ejemplo n.º 21
0
 /// <summary>
 /// Clears the brodcast of a <see cref="ReferenceHub"/>. Doesn't get logged to the console.
 /// </summary>
 /// <param name="player"></param>
 public static void ClearBroadcasts(this ReferenceHub player) => Map.BroadcastComponent.TargetClearElements(player.scp079PlayerScript.connectionToClient);
Ejemplo n.º 22
0
 /// <summary>
 /// Sets the rank color of a <see cref="ReferenceHub"/> to a given color with a <see cref="string"/>.
 /// </summary>
 public static void SetRankColor(this ReferenceHub player, string color) => player.serverRoles.SetColor(color);
Ejemplo n.º 23
0
 /// <summary>
 /// Gets the Reference hub belonging to the GameObject, if any.
 /// </summary>
 /// <param name="player">object</param>
 /// <returns>ReferenceHub or null</returns>
 public static ReferenceHub GetPlayer(this GameObject player) => ReferenceHub.GetHub(player);
Ejemplo n.º 24
0
 /// <summary>
 /// Sets the rank name of a <see cref="ReferenceHub"/> to a given <see cref="string"/>.
 /// </summary>
 public static void SetRankName(this ReferenceHub player, string name) => player.serverRoles.SetText(name);
Ejemplo n.º 25
0
 /// <summary>
 /// Gets a player's UserID
 /// </summary>
 /// <param name="player">Player</param>
 /// <returns>string, can be empty.</returns>
 public static string GetUserId(this ReferenceHub player) => player.characterClassManager.UserId;
Ejemplo n.º 26
0
 /// <summary>
 /// Sets the rank of a <see cref="ReferenceHub"/> to a <see cref="UserGroup"/>.
 /// </summary>
 public static void SetRank(this ReferenceHub player, UserGroup userGroup) => player.serverRoles.SetGroup(userGroup, false, false, false);
Ejemplo n.º 27
0
 /// <summary>
 /// Gets a player's PlayerID
 /// </summary>
 /// <param name="player">Player</param>
 /// <returns>int PlayerID</returns>
 public static int GetPlayerId(this ReferenceHub player) => player.queryProcessor.PlayerId;
Ejemplo n.º 28
0
 /// <summary>
 /// Gets the nickname of a <see cref="ReferenceHub"/>
 /// </summary>
 public static string GetNickname(this ReferenceHub player) => player.nicknameSync.Network_myNickSync;
Ejemplo n.º 29
0
 /// <summary>
 /// Gets a <see cref="ReferenceHub">player</see> mute status.
 /// </summary>
 /// <param name="player"></param>
 /// <returns>True if muted, false if not</returns>
 public static bool IsMuted(this ReferenceHub player) => player.characterClassManager.NetworkMuted;
Ejemplo n.º 30
0
 /// <summary>
 /// Sets a player's role.
 /// </summary>
 /// <param name="player"></param>
 /// <param name="newRole"></param>
 public static void SetRole(this ReferenceHub player, RoleType newRole) => player.characterClassManager.SetPlayersClass(newRole, player.gameObject);