Exemplo n.º 1
0
        private void savePlayerState(BasePlayer player)
        {
            long currentTimestamp = GrabCurrentTimestamp();
            var  info             = new PlayTimeInfo(player);
            var  state            = new PlayerStateInfo(player);

            if (!playTimeData.Players.ContainsKey(info.SteamID))
            {
                playTimeData.Players.Add(info.SteamID, info);
            }
            long initTimeStamp = playerStateData.Players[state.SteamID].InitTimeStamp;
            long afkTime       = playerStateData.Players[state.SteamID].AfkTime;
            long totalPlayed   = currentTimestamp - initTimeStamp;

            playTimeData.Players[info.SteamID].AfkTime += afkTime;
            TimeSpan humanAfkTime = TimeSpan.FromSeconds(playTimeData.Players[info.SteamID].AfkTime);

            playTimeData.Players[info.SteamID].HumanAfkTime = string.Format("{0:c}", humanAfkTime);

            playTimeData.Players[info.SteamID].PlayTime += totalPlayed;
            TimeSpan humanPlayTime = TimeSpan.FromSeconds(playTimeData.Players[info.SteamID].PlayTime);

            playTimeData.Players[info.SteamID].HumanPlayTime = string.Format("{0:c}", humanPlayTime);

            playTimeData.Players[info.SteamID].LastSeen = (DateTime.Now).ToString("G");

            Interface.GetMod().DataFileSystem.WriteObject("PlayTimeTracker", playTimeData);
        }
Exemplo n.º 2
0
        void OnPlayerDisconnected(BasePlayer player)
        {
            long currentTimestamp = GrabCurrentTimestamp();
            var  info             = new PlayTimeInfo(player);

            long lastIncrement = playTimeData.Players[info.SteamID].LastPlayTimeIncrement;
            long totalPlayed   = currentTimestamp - lastIncrement;

            playTimeData.Players[info.SteamID].PlayTime += totalPlayed;
            playTimeData.Players[info.SteamID].LastPlayTimeIncrement = currentTimestamp;
            playTimeData.Players[info.SteamID].LastLogoutTime        = currentTimestamp;
            Interface.GetMod().DataFileSystem.WriteObject("PlayTime", playTimeData);
        }
Exemplo n.º 3
0
        void OnPlayerInit(BasePlayer player)
        {
            var info = new PlayTimeInfo(player);

            if (!playTimeData.Players.ContainsKey(info.SteamID))
            {
                playTimeData.Players.Add(info.SteamID, info);
            }
            playTimeData.Players[info.SteamID].Name     = player.displayName;
            playTimeData.Players[info.SteamID].LastSeen = "Now";

            Interface.GetMod().DataFileSystem.WriteObject("PlayTimeTracker", playTimeData);

            initPlayerState(player);
        }
Exemplo n.º 4
0
        public void updatePlayTime()
        {
            Puts("Saving playtime data for all online users.");
            foreach (BasePlayer onlinePlayer in BasePlayer.activePlayerList)
            {
                long currentTimestamp = GrabCurrentTimestamp();
                long playerSteamID = FindPlayer(onlinePlayer.userID.ToString());

                if (playerSteamID == 0)
                {
                    // No info in file, so lets initiate him.
                    var info = new PlayTimeInfo(onlinePlayer);

                    if (playTimeData.Players.ContainsKey(info.SteamID))
                    {
                        Puts("Player already has a PlayTime log.");

                        playTimeData.Players[info.SteamID].LastPlayTimeIncrement = GrabCurrentTimestamp();
                        playTimeData.Players[info.SteamID].Name = onlinePlayer.displayName;
                    }
                    else
                    {
                        Puts("Saving new player to PlayTime log.");
                        playTimeData.Players.Add(info.SteamID, info);
                    }

                    Interface.GetMod().DataFileSystem.WriteObject("PlayTime", playTimeData);

                    return;
                }

                if (onlinePlayer.userID.ToString() == playerSteamID.ToString())
                {
                    string playerName = playTimeData.Players[playerSteamID.ToString()].Name;
                    long playedTime = currentTimestamp - playTimeData.Players[playerSteamID.ToString()].LastPlayTimeIncrement;

                    playTimeData.Players[playerSteamID.ToString()].PlayTime += playedTime;
                    playTimeData.Players[playerSteamID.ToString()].LastPlayTimeIncrement = currentTimestamp;

                    Interface.GetMod().DataFileSystem.WriteObject("PlayTime", playTimeData);
                }
            }
        }
Exemplo n.º 5
0
        public void updatePlayTime()
        {
            Puts("Saving playtime data for all online users.");
            foreach (BasePlayer onlinePlayer in BasePlayer.activePlayerList)
            {
                long currentTimestamp = GrabCurrentTimestamp();
                long playerSteamID    = FindPlayer(onlinePlayer.userID.ToString());

                if (playerSteamID == 0)
                {
                    // No info in file, so lets initiate him.
                    var info = new PlayTimeInfo(onlinePlayer);

                    if (playTimeData.Players.ContainsKey(info.SteamID))
                    {
                        Puts("Player already has a PlayTime log.");

                        playTimeData.Players[info.SteamID].LastPlayTimeIncrement = GrabCurrentTimestamp();
                        playTimeData.Players[info.SteamID].Name = onlinePlayer.displayName;
                    }
                    else
                    {
                        Puts("Saving new player to PlayTime log.");
                        playTimeData.Players.Add(info.SteamID, info);
                    }

                    Interface.GetMod().DataFileSystem.WriteObject("PlayTime", playTimeData);

                    return;
                }

                if (onlinePlayer.userID.ToString() == playerSteamID.ToString())
                {
                    string playerName = playTimeData.Players[playerSteamID.ToString()].Name;
                    long   playedTime = currentTimestamp - playTimeData.Players[playerSteamID.ToString()].LastPlayTimeIncrement;

                    playTimeData.Players[playerSteamID.ToString()].PlayTime += playedTime;
                    playTimeData.Players[playerSteamID.ToString()].LastPlayTimeIncrement = currentTimestamp;

                    Interface.GetMod().DataFileSystem.WriteObject("PlayTime", playTimeData);
                }
            }
        }
Exemplo n.º 6
0
        void OnPlayerInit(BasePlayer player)
        {
            long currentTimestamp = GrabCurrentTimestamp();
            var info = new PlayTimeInfo(player);

            if (BroadcastLastSeenOnConnect)
            {
                long lastLogoutTime = playTimeData.Players[info.SteamID].LastLogoutTime;
                long lastSeenDays = 0;
                long lastSeenHours = 0;
                long lastSeenMinutes = 0;
                long lastSeenSeconds = currentTimestamp - lastLogoutTime;

                if (lastSeenSeconds > 60)
                {
                    lastSeenMinutes = lastSeenSeconds / 60;
                    lastSeenSeconds = lastSeenSeconds - (lastSeenMinutes * 60);
                }

                if (lastSeenMinutes > 60)
                {
                    lastSeenHours = lastSeenMinutes / 60;
                    lastSeenMinutes = lastSeenMinutes - (lastSeenHours * 60);
                }

                if (lastSeenHours > 24)
                {
                    lastSeenDays = lastSeenHours / 24;
                    lastSeenHours = lastSeenHours - (lastSeenDays * 24);
                }

                if (lastSeenDays > 0)
                {
                    PrintToChat(Prefix + player.displayName + " was last seen " + lastSeenDays + " days " + lastSeenHours + " hours and " + lastSeenMinutes + " minutes ago.");
                    Puts(player.displayName + " was last seen " + lastSeenDays + " days " + lastSeenHours + " hours and " + lastSeenMinutes + " minutes ago.");
                }
                else if (lastSeenHours > 0)
                {
                    PrintToChat(Prefix + player.displayName + " was last seen " + lastSeenHours + " hours and " + lastSeenMinutes + " minutes ago.");
                    Puts(player.displayName + " was last seen " + lastSeenDays + " days " + lastSeenHours + " hours and " + lastSeenMinutes + " minutes ago.");
                }
                else if (lastSeenMinutes > 0)
                {
                    PrintToChat(Prefix + player.displayName + " was last seen " + lastSeenMinutes + " minutes ago.");
                    Puts(player.displayName + " was last seen " + lastSeenDays + " days " + lastSeenHours + " hours and " + lastSeenMinutes + " minutes ago.");
                }
                else
                {
                    PrintToChat(Prefix + player.displayName + " was last seen " + lastSeenSeconds + " seconds ago.");
                    Puts(player.displayName + " was last seen " + lastSeenDays + " days " + lastSeenHours + " hours and " + lastSeenMinutes + " minutes ago.");
                }
            }

            if (playTimeData.Players.ContainsKey(info.SteamID))
            {
                Puts("Player already has a PlayTime log.");

                playTimeData.Players[info.SteamID].LastPlayTimeIncrement = currentTimestamp;
                playTimeData.Players[info.SteamID].Name = player.displayName;
            }
            else
            {
                Puts("Saving new player to PlayTime log.");
                playTimeData.Players.Add(info.SteamID, info);
            }

            Interface.GetMod().DataFileSystem.WriteObject("PlayTime", playTimeData);
        }
Exemplo n.º 7
0
        void OnPlayerDisconnected(BasePlayer player)
        {
            long currentTimestamp = GrabCurrentTimestamp();
            var info = new PlayTimeInfo(player);

            long lastIncrement = playTimeData.Players[info.SteamID].LastPlayTimeIncrement;
            long totalPlayed = currentTimestamp - lastIncrement;

            playTimeData.Players[info.SteamID].PlayTime += totalPlayed;
            playTimeData.Players[info.SteamID].LastPlayTimeIncrement = currentTimestamp;
            playTimeData.Players[info.SteamID].LastLogoutTime = currentTimestamp;
            Interface.GetMod().DataFileSystem.WriteObject("PlayTime", playTimeData);
        }
Exemplo n.º 8
0
        private void savePlayerState(BasePlayer player)
        {
            long currentTimestamp = GrabCurrentTimestamp();
              var info = new PlayTimeInfo(player);
              var state = new PlayerStateInfo(player);

              if (!playTimeData.Players.ContainsKey(info.SteamID)){
            playTimeData.Players.Add(info.SteamID, info);
              }
              long initTimeStamp = playerStateData.Players[state.SteamID].InitTimeStamp;
              long afkTime = playerStateData.Players[state.SteamID].AfkTime;
              long totalPlayed = currentTimestamp - initTimeStamp;

              playTimeData.Players[info.SteamID].AfkTime += afkTime;
              TimeSpan humanAfkTime = TimeSpan.FromSeconds(playTimeData.Players[info.SteamID].AfkTime);
              playTimeData.Players[info.SteamID].HumanAfkTime = string.Format("{0:c}", humanAfkTime);

              playTimeData.Players[info.SteamID].PlayTime += totalPlayed;
              TimeSpan humanPlayTime = TimeSpan.FromSeconds(playTimeData.Players[info.SteamID].PlayTime);
              playTimeData.Players[info.SteamID].HumanPlayTime = string.Format("{0:c}", humanPlayTime);

              playTimeData.Players[info.SteamID].LastSeen = (DateTime.Now).ToString("G");

              Interface.GetMod().DataFileSystem.WriteObject("PlayTimeTracker", playTimeData);
        }
Exemplo n.º 9
0
        void OnPlayerInit(BasePlayer player)
        {
            var info = new PlayTimeInfo(player);

              if (!playTimeData.Players.ContainsKey(info.SteamID)) {
            playTimeData.Players.Add(info.SteamID, info);
              }
              playTimeData.Players[info.SteamID].Name = player.displayName;
              playTimeData.Players[info.SteamID].LastSeen = "Now";

              Interface.GetMod().DataFileSystem.WriteObject("PlayTimeTracker", playTimeData);

              initPlayerState(player);
        }
Exemplo n.º 10
0
        void OnPlayerInit(BasePlayer player)
        {
            long currentTimestamp = GrabCurrentTimestamp();
            var  info             = new PlayTimeInfo(player);

            if (BroadcastLastSeenOnConnect)
            {
                long lastLogoutTime  = playTimeData.Players[info.SteamID].LastLogoutTime;
                long lastSeenDays    = 0;
                long lastSeenHours   = 0;
                long lastSeenMinutes = 0;
                long lastSeenSeconds = currentTimestamp - lastLogoutTime;

                if (lastSeenSeconds > 60)
                {
                    lastSeenMinutes = lastSeenSeconds / 60;
                    lastSeenSeconds = lastSeenSeconds - (lastSeenMinutes * 60);
                }

                if (lastSeenMinutes > 60)
                {
                    lastSeenHours   = lastSeenMinutes / 60;
                    lastSeenMinutes = lastSeenMinutes - (lastSeenHours * 60);
                }

                if (lastSeenHours > 24)
                {
                    lastSeenDays  = lastSeenHours / 24;
                    lastSeenHours = lastSeenHours - (lastSeenDays * 24);
                }

                if (lastSeenDays > 0)
                {
                    PrintToChat(Prefix + player.displayName + " was last seen " + lastSeenDays + " days " + lastSeenHours + " hours and " + lastSeenMinutes + " minutes ago.");
                    Puts(player.displayName + " was last seen " + lastSeenDays + " days " + lastSeenHours + " hours and " + lastSeenMinutes + " minutes ago.");
                }
                else if (lastSeenHours > 0)
                {
                    PrintToChat(Prefix + player.displayName + " was last seen " + lastSeenHours + " hours and " + lastSeenMinutes + " minutes ago.");
                    Puts(player.displayName + " was last seen " + lastSeenDays + " days " + lastSeenHours + " hours and " + lastSeenMinutes + " minutes ago.");
                }
                else if (lastSeenMinutes > 0)
                {
                    PrintToChat(Prefix + player.displayName + " was last seen " + lastSeenMinutes + " minutes ago.");
                    Puts(player.displayName + " was last seen " + lastSeenDays + " days " + lastSeenHours + " hours and " + lastSeenMinutes + " minutes ago.");
                }
                else
                {
                    PrintToChat(Prefix + player.displayName + " was last seen " + lastSeenSeconds + " seconds ago.");
                    Puts(player.displayName + " was last seen " + lastSeenDays + " days " + lastSeenHours + " hours and " + lastSeenMinutes + " minutes ago.");
                }
            }

            if (playTimeData.Players.ContainsKey(info.SteamID))
            {
                Puts("Player already has a PlayTime log.");

                playTimeData.Players[info.SteamID].LastPlayTimeIncrement = currentTimestamp;
                playTimeData.Players[info.SteamID].Name = player.displayName;
            }
            else
            {
                Puts("Saving new player to PlayTime log.");
                playTimeData.Players.Add(info.SteamID, info);
            }

            Interface.GetMod().DataFileSystem.WriteObject("PlayTime", playTimeData);
        }