Ejemplo n.º 1
0
        public static void EventSleeperAway(object obj, ulong userID)
        {
            if (obj != null && obj is EventTimer)
            {
                (obj as EventTimer).Dispose();
            }
            string username = Users.GetUsername(userID);

            RustProto.Avatar avatar = NetUser.LoadAvatar(userID);
            if (avatar != null && avatar.HasAwayEvent && avatar.AwayEvent.Type == AwayEvent.Types.AwayEventType.SLUMBER)
            {
                SleepingAvatar.TransientData transientData = (SleepingAvatar.TransientData) typeof(SleepingAvatar).GetMethod("Close", BindingFlags.Static | BindingFlags.NonPublic).Invoke(null, new object[]
                {
                    userID
                });
                if (transientData.exists)
                {
                    Helper.Log(string.Concat(new object[]
                    {
                        "User Sleeping [",
                        username,
                        ":",
                        userID,
                        "] is disappeared."
                    }), true);
                    transientData.AdjustIncomingAvatar(ref avatar);
                    NetUser.SaveAvatar(userID, ref avatar);
                }
            }
        }
Ejemplo n.º 2
0
        public static void OnUserInitialize(NetUser user)
        {
            try
            {
                if (user != null)
                {
                    string userName = user.displayName;

                    RustProto.Avatar objB = user.LoadAvatar();
                    if (objB != null)
                    {
                        RustServerManagement RSM = RustServerManagement.Get();
                        if (RSM != null)
                        {
                            RSM.UpdateConnectingUserAvatar(user, ref user.avatar);
                            if (!object.ReferenceEquals(user.avatar, objB))
                            {
                                user.SaveAvatar();
                            }
                            if (user.playerClient != null)
                            {
                                if (RSM.SpawnPlayer(user.playerClient, false, user.avatar) != null)
                                {
                                    user.did_join = true;
                                    conLog.Info((vanishedList.Contains(user.userID.ToString()) ? "Vanished user" : userName) + " (" + user.userID + ") has joined the game world. Avatar loaded.");
                                    if (vanishedList.Contains(user.userID.ToString()))
                                    {
                                        addArmor(user.playerClient, "Invisible Helmet", true);
                                        addArmor(user.playerClient, "Invisible Vest", true);
                                        addArmor(user.playerClient, "Invisible Pants", true);
                                        addArmor(user.playerClient, "Invisible Boots", true);
                                    }
                                }
                            }
                            else
                            {
                               conLog.Info("User " + userName + " (" + user.userID.ToString() + ") joined but the instance of PlayerClient is null! DO NOT IGNORE THIS!");
                            }
                        }
                        else
                            conLog.Info("User " + userName + " (" + user.userID.ToString() + ") joined but the RSM is null!");
                    }
                    else
                        conLog.Info("User " + userName + " (" + user.userID.ToString() + ") joined but the avatar could not be loaded!");
                }
                else
                    conLog.Info("User was null when joining! DO NOT IGNORE THIS!");
            }
            catch (Exception ex) { Vars.conLog.Error(ex.ToString()); }
        }