Can someone help me with a AFK timer ?

03/06/2010 12:20 Paralyzer[GM]#1
So I saw an AFK timer and it looked pretty cool so I wanted to use it and as you have most likely guest that it was LOTF and LOTF = shit so.... So I was think something like

AFK for 10 mins you get auto-kicked
and maybe add a code so like if (!==1002) || (!==1038)

so like if your in ANY map u get kicked after 10mins of not moving but (!==1002) can be there so I can add a map that does NOT have the Auto AFK timer.

So can anyone help me out ? or you can just PM me the code if you dont want other people having it ;)

Many Thanks,
Paralyzer!
03/06/2010 14:45 PeTe Ninja#2
well not moving isthe first step.. not talking is the second step. not doing anything in their inventory or checking things out is the third step.
03/06/2010 15:47 Paralyzer[GM]#3
Cheers, but my question was can someone give me the code ?
03/06/2010 15:52 PeTe Ninja#4
FUCK NO
03/06/2010 15:56 Paralyzer[GM]#5
lol why its just a little code ** have a biscuit :D **
03/06/2010 16:01 Arcо#6
Quote:
Originally Posted by Paralyzer[GM] View Post
lol why its just a little code ** have a biscuit :D **
Reason people won't give you the code is because this forum is full of leechers and most of us intermediate people want the newcomers to try to learn for themselves. Well that's my reason anyways.
03/06/2010 16:05 PeTe Ninja#7
my reason is do it ur fucking self. and + no one uses a afk timer for their server because its plain stupid... there is multiple things u have to count for ( its possible, itsbeen done)

- Training Ground
- Attacking Guild Pole
- Talking with friends
- Viewing items and different combinations
- Thinking of a cool name to change yours to
- leveling skills..

whoever wants to kick players out of their server for no reason other than being gone for like 5 seconds... seriously what if the person has to go somewhere and returns? hes like brb for 10 mins u gonna kick him? .. anyway why would u kick players? people want to get MORE players not less.
03/06/2010 16:09 Paralyzer[GM]#8
Can anyone teach me how to code such a thing ?
03/06/2010 16:13 PeTe Ninja#9
did u try urself and btw lotf does not equal shit.
03/06/2010 16:25 Paralyzer[GM]#10
I did attempt it but no luck just got a shit load of errors so clearly nobody can help me or teach me to learn these things so

#Request Close
03/07/2010 00:54 _tao4229_#11
[Only registered and activated users can see links. Click Here To Register...]
Perfect guide.
03/07/2010 01:27 CIRASH#12
Quote:
Originally Posted by _tao4229_ View Post
[Only registered and activated users can see links. Click Here To Register...]
Perfect guide.
pwnt + agreed. read some tuts...
03/07/2010 01:42 pro4never#13
I'd suggest a date time check.

Under your characters I'd do a datetime controling when the last 'action' was and a bool controlling if the character is afk or not.

Then in your movement, attack and chat sections reset the date time to current datetime (saying the last time the client was active is now)

Then where your source handles server checks (such as pk tourneys, dis city or w/e), do a loop through all connected client seeing if they are not on certain maps (market/tg) check if their last action + 10 minutes is less than the current date time. if so, kick them... or use an afk bool which you could use to display an effect around a character to show they are 'away' or whatnot.
03/07/2010 18:14 herekorvac#14
I wrote this just now...This could help you a little bit..I hope you continue from what I wrote otherwise it was just a waste of my time.. I thought since no one really is "helping" you , I guess i would...

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Timers;
/* AFK Timer Project..Quick Example */
/* EP-PN © 2010 */
namespace AFKTimerProjectQuick
{
    public class Program
    {
        public static void Check(Character Entity)
        {
            if (Entity._LastAction == Character.LastAction.Fighting || Entity._LastAction == Character.LastAction.Move || Entity._LastAction == Character.LastAction.Talk)
            {
                if (Entity.LastActionTime.Minute > 15) // The Entity's last action is greater than 15 minutes..kick
                {
                    Console.WriteLine(Entity.Name + " is AFK..being kicked");
                    Entity.Drop();
                }
            }
           
        }
        static void Main(string[] args)
        {
            Console.Title = "AFK Timer Quick Example v1.0";
            Character startChar = new Character();
            Console.ReadLine();
            
        }
    }
    public class Character
    {
        public string Name;
        public byte Level;
        public UInt16 MapId;
        public UInt16 X_Cord;
        public UInt16 Y_Cord;
        public Timer AFKTimer = new Timer();
        public LastAction _LastAction;
        public DateTime LastActionTime;
        public enum LastAction
        {
            Talk,
            Move,
            Fighting,
        }
        

        public Character()
        {
            AFKTimer.Interval = 1000;
            AFKTimer.Elapsed += new ElapsedEventHandler(AFKTimer_Elapsed);
            AFKTimer.Start();
        }

        

        void AFKTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            Program.Check(this);
        }
        internal void Tele(UInt16 x, UInt16 y)
        {
            X_Cord = x;
            Y_Cord = y;
            _LastAction = LastAction.Move;
            LastActionTime = DateTime.Now;
        }
        internal void Drop()
        {
           // Kick
        }
    }
    public class Client
    {
        Character _Entity = new Character();
        Character subAttacker = new Character();

        public void SendPacket()
        {
            UInt16 PacketID = new UInt16(); // Quick Example...Really does nothing..

            switch (PacketID)
            {
                /* Don't know if any are attacking or moving or talking, but you should see what i mean */

                case 21: // Attack
                    Attack(_Entity, subAttacker);
                    break;

                case 133: // Move
                    Move();
                    break;

                case 1018: // Talk
                    Chat();
                    break;
            }
        }
        public void Attack(Character Attacker, Character Attacked)
        {
            // Attacking Calculations
            Attacker._LastAction = Character.LastAction.Fighting;
            Attacker.LastActionTime = DateTime.Now;

            Attacked._LastAction = Character.LastAction.Fighting;
            Attacked.LastActionTime = DateTime.Now;
        }
        public void Move()
        {
            System.Random newMove = new Random();
            int _x = newMove.Next(1, 999);
            int _y = newMove.Next(1, 999);
            _Entity.Tele(Convert.ToUInt16(_x), Convert.ToUInt16(_y));

        }
        public void Chat()
        {
            // Blah Blah Blah..Check Commands
            InternalUniverse.SendMessage(_Entity, "Hello, This is just an example.", 2005);
        }
        
    }
    public class InternalUniverse
    {
        public  static void SendMessage(Character _Char, string Message, UInt16 type)
        {
            switch (type)
            {
                case 2005: // Top

                    Console.WriteLine("[TOP]"+_Char.Name + ": " + Message + "");
                    break;

                case 2000: // Regular

                    Console.WriteLine(_Char.Name + ": " + Message + "");
                    break;

                case 2072: // Broadcast

                    Console.WriteLine("[BROADCAST]"+_Char.Name + ": " + Message + "");
                    break;

                case 111: // SYSTEM

                    Console.WriteLine("[SYSTEM]" + _Char.Name + ": " + Message + "");
                    break;
            }

            _Char._LastAction = Character.LastAction.Talk;
            _Char.LastActionTime = DateTime.Now;
        }
    }

}
If you want to omit some maps under
Code:
 Public DateTime LastActionTime;
put something like this

Code:
public UInt16[] OmittedMaps = new UInt16[5] { 1002, 1015, 1050, 1323, 1564 };
Then at this part
Code:
 if (Entity.LastActionTime.Minute > 15) // The Entity's last action is greater than 15 minutes..kick
                {
                    Console.WriteLine(Entity.Name + " is AFK..being kicked");
                    Entity.Drop();
                }
Change it to

Code:
if (Entity.LastActionTime.Minute > 15) // The Entity's last action is greater than 15 minutes..kick
                {
                    if (Entity.OmittedMaps.Contains(Entity.MapId))
                        Console.WriteLine(Entity.Name + " is AFK BUT!!! is allowed to stay online due to training ground or somereason");
                    else
                    {
                        Console.WriteLine(Entity.Name + " is AFK..being kicked");
                        Entity.Drop();
                    }
                }
reply also.. want to know if it helped u ><
03/07/2010 18:36 Paralyzer[GM]#15
THANK YOU!

but were do I put

Code:
[B][B]using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Timers;
/* AFK Timer Project..Quick Example */
/* EP-PN © 2010 */
namespace AFKTimerProjectQuick
{
    public class Program
    {
        public static void Check(Character Entity)
        {
            if (Entity._LastAction == Character.LastAction.Fighting || Entity._LastAction == Character.LastAction.Move || Entity._LastAction == Character.LastAction.Talk)
            {
                if (Entity.LastActionTime.Minute > 15) // The Entity's last action is greater than 15 minutes..kick
                {
                    Console.WriteLine(Entity.Name + " is AFK..being kicked");
                    Entity.Drop();
                }
            }
           
        }
        static void Main(string[] args)
        {
            Console.Title = "AFK Timer Quick Example v1.0";
            Character startChar = new Character();
            Console.ReadLine();
            
        }
    }
    public class Character
    {
        public string Name;
        public byte Level;
        public UInt16 MapId;
        public UInt16 X_Cord;
        public UInt16 Y_Cord;
        public Timer AFKTimer = new Timer();
        public LastAction _LastAction;
        public DateTime LastActionTime;
        public enum LastAction
        {
            Talk,
            Move,
            Fighting,
        }
        

        public Character()
        {
            AFKTimer.Interval = 1000;
            AFKTimer.Elapsed += new ElapsedEventHandler(AFKTimer_Elapsed);
            AFKTimer.Start();
        }

        

        void AFKTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            Program.Check(this);
        }
        internal void Tele(UInt16 x, UInt16 y)
        {
            X_Cord = x;
            Y_Cord = y;
            _LastAction = LastAction.Move;
            LastActionTime = DateTime.Now;
        }
        internal void Drop()
        {
           // Kick
        }
    }
    public class Client
    {
        Character _Entity = new Character();
        Character subAttacker = new Character();

        public void SendPacket()
        {
            UInt16 PacketID = new UInt16(); // Quick Example...Really does nothing..

            switch (PacketID)
            {
                /* Don't know if any are attacking or moving or talking, but you should see what i mean */

                case 21: // Attack
                    Attack(_Entity, subAttacker);
                    break;

                case 133: // Move
                    Move();
                    break;

                case 1018: // Talk
                    Chat();
                    break;
            }
        }
        public void Attack(Character Attacker, Character Attacked)
        {
            // Attacking Calculations
            Attacker._LastAction = Character.LastAction.Fighting;
            Attacker.LastActionTime = DateTime.Now;

            Attacked._LastAction = Character.LastAction.Fighting;
            Attacked.LastActionTime = DateTime.Now;
        }
        public void Move()
        {
            System.Random newMove = new Random();
            int _x = newMove.Next(1, 999);
            int _y = newMove.Next(1, 999);
            _Entity.Tele(Convert.ToUInt16(_x), Convert.ToUInt16(_y));

        }
        public void Chat()
        {
            // Blah Blah Blah..Check Commands
            InternalUniverse.SendMessage(_Entity, "Hello, This is just an example.", 2005);
        }
        
    }
    public class InternalUniverse
    {
        public  static void SendMessage(Character _Char, string Message, UInt16 type)
        {
            switch (type)
            {
                case 2005: // Top

                    Console.WriteLine("[TOP]"+_Char.Name + ": " + Message + "");
                    break;

                case 2000: // Regular

                    Console.WriteLine(_Char.Name + ": " + Message + "");
                    break;

                case 2072: // Broadcast

                    Console.WriteLine("[BROADCAST]"+_Char.Name + ": " + Message + "");
                    break;

                case 111: // SYSTEM

                    Console.WriteLine("[SYSTEM]" + _Char.Name + ": " + Message + "");
                    break;
            }

            _Char._LastAction = Character.LastAction.Talk;
            _Char.LastActionTime = DateTime.Now;
        }
    }[/B][/B]


}