Ejemplo n.º 1
0
        /// <summary>
        /// Occurs when the server receives data.
        /// </summary>
        void NetHooks_GetData(Hooks.GetDataEventArgs e)
        {
            if (e.MsgID == PacketTypes.PlayerUpdate)
            {
                byte plyID = e.Msg.readBuffer[e.Index];
                byte flags = e.Msg.readBuffer[e.Index + 1];

                var player = PlayerList[plyID];
                if (player != null && player.LastState != flags)
                {
                    player.LastState = flags;
                    player.IdleCount = 0;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Occurs when the server receives data from the client.
        /// </summary>
        void NetHooks_GetData(Hooks.GetDataEventArgs e)
        {
            if (e.MsgID == PacketTypes.PlayerUpdate)
            {
                byte playerIndex = e.Msg.readBuffer[e.Index];
                PlayerControlFlags    playerState   = (PlayerControlFlags)e.Msg.readBuffer[e.Index + 1];
                Economy.EconomyPlayer currentPlayer = GetEconomyPlayerSafe(playerIndex);

                //The idea behind this logic is that IdleSince resets to now any time the server an action from the client.
                //If the client never updates, or updates to 0 (Idle) then "IdleSince" never changes.
                //When you want to get the amount of time the player has been idle, just subtract it from DateTime.Now
                //And voila, you get a TimeSpan with how long the user has been idle for.
                if (playerState != PlayerControlFlags.Idle)
                {
                    currentPlayer.IdleSince = DateTime.Now;
                }

                currentPlayer.LastKnownState = playerState;
            }
        }
Ejemplo n.º 3
0
 void NetHooks_GetData(Hooks.GetDataEventArgs e)
 {
     if (e.MsgID == PacketTypes.Tile)
     {
     }
 }