GuildUpdate() public static method

public static GuildUpdate ( character c, byte type, int memberid, int permissions, int donatedgp ) : byte[]
c character
type byte
memberid int
permissions int
donatedgp int
return byte[]
Beispiel #1
0
 void GetGuildData()
 {
     //Wrap our function inside a catcher
     try
     {
         //If the player is in a guild
         if (this.Character.Network.Guild.Guildid > 0)
         {
             if (!CheckGuildMemberAdd(Character))
             {
                 Character.Network.Guild.Members.Add(this.Character.Information.CharacterID);
                 Character.Network.Guild.MembersClient.Add(this.client);
             }
             //Send data begin opcode
             client.Send(Packet.SendGuildStart());
             //Send date
             client.Send(Packet.SendGuildInfo(this.Character.Network.Guild));
             //Send end data
             client.Send(Packet.SendGuildEnd());
             //Send detail information
             Send(Packet.SendGuildInfo2(this.Character));
             //Update to all guild members (online state).
             if (Character.Network.Guild.Guildid != 0)
             {
                 Character.Information.Online = 1;
                 //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));
                             }
                         }
                     }
                 }
             }
         }
         //Get union data
         LoadUnions();
     }
     catch (Exception ex)
     {
         Console.WriteLine("Get guild data error {0}", ex);
         Systems.Debugger.Write(ex);
     }
 }
Beispiel #2
0
        void GuildTransferLeaderShip()
        {
            try
            {
                //Create new packet reader
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                //Read guild id
                int Guildid = Reader.Int32();
                //Read guild member id to transfer to
                int GuildMemberID = Reader.Int32();
                //Close reader
                Reader.Close();

                //Get detailed player information
                Systems NewLeader = GetPlayerid(GuildMemberID);

                //Update database
                MsSQL.InsertData("UPDATE guild_members SET guild_rank='10',guild_perm_join='0',guild_perm_withdraw='0',guild_perm_union='0',guild_perm_storage='0',guild_perm_notice='0' WHERE guild_member_id='" + Character.Information.CharacterID + "'");
                MsSQL.InsertData("UPDATE guild_members SET guild_rank='0',guild_perm_join='1',guild_perm_withdraw='1',guild_perm_union='1',guild_perm_storage='1',guild_perm_notice='1' WHERE guild_member_id='" + GuildMemberID + "'");

                //Repeat for each member in our guild
                foreach (int member in Character.Network.Guild.Members)
                {
                    //Make sure member is not null
                    if (member != 0)
                    {
                        //Get information for the guildmember
                        Systems guildmember = GetPlayerMainid(member);
                        //Make sure the guildmember isnt null
                        if (guildmember != null)
                        {
                            //Send update packet of new leader
                            guildmember.client.Send(Packet.GuildUpdate(Character, 3, GuildMemberID, 0, 0));
                        }
                    }
                }
                //Send message to old owner
                PacketWriter Writer = new PacketWriter();
                //Add opcode
                Writer.Create(Systems.SERVER_GUILD_TRANSFER_MSG);
                //Static byte 1
                Writer.Byte(1);
                //Send bytes to client
                client.Send(Writer.GetBytes());
            }
            //If a bad exception error happens
            catch (Exception ex)
            {
                //Write information to the console
                Console.WriteLine("Guild Transfer Error: {0}", ex);
                //Write information to the debug log
                Systems.Debugger.Write(ex);
            }
        }
Beispiel #3
0
        void GuildLeave()
        {
            //Write our function inside a catcher
            try
            {
                //Send required packets to network
                foreach (int member in Character.Network.Guild.Members)
                {
                    //Make sure member s not null
                    if (member != 0)
                    {
                        //Get information for the guildmember
                        Systems guildmember = GetPlayerMainid(member);
                        //Make sure the guildmember isnt null
                        if (guildmember != null)
                        {
                            //Send update packet
                            guildmember.client.Send(Packet.GuildUpdate(Character, 12, 0, 0, 0));
                        }
                    }
                }

                //Send public packet to in range players (removal guild name).
                Send(Packet.GuildKick(Character.Information.UniqueID));
                //Removal from guild
                client.Send(Packet.GuildLeave());
                //Send normal state packet
                client.Send(Packet.StatePack(Character.Information.UniqueID, 0x04, 0x00, false));
                //Count new members minus 1
                int Membercount = Character.Network.Guild.Members.Count - 1;
                //Update database
                MsSQL.InsertData("UPDATE guild SET guild_members_t='" + Membercount + "' WHERE guild_name='" + Character.Network.Guild.Name + "'");
                //Remove the player from database
                MsSQL.UpdateData("DELETE from guild_members where guild_member_id='" + Character.Information.CharacterID + "'");
                //If the guild has a union
                if (Character.Network.Guild.UniqueUnion != 0)
                {
                    //Set boolean unionactive to false
                    Character.Network.Guild.UnionActive = false;
                    //Remove the member from union member list
                    Character.Network.Guild.UnionMembers.Remove(Character.Information.CharacterID);
                }
                //Cleanup character
                CleanUp(this);
                //Reload information
                LoadPlayerGuildInfo(true);
            }
            //Catch bad exception errors
            catch (Exception ex)
            {
                //Write information the the debug log
                Systems.Debugger.Write(ex);
            }
        }
Beispiel #4
0
        void GuildMessage()
        {
            //Wrap our function inside a catcher
            try
            {
                //Create new packet reader
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                //Read short int16 for title lenght
                short TitleL = Reader.Int16();
                //Read string for title
                string Title = Reader.String(TitleL);
                //Read short Message lenght
                short MessageL = Reader.Int16();
                //Read message
                string Message = Reader.String(MessageL);
                //Close reader
                Reader.Close();

                //Update database guild message title and message
                MsSQL.InsertData("UPDATE guild SET guild_news_t='" + Title + "',guild_news_m='" + Message + "' WHERE guild_name='" + Character.Network.Guild.Name + "'");

                //Set new message info to current member for sending packet update.
                Character.Network.Guild.NewsTitle   = Title;
                Character.Network.Guild.NewsMessage = Message;
                //Repeat for each member in our guild
                foreach (int member in Character.Network.Guild.Members)
                {
                    //Make sure the member is there
                    if (member != 0)
                    {
                        //Get detailed information from member main id
                        Systems characterinformation = GetPlayerid(member);
                        //Set the current member news title and message information
                        characterinformation.Character.Network.Guild.NewsMessage = Message;
                        characterinformation.Character.Network.Guild.NewsTitle   = Title;
                        //Send packet to the member to update guild message.
                        characterinformation.client.Send(Packet.GuildUpdate(characterinformation.Character, 11, 0, 0, 0));
                    }
                }
            }
            //Catch any bad exception error
            catch (Exception ex)
            {
                //Write error to the console
                Console.WriteLine("Guild Message Error: {0}", ex);
                //Write information to the debug log
                Systems.Debugger.Write(ex);
            }
        }
Beispiel #5
0
 //When player logs off
 public void RemoveMeFromGuildDisconnect(guild g, character c)
 {
     //Repeat for each client in members of guild
     foreach (Client member in g.MembersClient)
     {
         //Make sure the client is not null
         if (member != null)
         {
             //Make sure the client is not the one of the player that logs off
             if (member != client)
             {
                 //Send packet to client
                 member.Send(Packet.GuildUpdate(c, 6, 0, 0, 0));
             }
         }
     }
 }
Beispiel #6
0
        void GuildPromote()
        {
            try
            {
                //Read client information int32 id
                PacketReader reader  = new PacketReader(PacketInformation.buffer);
                int          guildid = reader.Int32();
                reader.Close();

                //When a guild has reached its max level
                if (Character.Network.Guild.Level == 5)
                {
                    //Send packet to client and return (Message level up max).
                    client.Send(Packet.IngameMessages(Systems.SERVER_GUILD_WAIT, IngameMessages.UIIT_MSG_ERROR_GUILD_LEVEL_UP_FULL));
                    return;
                }
                //Definition for gold needed
                int GoldRequired;
                //Definition for guild points needed
                int GuildPointRequired;
                //Check if player is allready in process of upgrading
                if (!IsUpgrading)
                {
                    //Set bool to true, so we cant dupe
                    IsUpgrading = true;
                    //Load player guild information before we continue (Check last info).
                    LoadPlayerGuildInfo(false);
                    //Create switch on guildl evel
                    switch (Character.Network.Guild.Level)
                    {
                    case 1:
                        GoldRequired       = 3000000;
                        GuildPointRequired = 5400;
                        break;

                    case 2:
                        GoldRequired       = 9000000;
                        GuildPointRequired = 50400;
                        break;

                    case 3:
                        GoldRequired       = 15000000;
                        GuildPointRequired = 135000;
                        break;

                    case 4:
                        GoldRequired       = 21000000;
                        GuildPointRequired = 378000;
                        break;

                    default:
                        return;
                    }
                    //Set new guild level definition + 1
                    int NewLevel = Character.Network.Guild.Level + 1;
                    //Set new guild storage slot  amount
                    int NewStorageSlots = Character.Network.Guild.StorageSlots + 30;
                    //If character's gold is not enough
                    if (Character.Information.Gold < GoldRequired)
                    {
                        //Send message to client
                        client.Send(Packet.IngameMessages(SERVER_GUILD_PROMOTE_MSG, IngameMessages.UIIT_MSG_ERROR_GUILD_LEVEL_UP_GOLD_DEFICIT));
                        return;
                    }
                    //Not enough guildpoints
                    if (Character.Network.Guild.PointsTotal < GuildPointRequired)
                    {
                        //Send client message
                        client.Send(Packet.IngameMessages(SERVER_GUILD_PROMOTE_MSG, IngameMessages.UIIT_MSG_ERROR_GUILD_LEVEL_UP_GP_DEFICIT));
                        return;
                    }
                    //Max level
                    if (Character.Network.Guild.Level == 5)
                    {
                        //Send client message
                        client.Send(Packet.IngameMessages(SERVER_GUILD_PROMOTE_MSG, IngameMessages.UIIT_MSG_ERROR_GUILD_LEVEL_UP_FULL));
                        return;
                    }
                    //If everything else is fine
                    else
                    //Upgrade guild initiate
                    {
                        //If max level return just incase.
                        if (Character.Network.Guild.Level == 5)
                        {
                            return;
                        }
                        //Reduct guildpoints
                        Character.Network.Guild.PointsTotal -= GuildPointRequired;
                        //If the upgrade is final upgrade set points to 0
                        if (Character.Network.Guild.Level == 4)
                        {
                            Character.Network.Guild.PointsTotal = 0;
                        }
                        //Reduct gold
                        Character.Information.Gold -= GoldRequired;
                        //Send update information to client
                        client.Send(Packet.InfoUpdate(1, Character.Network.Guild.PointsTotal, 0));
                        //Send success message to client
                        client.Send(Packet.PromoteOrDisband(2));
                        //Update guild in database
                        MsSQL.UpdateData("UPDATE guild SET guild_level='" + NewLevel + "',guild_points='" + Character.Network.Guild.PointsTotal + "',guild_storage_slots='" + NewStorageSlots + "' WHERE guild_name='" + Character.Network.Guild.Name + "'");
                        //Repeat for each member in our guild
                        foreach (int member in Character.Network.Guild.Members)
                        {
                            //Check if memeber is not null
                            if (member != 0)
                            {
                                //Get detailed member information
                                Systems memberinfo = GetPlayerMainid(member);
                                //Make sure the member is not null
                                if (memberinfo != null)
                                {
                                    //Reload information for the current guild member
                                    memberinfo.LoadPlayerGuildInfo(false);
                                    //Send guild update packet for current guild member
                                    memberinfo.client.Send(Packet.GuildUpdate(Character, 5, 0, 0, 0));
                                }
                            }
                        }
                        //Save player's gold
                        SaveGold();
                        //Send update gold packet to client
                        client.Send(Packet.UpdateGold(Character.Information.Gold));
                    }
                }
                //Disable the bool so we can upgrade again
                IsUpgrading = false;
            }
            //If any error accures
            catch (Exception ex)
            {
                //Write error to the console
                Console.WriteLine("Guild Promote Error: {0}", ex);
                //Write error to debug log
                Systems.Debugger.Write(ex);
            }
        }
Beispiel #7
0
        void GuildPermissions()
        {
            try
            {
                //Create new packet reader
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                //Skip first
                Reader.Skip(1);
                //Read member id
                int memberid = Reader.Int32();
                //Read permission byte
                byte permissions = (byte)Reader.Int32();
                //Set new char bits 8
                char[] bits = new char[8];
                //Repeat for each 8 bits
                for (int i = 0; i < 8; ++i)
                {
                    bits[i] = (char)0;
                }
                //Convert bits to string / to char array
                bits = Convert.ToString(permissions, 2).ToCharArray();
                //Close reader
                Reader.Close();
                //Set amount to player targetindex
                int targetindex = this.Character.Network.Guild.MembersInfo.FindIndex(i => i.MemberID == memberid);
                //If character is online
                if (this.Character.Network.Guild.MembersInfo[targetindex].Online)
                {
                    //Get detailed player information
                    Systems member = GetPlayerMainid(memberid);
                    //Set bits
                    member.Character.Network.Guild.joinRight         = bits[4] == '1' ? true : false;
                    member.Character.Network.Guild.withdrawRight     = bits[3] == '1' ? true : false;
                    member.Character.Network.Guild.unionRight        = bits[2] == '1' ? true : false;
                    member.Character.Network.Guild.guildstorageRight = bits[0] == '1' ? true : false;
                    member.Character.Network.Guild.noticeeditRight   = bits[1] == '1' ? true : false;
                }
                // set new amount to every guild members guild class
                foreach (int m in Character.Network.Guild.Members)
                {
                    //Set int index (Find member id)
                    int index = Character.Network.Guild.MembersInfo.FindIndex(i => i.MemberID == m);
                    //If the character is online
                    if (Character.Network.Guild.MembersInfo[index].Online)
                    {
                        //Get detailed information of the player
                        Systems sys = Systems.GetPlayerMainid(m);

                        //Set new guild player
                        Global.guild_player mygp = new Global.guild_player();
                        int myindex = 0;
                        //Repeat for each player
                        foreach (Global.guild_player gp in sys.Character.Network.Guild.MembersInfo)
                        {
                            //if the member id equals the player
                            if (gp.MemberID == memberid)
                            {
                                //Set my gp
                                mygp = gp;
                                //Set bits
                                mygp.joinRight         = bits[4] == '1' ? true : false;
                                mygp.withdrawRight     = bits[3] == '1' ? true : false;
                                mygp.unionRight        = bits[2] == '1' ? true : false;
                                mygp.guildstorageRight = bits[0] == '1' ? true : false;
                                mygp.noticeeditRight   = bits[1] == '1' ? true : false;
                                break;
                            }
                            //Index ++
                            myindex++;
                        }
                        //Set membersinfo index as mygp
                        sys.Character.Network.Guild.MembersInfo[myindex] = mygp;
                    }
                }
                //Update guild database information rights
                MsSQL.UpdateData("UPDATE guild_members SET guild_perm_join='" + bits[4] + "',guild_perm_withdraw='" + bits[3] + "',guild_perm_union='" + bits[2] + "',guild_perm_storage='" + bits[0] + "',guild_perm_notice='" + bits[1] + "' WHERE guild_member_id='" + memberid + "'");
                //Send to everyone in guild update of permissions
                Character.Network.Guild.Send(Packet.GuildUpdate(Character, 4, 0, permissions, 0));
            }
            //If an error happens
            catch (Exception ex)
            {
                //Write the information to the console
                Console.WriteLine("Guild permission error: {0}", ex);
                //Write information to the debug log
                Systems.Debugger.Write(ex);
            }
        }
Beispiel #8
0
        void CharacterRequest()
        {
            try
            {
                //Open packet reader
                PacketReader Reader = new PacketReader(PacketInformation.buffer);

                //Get targeted player information
                Systems sys = GetPlayer(Character.Network.TargetID);

                if (this.Character.State.UnionApply && sys.Character.State.UnionApply)
                {
                    if (Reader.Byte() == 1 && Reader.Byte() == 0)
                    {
                        //Need to sniff decline packet info
                        Character.State.UnionApply     = false;
                        sys.Character.State.UnionApply = false;
                    }
                    else
                    {
                        //Check for null and set unique id for union and insert our own guild.
                        if (sys.Character.Network.Guild.Unions == null)
                        {
                            int uniqueid = MsSQL.GetRowsCount("SELECT * FROM guild_unions");
                            sys.Character.Network.Guild.UniqueUnion = uniqueid + 1;
                            MsSQL.InsertData("INSERT INTO guild_unions (union_leader, union_guildid, union_unique_id) VALUES ('" + sys.Character.Network.Guild.Guildid + "','" + sys.Character.Network.Guild.Guildid + "','" + sys.Character.Network.Guild.UniqueUnion + "')");
                        }
                        //Update database
                        MsSQL.InsertData("INSERT INTO guild_unions (union_leader, union_guildid, union_unique_id) VALUES ('" + sys.Character.Network.Guild.Guildid + "','" + Character.Network.Guild.Guildid + "','" + sys.Character.Network.Guild.UniqueUnion + "')");

                        //Send union packet to newly joined player
                        client.Send(Packet.UnionInfo(this));

                        //Send update packet to all guilds in union
                        foreach (int member in Character.Network.Guild.Members)
                        {
                            //Make sure the member is there
                            if (member != 0)
                            {
                                //If the user is not the newly invited member get player info
                                Systems tomember = GetPlayerMainid(member);
                                //Send guild update packet
                                if (tomember != null)
                                {
                                    if (!tomember.Character.Network.Guild.SingleSend)
                                    {
                                        if (Character.Information.CharacterID != tomember.Character.Information.CharacterID)
                                        {
                                            tomember.Character.Network.Guild.SingleSend = true;
                                            tomember.client.Send(Packet.GuildUpdate(Character, 14, 0, 0, 0));
                                        }
                                    }
                                }
                            }
                        }
                        foreach (int member in Character.Network.Guild.UnionMembers)
                        {
                            //Make sure the member is there
                            if (member != 0)
                            {
                                //If the user is not the newly invited member get player info
                                Systems tomember = GetPlayerMainid(member);
                                //Send guild update packet
                                if (tomember != null)
                                {
                                    if (!tomember.Character.Network.Guild.SingleSend)
                                    {
                                        tomember.Character.Network.Guild.SingleSend = true;
                                        tomember.client.Send(Packet.GuildUpdate(Character, 14, 0, 0, 0));
                                    }
                                }
                            }
                        }
                        //Disable the bool again
                        foreach (int member in Character.Network.Guild.Members)
                        {
                            //Make sure member isnt null
                            if (member != 0)
                            {
                                //Get guildmember details
                                Systems guildmember = GetPlayerMainid(member);
                                //Make sure guildmember isnt null
                                if (guildmember != null)
                                {
                                    //Disable bool to allow resend new packets.
                                    guildmember.Character.Network.Guild.SingleSend = false;
                                }
                            }
                        }
                        //Disable the bool again
                        foreach (int member in Character.Network.Guild.UnionMembers)
                        {
                            //Make sure member isnt null
                            if (member != 0)
                            {
                                //Get guildmember details
                                Systems guildmember = GetPlayerMainid(member);
                                //Make sure guildmember isnt null
                                if (guildmember != null)
                                {
                                    //Disable bool to allow resend new packets.
                                    guildmember.Character.Network.Guild.SingleSend = false;
                                }
                            }
                        }
                        //Reset bools
                        Character.State.UnionApply     = false;
                        sys.Character.State.UnionApply = false;
                    }
                }
                //------------------------------------- [ Exchange invite ] -------------------------------------//
                else if (this.Character.State.Exchanging && sys.Character.State.Exchanging)
                {
                    if (Reader.Byte() == 1 && Reader.Byte() == 0)
                    {
                        sys.client.Send(Packet.Exchange_Cancel());
                        Character.State.Exchanging     = false;
                        sys.Character.State.Exchanging = false;
                    }
                    else
                    {
                        sys.client.Send(Packet.OpenExhangeWindow(1, this.Character.Information.UniqueID));
                        client.Send(Packet.OpenExhangeWindow(sys.Character.Information.UniqueID));

                        Character.Network.Exchange.Window       = true;
                        Character.Network.Exchange.ItemList     = new List <DarkEmu_GameServer.Global.slotItem>();
                        sys.Character.Network.Exchange.Window   = true;
                        sys.Character.Network.Exchange.ItemList = new List <DarkEmu_GameServer.Global.slotItem>();
                    }
                }
                //------------------------------------- [ Guild invite ] -------------------------------------//
                else if (this.Character.State.GuildInvite && sys.Character.State.GuildInvite)
                {
                    //If byte equals 2 the type is denied
                    if (Reader.Byte() == 2)
                    {
                        //Denied request
                        Character.State.GuildInvite     = false;
                        sys.Character.State.GuildInvite = false;
                        //Send refused packet to sender
                        sys.client.Send(Packet.IngameMessages(SERVER_GUILD, IngameMessages.UIIT_MSG_GUILDERR_JOIN_GUILD_REFUSED));
                    }
                    //If not denied we start adding the new member
                    else
                    {
                        //Invite guild member (Add member count + 1).
                        int guildmemberadd = sys.Character.Network.Guild.Members.Count + 1;
                        //Update database
                        MsSQL.InsertData("INSERT INTO guild_members (guild_id, guild_member_id, guild_rank, guild_points, guild_fortress, guild_grant, guild_perm_join, guild_perm_withdraw, guild_perm_union, guild_perm_storage, guild_perm_notice) VALUES ('" + sys.Character.Network.Guild.Guildid + "','" + Character.Information.CharacterID + "','10','0','1','" + "" + "','0','0','0','0','0')");
                        MsSQL.UpdateData("UPDATE guild SET guild_members_t='" + guildmemberadd + "' WHERE guild_name='" + sys.Character.Network.Guild.Name + "'");
                        //Reload new member and load character data for guildinfo
                        LoadPlayerGuildInfo(true);
                        //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
                                    tomember.LoadPlayerGuildInfo(true);
                                    tomember.client.Send(Packet.GuildUpdate(Character, 1, Character.Information.CharacterID, 0, 0));
                                    tomember.client.Send(Packet.GuildSetOnline(Character.Network.Guild, Character.Information.UniqueID));
                                    tomember.client.Send(Packet.GuildUpdate(Character, 6, Character.Information.CharacterID, 0, 0));
                                }
                                //Send information to the invited player
                                else
                                {
                                    //Send guild data packets to invited
                                    client.Send(Packet.SendGuildStart());
                                    client.Send(Packet.SendGuildInfo(Character.Network.Guild));
                                    client.Send(Packet.SendGuildEnd());
                                    //Load union data for new invited player
                                    LoadUnions();
                                }
                            }
                        }
                        //Set bools to false for new invite
                        Character.State.GuildInvite     = false;
                        sys.Character.State.GuildInvite = false;
                    }
                }

                //------------------------------------- [ Party invite ] -------------------------------------//
                else
                {
                    //If invitation is accepted
                    if (Reader.Byte() == 1 && Reader.Byte() == 1)
                    {
                        //First we set our main checks (Check if player is in party or not).
                        if (Character.Network.Party != null)
                        {
                            return;
                        }
                        //Set bools for check
                        Character.Information.CheckParty     = true;
                        sys.Character.Information.CheckParty = true;

                        //Set main party information
                        party JoiningParty = sys.Character.Network.Party;

                        //Check party type members allowed need message if full
                        if (JoiningParty.Type == 4 && JoiningParty.Members.Count > 3)
                        {
                            //Send party is full message to player
                            client.Send(Packet.IngameMessages(Systems.SERVER_PARTY_MESSAGES, IngameMessages.UIIT_MSG_PARTYERR_ALREADY_FULL));
                            return;
                        }
                        if (JoiningParty.Type == 5 && JoiningParty.Members.Count > 7)
                        {
                            //Send party is full message to player
                            client.Send(Packet.IngameMessages(Systems.SERVER_PARTY_MESSAGES, IngameMessages.UIIT_MSG_PARTYERR_ALREADY_FULL));
                            return;
                        }
                        //If the current count == 0 then add party and add me
                        if (JoiningParty.Members.Count == 0)
                        {
                            //Add ourselfs to the party list
                            JoiningParty.Members.Add(sys.Character.Information.UniqueID);
                            //Add our client to the party list
                            JoiningParty.MembersClient.Add(sys.client);
                            //Set party id
                            JoiningParty.ptid = Party.Count + 1;
                            //Set party network info
                            sys.Character.Network.Party = JoiningParty;
                            //Send permissions
                            sys.client.Send(Packet.Party_Member(sys.Character.Information.UniqueID));
                            //Send party data to leader
                            sys.client.Send(Packet.Party_DataMember(JoiningParty));
                            //Send party data packet to leader (Other player that joined).
                            sys.client.Send(Packet.Party_Data(2, Character.Information.UniqueID));
                            //Add invited member to the list
                            JoiningParty.Members.Add(Character.Information.UniqueID);
                            JoiningParty.MembersClient.Add(client);
                            //Set party info for invited member
                            Character.Network.Party = JoiningParty;
                            //Send permissions
                            client.Send(Packet.PartyOwnerInformation(Character.Information.UniqueID));
                            //Send party data
                            client.Send(Packet.Party_DataMember(JoiningParty));
                            //return
                            return;
                        }
                        //If there are more members in the current party
                        else
                        {
                            //Repeat for each member using count
                            for (byte b = 0; b <= JoiningParty.Members.Count - 1; b++)
                            {
                                //Get player information from [b]
                                Systems others = GetPlayer(JoiningParty.Members[b]);
                                //Send party data to member
                                others.client.Send(Packet.Party_Data(2, Character.Information.UniqueID));
                            }
                            //Add the invited member to list
                            JoiningParty.Members.Add(Character.Information.UniqueID);
                            //Add the invited client to the list
                            JoiningParty.MembersClient.Add(client);
                            //Set party
                            Character.Network.Party = JoiningParty;
                            //Send permissions
                            client.Send(Packet.PartyOwnerInformation(Character.Information.UniqueID));
                            //Send party data
                            client.Send(Packet.Party_DataMember(JoiningParty));
                            return;
                        }
                    }
                    //If denied request
                    else
                    {
                        //Send denied message to the player joining
                        client.Send(Packet.IngameMessages(Systems.SERVER_PARTY_MEMBER, IngameMessages.UIIT_MSG_PARTYERR_JOIN_PARTY_REFUSED));
                        //Set both bools to false so inviting can be done again
                        sys.Character.Information.CheckParty = false;
                        Character.Information.CheckParty     = false;
                    }
                }
            }
            //Catch bad exception errors
            catch (Exception ex)
            {
                //Write information to the console
                Console.WriteLine("Request error: {0}", ex);
                //Write information to the debug log
                Debugger.Write(ex);
            }
        }
Beispiel #9
0
        /////////////////////////////////////////////////////////////////////////////////
        // Movement
        /////////////////////////////////////////////////////////////////////////////////
        public void Movement()
        {
            try
            {
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                Character.Action.PickUping = false;
                byte Type = Reader.Byte();

                ////////////////////////////////////////////////////////////////////////////// Sky drome movement
                if (Type == 0)
                {
                    if (!Character.Stall.Stallactive && !Character.Action.PickUping && !Character.State.Die && !Character.Action.sCasting && !Character.Action.sAttack && !Character.Action.nAttack && !Character.Information.Scroll && !Character.State.Sitting && !Character.Information.SkyDroming)
                    {
                        /*
                         * if (File.FileLoad.CheckCave(Character.Position.xSec, Character.Position.ySec))
                         * {
                         *  return;
                         * }
                         * else
                         * {
                         *
                         *  Character.Information.SkyDroming = true;
                         *  byte info = Reader.Byte();
                         *  ushort angle = Reader.UInt16();
                         *
                         *  Character.Information.Angle = angle / (65535.0 / 360.0);
                         *
                         *  Character.Position.packetxSec = Character.Position.xSec;
                         *  Character.Position.packetySec = Character.Position.ySec;
                         *  Character.Position.packetX = (ushort)Game.Formule.packetx(Character.Position.x, Character.Position.xSec);
                         *  Character.Position.packetY = (ushort)Game.Formule.packetx(Character.Position.x, Character.Position.xSec);
                         *
                         *  double distance = Formule.gamedistance(
                         *      Character.Position.x,
                         *      Character.Position.y,
                         *      Formule.gamex(Character.Position.x, Character.Position.xSec),
                         *      Formule.gamey(Character.Position.y, Character.Position.ySec));
                         *
                         *  Character.Position.Time = (distance / (Character.Speed.RunSpeed * 0.0768)) * 1000.0;
                         *  Character.Position.RecordedTime = Character.Position.Time;
                         *
                         *
                         *  PacketWriter Writer = new PacketWriter();
                         *  Writer.Create(Systems.SERVER_MOVEMENT);
                         *  Writer.DWord(Character.Information.UniqueID);
                         *  Writer.Byte(0);
                         *  Writer.Byte(info);
                         *  Writer.Word(angle);
                         *  Writer.Byte(1);
                         *  Writer.Byte(Character.Position.xSec);
                         *  Writer.Byte(Character.Position.ySec);
                         *  Writer.Word(Character.Position.packetX);
                         *  Writer.DWord(Character.Position.z);
                         *  Writer.Word(Character.Position.packetY);
                         *  Send(Writer.GetBytes());
                         *
                         *  StartSkyDromeTimer(1000);
                         * }*/
                    }
                }

                //------------------------- Normal movement -------------------------//
                if (Type == 1)
                {
                    //If character is in a guild
                    if (Character.Network.Guild.Guildid != 0)
                    {
                        //Repeat for each client in the guild
                        foreach (Client memberclient in Character.Network.Guild.MembersClient)
                        {
                            //Make sure the client is not null
                            if (memberclient != null)
                            {
                                //Send update packet for location of player
                                memberclient.Send(Packet.GuildUpdate(Character, 10, Character.Information.UniqueID, 0, 0));
                            }
                        }
                    }

                    if (Character.Stall.Stallactive)
                    {
                        return;
                    }
                    if (Character.Action.PickUping)
                    {
                        return;
                    }
                    StopPickUpTimer();
                    if (Character.State.Die)
                    {
                        return;
                    }
                    if (Character.Information.Scroll)
                    {
                        return;
                    }
                    if (Character.State.Sitting)
                    {
                        return;
                    }
                    if (Character.Information.SkyDroming)
                    {
                        StopSkyDromeTimer();
                    }
                    if (Character.Action.nAttack)
                    {
                        StopAttackTimer();
                        Character.Action.nAttack = false;
                    }
                    if (Character.Action.sAttack)
                    {
                        StopAttackTimer();
                        Character.Action.sAttack = false;
                    }
                    if (Character.Action.sCasting)
                    {
                        StopAttackTimer();
                        Character.Action.sCasting = false;
                    }
                    if (Character.Information.PvpWait)
                    {
                        Send(Packet.PvpInterupt(Character.Information.UniqueID));
                        Character.Information.PvpWait = false;
                        Character.Information.Pvptype = 0;
                        StopPvpTimer();
                    }
                    Character.Position.Walking = true;
                    byte  xsec = Reader.Byte();
                    byte  ysec = Reader.Byte();
                    float x, y, z;

                    if (!File.FileLoad.CheckCave(xsec, ysec))
                    {
                        x = Reader.Int16();
                        z = Reader.Int16();
                        y = Reader.Int16();
                        double distance = Formule.gamedistance(
                            Character.Position.x,
                            Character.Position.y,
                            Formule.gamex(x, xsec),
                            Formule.gamey(y, ysec));

                        Character.Position.xSec = xsec;
                        Character.Position.ySec = ysec;
                        Character.Position.wX   = Formule.gamex(x, xsec) - Character.Position.x;
                        Character.Position.wZ   = z;
                        Character.Position.wY   = Formule.gamey(y, ysec) - Character.Position.y;

                        Character.Position.packetxSec = xsec;
                        Character.Position.packetySec = ysec;
                        Character.Position.packetX    = (ushort)x;
                        Character.Position.packetZ    = (ushort)z;
                        Character.Position.packetY    = (ushort)y;

                        if (xsec != 0 && ysec != 0)
                        {
                            Send(Packet.Movement(new Global.vektor(Character.Information.UniqueID, x, z, y, xsec, ysec)));
                        }
                        if (Character.Information.Berserking)
                        {
                            Character.Position.Time = (distance / (Character.Speed.RunSpeed * 0.109)) * 1000.0;
                        }
                        else
                        {
                            Character.Position.Time = (distance / (Character.Speed.RunSpeed * 0.109)) * 1000.0;
                        }
                    }
                    else  // Added for cave telepad locations
                    {
                        x = Formule.cavegamex(Reader.Int16(), Reader.Int16()); //Reads the location and retunrs the coords for the cave postion x
                        z = Formule.cavegamez(Reader.Int16(), Reader.Int16()); //Reads the location and retunrs the coords for the cave postion z
                        y = Formule.cavegamey(Reader.Int16(), Reader.Int16()); //Reads the location and retunrs the coords for the cave postion y

                        double distance = Formule.gamedistance(Character.Position.x, Character.Position.y, Formule.cavegamex(x), Formule.cavegamey(y));

                        Character.Position.xSec = xsec;
                        Character.Position.ySec = ysec;
                        Character.Position.wX   = Formule.cavegamex(x) - Character.Position.x;
                        Character.Position.wZ   = z;
                        Character.Position.wY   = Formule.cavegamey(y) - Character.Position.y;

                        Character.Position.packetxSec = xsec;
                        Character.Position.packetySec = ysec;
                        Character.Position.packetX    = (ushort)x;
                        Character.Position.packetZ    = (ushort)z;
                        Character.Position.packetY    = (ushort)y;

                        if (xsec != 0 && ysec != 0)
                        {
                            Send(Packet.Movement(new Global.vektor(Character.Information.UniqueID, x, z, y, xsec, ysec)));
                        }
                        if (Character.Information.Berserking)
                        {
                            Character.Position.Time = (distance / (Character.Speed.BerserkSpeed * 0.0768)) * 1000.0;
                        }
                        else
                        {
                            Character.Position.Time = (distance / (Character.Speed.RunSpeed * 0.0768)) * 1000.0;
                        }
                    }

                    Reader.Close();

                    if (xsec != 0 && ysec != 0)
                    {
                        Send(Packet.Movement(new Global.vektor(Character.Information.UniqueID, x, z, y, xsec, ysec)));
                    }

                    if (Character.Grabpet.Active)
                    {
                        Send(Packet.Movement(new Global.vektor(Character.Grabpet.Details.UniqueID, x + rnd.Next(10, 25), z, y + rnd.Next(10, 25), xsec, ysec)));
                    }
                    if (Character.Attackpet.Active)
                    {
                        Send(Packet.Movement(new Global.vektor(Character.Attackpet.Details.UniqueID, x + rnd.Next(10, 25), z, y + rnd.Next(10, 25), xsec, ysec)));
                    }

                    Character.Position.RecordedTime = Character.Position.Time;
                    StartMovementTimer((int)(Character.Position.Time * 0.1));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Movement error: {0}", ex);
            }
        }
Beispiel #10
0
 void KickFromGuild()
 {
     //Wrap our function inside a catcher
     try
     {
         //Open a new packet reader
         PacketReader Reader = new PacketReader(PacketInformation.buffer);
         //Read short value lenght of name below
         short CharacterNameLen = Reader.Int16();
         //Read string charactername
         string CharacterName = Reader.String(CharacterNameLen);
         //Close packet reader
         Reader.Close();
         //Get player information
         Systems TargetCharacter = GetPlayerName(CharacterName);
         //Send required packets to network
         foreach (int member in Character.Network.Guild.Members)
         {
             //Make sure member s not null
             if (member != 0)
             {
                 //Get information for the guildmember
                 Systems guildmember = GetPlayerMainid(member);
                 //Make sure the guildmember isnt null
                 if (guildmember != null)
                 {
                     //Make sure the kicked member does not receive the packet
                     if (guildmember.Character.Information.CharacterID != TargetCharacter.Character.Information.CharacterID)
                     {
                         guildmember.client.Send(Packet.GuildUpdate(TargetCharacter.Character, 7, 0, 0, 0));
                     }
                 }
             }
         }
         //Send update packet to the kicked player
         TargetCharacter.client.Send(Packet.GuildUpdate(TargetCharacter.Character, 7, 0, 0, 0));
         //Send guild kick message packet to the kicked player
         PacketWriter Writer = new PacketWriter();
         //Add opcode
         Writer.Create(Systems.SERVER_GUILD_KICK);
         //Add static byte 1
         Writer.Byte(1);
         //Send packet to kicked member
         TargetCharacter.client.Send(Writer.GetBytes());
         //Send guildkick visual packet update to kicked player
         TargetCharacter.Send(Packet.GuildKick(TargetCharacter.Character.Information.UniqueID));
         //Remove the player from database
         MsSQL.UpdateData("DELETE from guild_members where guild_member_id='" + TargetCharacter.Character.Information.CharacterID + "'");
         //Update database
         Character.Network.Guild.TotalMembers -= 1;
         MsSQL.InsertData("UPDATE guild SET guild_members_t='" + Character.Network.Guild.TotalMembers + "' WHERE guild_name='" + Character.Network.Guild.Name + "'");
         TargetCharacter.CleanUp(TargetCharacter);
     }
     //Catch bad exception errors
     catch (Exception ex)
     {
         //Write information to the console
         Console.WriteLine("Guild Kick Error: {0}", ex);
         //Write information to the debug log
         Systems.Debugger.Write(ex);
     }
 }
Beispiel #11
0
        /////////////////////////////////////////////////////////////////////////
        //Guild Disbanding
        /////////////////////////////////////////////////////////////////////////
        #region Guild Disband
        void GuildDisband()
        {
            try
            {
                foreach (int member in Character.Network.Guild.Members)
                {
                    if (member != 0)
                    {
                        Systems guildplayer = GetPlayerMainid(member);
                        if (guildplayer != null)
                        {
                            if (guildplayer.Character.Information.CharacterID != Character.Information.CharacterID)
                            {
                                //Guild disband message packet
                                guildplayer.client.Send(Packet.GuildUpdate(Character, 2, 0, 0, 0));
                                //Remove guild name and details from player
                                Send(Packet.GuildKick(guildplayer.Character.Information.UniqueID));
                                //State packet
                                guildplayer.client.Send(Packet.StatePack(guildplayer.Character.Information.UniqueID, 4, 0, false));
                                //Set all values to null.
                                guildplayer.Character.Network.Guild.Members.Remove(guildplayer.Character.Information.CharacterID);
                                guildplayer.Character.Network.Guild.MembersClient.Remove(guildplayer.client);
                                guildplayer.Character.Network.Guild.Guildid = 0;

                                if (guildplayer.Character.Network.Guild.UniqueUnion != 0)
                                {
                                    guildplayer.Character.Network.Guild.UnionActive = false;
                                    guildplayer.Character.Network.Guild.UnionMembers.Remove(guildplayer.Character.Information.CharacterID);
                                }
                            }
                        }
                    }
                }
                //Guild disband message packet
                client.Send(Packet.GuildUpdate(Character, 2, 0, 0, 0));
                //Remove guild name and details from player
                Send(Packet.GuildKick(Character.Information.UniqueID));
                //State packet
                client.Send(Packet.StatePack(Character.Information.UniqueID, 4, 0, false));
                //Set all values to null.

                //Remove all rows that contains guildname
                MsSQL.UpdateData("DELETE FROM guild_members WHERE guild_id=" + Character.Network.Guild.Guildid + "");
                //Remove guild from guild table
                MsSQL.UpdateData("DELETE FROM guild WHERE id=" + Character.Network.Guild.Guildid + "");
                //Remove ourself
                if (Character.Network.Guild.UniqueUnion != 0)
                {
                    Character.Network.Guild.UnionActive = false;
                    Character.Network.Guild.UnionMembers.Remove(Character.Information.CharacterID);
                }

                Character.Network.Guild.Members.Remove(Character.Information.UniqueID);
                Character.Network.Guild.MembersClient.Remove(client);
                Character.Network.Guild.Guildid = 0;

                //Packet Final message
                client.Send(Packet.PromoteOrDisband(1));
            }
            catch (Exception ex)
            {
                Console.WriteLine("Guild Disband Error: {0}", ex);
                Systems.Debugger.Write(ex);
            }
        }
Beispiel #12
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);
     }
 }
Beispiel #13
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);
            }
        }
Beispiel #14
0
 void DonateGP()
 {
     //First we write our function inside a catcher
     try
     {
         //Max level of guild wont allow new gp donations.
         if (Character.Network.Guild.Level == 5)
         {
             //Send error message to client
             client.Send(Packet.IngameMessages(SERVER_GUILD_PROMOTE_MSG, IngameMessages.UIIT_MSG_GUILD_LACK_GP));
             return;
         }
         //Open our packet reader
         PacketReader reader = new PacketReader(PacketInformation.buffer);
         //Read donated gp amount (int).
         int donatedgp = reader.Int32();
         //Close packet reader
         reader.Close();
         //Anti hack checking (If donated gp higher is then the player skillpoints.
         if (donatedgp > Character.Information.SkillPoint)
         {
             return;
         }
         //Calculate total
         int totalgp = Character.Network.Guild.PointsTotal + donatedgp;
         //Set guild points total
         Character.Network.Guild.PointsTotal += donatedgp;
         //Set skill points minus donated amount
         Character.Information.SkillPoint -= donatedgp;
         //Set donated gp + donated skill points
         Character.Network.Guild.DonateGP += donatedgp;
         //Save our information (Skill points).
         SavePlayerInfo();
         //Update database total guild points
         MsSQL.UpdateData("UPDATE guild SET guild_points='" + totalgp + "' WHERE guild_name='" + Character.Network.Guild.Name + "'");
         //Update database donated player guild points amount
         MsSQL.UpdateData("UPDATE guild_members SET guild_points='" + Character.Network.Guild.DonateGP + "' WHERE guild_member_id='" + Character.Information.CharacterID + "'");
         //Send packets to donator.
         client.Send(Packet.InfoUpdate(1, totalgp, 0));
         //Send donated gp info
         PacketWriter writer = new PacketWriter();
         //Add opcode
         writer.Create(Systems.SERVER_GUILD_DONATE_GP);
         //Write static byte 1
         writer.Byte(1);
         //Write dword int value donated gp amount.
         writer.DWord(donatedgp);
         //Send bytes to client
         client.Send(writer.GetBytes());
         //Repeat for each member in our guild
         foreach (int member in Character.Network.Guild.Members)
         {
             //Make sure that the member isnt null
             if (member != 0)
             {
                 //Now we get the detailed information for each member
                 Systems guildmember = GetPlayerMainid(member);
                 //Make sure the guildmember is still there
                 if (guildmember != null)
                 {
                     //Send guild update packets to each member (Donated gp information and % bar update).
                     guildmember.client.Send(Packet.GuildUpdate(Character, 13, 0, 0, totalgp));
                     guildmember.client.Send(Packet.GuildUpdate(Character, 9, 0, 0, totalgp));
                 }
             }
         }
     }
     //Catch any bad exception error
     catch (Exception ex)
     {
         //Write information to the console
         Console.WriteLine("Donate GP Error {0}", ex);
         //Write information to the debug log.
         Systems.Debugger.Write(ex);
     }
 }