FriendData() public static method

public static FriendData ( int target, byte type, string name, character c, bool state ) : byte[]
target int
type byte
name string
c character
state bool
return byte[]
Ejemplo n.º 1
0
        /////////////////////////////////////////////////////////////////////////////////
        // Friend add response
        /////////////////////////////////////////////////////////////////////////////////
        void FriendAddResponse()
        {
            try
            {
                PacketReader reader    = new PacketReader(PacketInformation.buffer);
                int          Inviterid = reader.Int32();
                int          Myid      = reader.Int32();
                byte         State     = reader.Byte();
                reader.Close();

                Systems sys = GetPlayer(Inviterid);
                if (sys != null)
                {
                    if (State == 0)
                    {
                        //Declined
                        client.Send(Packet.FriendDecline(Character.Information.Name));
                        sys.client.Send(Packet.FriendDecline(Character.Information.Name));
                    }
                    else
                    {
                        //Accepted
                        sys.client.Send(Packet.FriendData(Myid, 2, Character.Information.Name, Character, false));
                        client.Send(Packet.FriendData(Inviterid, 2, sys.Character.Information.Name, sys.Character, false));
                        MsSQL.InsertData("INSERT INTO friends (owner,friend_name,model_info) VALUES ('" + Character.Information.CharacterID + "','" + sys.Character.Information.CharacterID + "','" + sys.Character.Information.Model + "')");
                        MsSQL.InsertData("INSERT INTO friends (owner,friend_name,model_info) VALUES ('" + sys.Character.Information.CharacterID + "','" + Character.Information.CharacterID + "','" + Character.Information.Model + "')");
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Friend Add Response Error {0}", ex);
                Systems.Debugger.Write(ex);
            }
        }
Ejemplo n.º 2
0
        /////////////////////////////////////////////////////////////////////////////////
        // Remove Friends
        /////////////////////////////////////////////////////////////////////////////////
        void FriendRemoval()
        {
            try
            {
                //Read client packet data
                PacketReader reader = new PacketReader(PacketInformation.buffer);
                int          target = reader.Int32();
                reader.Close();
                //Get player information
                Systems sys = GetPlayerid(target);

                //Remove friend from our list query
                MsSQL.UpdateData("DELETE FROM friends WHERE owner='" + Character.Information.CharacterID + "' AND friend_name='" + target + "'");
                MsSQL.UpdateData("DELETE FROM friends WHERE owner='" + target + "' AND friend_name='" + Character.Information.CharacterID + "'");

                //Remove friend from our list packet
                client.Send(Packet.FriendData(target, 3, "", Character, false));
                client.Send(Packet.FriendRemovalTarget(target));
                //Remove friend from friend id packet
                if (sys != null)
                {
                    sys.Send(Packet.FriendData(sys.Character.Information.UniqueID, 3, "", Character, false));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Friend removal error {0}", ex);
                Systems.Debugger.Write(ex);
            }
        }
Ejemplo n.º 3
0
 /////////////////////////////////////////////////////////////////////////////////
 // Load our personal friends list.
 /////////////////////////////////////////////////////////////////////////////////
 #region Friend list
 void GetFriendsList()
 {
     //Wrap our function inside a catcher
     try
     {
         //Set new sql query to get friend information
         MsSQL ms = new MsSQL("SELECT * FROM friends WHERE owner='" + Character.Information.CharacterID + "'");
         //Count our friends
         int count = ms.Count();
         //If we have a friend in the list
         if (count > 0)
         {
             //Send our packet
             client.Send(Packet.SendFriendList(Convert.ToByte(count), Character));
             //Open new sql data reader
             using (SqlDataReader reader = ms.Read())
             {
                 //While our sql data reader is reading
                 while (reader.Read())
                 {
                     //Get player id information of friend
                     int getid = reader.GetInt32(2);
                     //Get detailed information for our friend
                     Systems sys = GetPlayerid(getid);
                     //If the character is online
                     if (sys != null)
                     {
                         //We send online state change packet
                         sys.client.Send(Packet.FriendData(Character.Information.CharacterID, 4, Character.Information.Name, Character, false));
                     }
                 }
             }
             //Close our sql reader
             ms.Close();
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Error loading friends list {0} ", ex);
         Systems.Debugger.Write(ex);
     }
 }
Ejemplo n.º 4
0
 void Player_Wait_CallBack(object e)
 {
     try
     {
         if (Character.Information.Quit)
         {
             //##############################################
             // checks before logout
             //##############################################
             if (Character.Position.Walking)
             {
                 Character.Position.RecordedTime = 0;
                 Timer.Movement.Dispose();
                 Timer.Movement = null;
             }
             //##############################################
             // checks before logout
             //##############################################
             if (Character.Information.CheckParty)
             {
                 LeaveParty();
             }
             //##############################################
             // checks before logout
             //##############################################
             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);
             }
             //##############################################
             // checks before logout
             //##############################################
             if (Character.Transport.Right)
             {
                 Character.Transport.Horse.DeSpawnMe();
             }
             if (Character.Grabpet.Active)
             {
                 UnSummonPetLogoff(Character.Grabpet.Details.UniqueID);
             }
             if (Character.Attackpet.Active)
             {
                 UnSummonPetLogoff(Character.Attackpet.Details.UniqueID);
             }
             if (Character.Network.Exchange.Window)
             {
                 Exchange_Close();
             }
             //##############################################
             // checks before logout
             //##############################################
             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));
                         }
                     }
                 }
             }
             //##############################################
             // Send packet leave game
             //##############################################
             client.Send(Packet.EndLeaveGame());
             //##############################################
             // Updated database
             //##############################################
             MsSQL.UpdateData("UPDATE character SET online='0' WHERE id='" + Character.Information.CharacterID + "'");
             //##############################################
             // Remove all remaining parts
             //##############################################
             BuffAllClose();
             DeSpawnMe();
             SavePlayerPosition();
             SavePlayerInfo();
             this.client.Close();
             this.Character.Dispose();
             this.Dispose();
             Character.InGame = false;
             Disconnect("normal");
         }
         Timer.Logout.Dispose();
     }
     catch (Exception ex)
     {
         Console.WriteLine("Logout error: {0}", ex);
     }
 }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
 void PrivateMessageSend()
 {
     try
     {
         //Create new packet reader for reading packet data
         PacketReader Reader = new PacketReader(PacketInformation.buffer);
         //Read lenght of charactername we send the message to
         short ToCharacterLen = Reader.Int16();
         //Read the name of the character we send the message to
         string ToCharacter = Reader.String(ToCharacterLen);
         //Read lenght of message characters
         short MessageLen = Reader.Int16();
         //Read message
         string Message = Reader.String(MessageLen);
         //Close packet reader
         Reader.Close();
         //Create new mssql query for sending and checking
         MsSQL ms = new MsSQL("SELECT * FROM character WHERE name='" + ToCharacter + "'");
         //Check if the player exists
         int PlayerExists = ms.Count();
         //If the player exists
         if (PlayerExists > 0)
         {
             //First get details of the player we send the message to.
             Systems sys = GetPlayerName(ToCharacter);
             //Make sure we dont get a null error
             if (sys.Character != null)
             {
                 //Check how many messages the player has if inbox is full or not
                 int TargetMessageCount = MsSQL.GetRowsCount("SELECT * FROM message WHERE receiver='" + sys.Character.Information.CharacterID + "'");
                 //If less then 50 we continue
                 if (TargetMessageCount < 50)
                 {
                     //Set temp int to character data for new message order
                     sys.Character.Information.MessageCount = TargetMessageCount;
                     //Insert new message into the database
                     MsSQL.InsertData("INSERT INTO message (sender, receiver, message, status, time) VALUES ('" + Character.Information.Name + "','" + ToCharacter + "','" + Message + "','0','" + DateTime.Now + "')");
                     //Send packet message has been send to our client
                     client.Send(PrivateMessageRespond(2));
                     //Send packet to receiver information new message has arrived
                     sys.Send(Packet.FriendData(sys.Character.Information.UniqueID, 5, ToCharacter, Character, false));
                 }
                 //If inbox is full
                 else
                 {
                     //Send message to sender and receiver inbox full
                     client.Send(PrivateMessageRespond(3));
                     sys.client.Send(PrivateMessageRespond(3));
                 }
             }
         }
         //If player doesn't exist
         else
         {
             //Send packet message failed to send to our client.
             client.Send(PrivateMessageRespond(1));
         }
     }
     //Catch any bad exception errors
     catch (Exception ex)
     {
         //Write information to the console
         Console.WriteLine("Error sending messages : {0}" + ex);
         //Write info to the debug logger.
         Systems.Debugger.Write(ex);
     }
 }