PromoteOrDisband() публичный статический Метод

public static PromoteOrDisband ( byte information ) : byte[]
information byte
Результат byte[]
Пример #1
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);
            }
        }
Пример #2
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);
            }
        }