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]
}