public void PingTimerCallBack(object e)
{
try
{
TimeSpan t = DateTime.Now - lastPing;
if (client.State) Ping();
if (!client.State && Player != null)
{
Console.BackgroundColor = ConsoleColor.Black;
MsSQL.UpdateData("UPDATE users SET online='" + 0 + "' WHERE id='" + Player.AccountName + "'");
MsSQL.UpdateData("UPDATE character SET online='0' WHERE id='" + Character.Information.CharacterID + "'");
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("[@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@]");
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("@Evo-Debug : Srevo has debugged: {0}", Character.Information.Name);
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("[@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@]");
Console.ForegroundColor = ConsoleColor.Green;
if (Character.Grabpet.Active) UnSummonPetLogoff(Character.Grabpet.Details.UniqueID);
if (Character.Attackpet.Active) UnSummonPetLogoff(Character.Attackpet.Details.UniqueID);
if (Character.Network.Party != null)
{
LeaveParty();
}
if (Character.Network.Guild.Guildid != 0)
{
Character.Information.Online = 0;
//Send packets to network and spawned players
foreach (int member in Character.Network.Guild.Members)
{
//Make sure the member is there
if (member != 0)
{
//We dont send this info to the invited user.
if (member != Character.Information.CharacterID)
{
//If the user is not the newly invited member get player info
Systems tomember = GetPlayerMainid(member);
//Send guild update packet
if (tomember != null)
{
tomember.client.Send(Packet.GuildUpdate(Character, 6, Character.Information.CharacterID, 0,0));
}
}
}
}
Character.Network.Guild.Members.Remove(Character.Information.CharacterID);
Character.Network.Guild.MembersClient.Remove(this.client);
}
if (this.Character.Transport.Right) this.Character.Transport.Horse.DeSpawnMe();
if (this.Character.Grabpet.Active) this.Character.Grabpet.Details.DeSpawnMe();
if (this.Character.Network.Exchange.Window) this.Exchange_Close();
#region Friend list
MsSQL ms = new MsSQL("SELECT * FROM friends WHERE owner='" + Character.Information.CharacterID + "'");
int count = ms.Count();
if (count >= 0)
{
using (SqlDataReader reader = ms.Read())
{
while (reader.Read())
{
int getid = reader.GetInt32(2);
Systems sys = GetPlayerid(getid);
if (sys != null)
{
sys.client.Send(Packet.FriendData(Character.Information.CharacterID, 4, Character.Information.Name, Character, true));
}
}
}
}
else
{
client.Send(Packet.SendFriendListstatic());
}
#endregion
BuffAllClose();
DeSpawnMe();
SavePlayerPosition();
SavePlayerInfo();
this.client.Close();
this.Character.Dispose();
this.Dispose();
Character.InGame = false;
Disconnect("normal");
lock (Systems.clients)
{
Systems.clients.Remove(this);
}
}
}
catch (NullReferenceException nex)
{
Console.WriteLine("Timer.PingTimerCallBack: {0}", nex);
PingStop();
}
catch (Exception ex)
{
Console.WriteLine("Debug error: {0}", ex);
}
}