spawndef

Member
it is possible inside a gump to call a server command ?

like [expbar , this is my command for see the expbar gump.
im trying to open from gump button to command , not to gump.
Code:
switch(info.ButtonID)
            {
                case 0:
				{
				from.CloseGump(typeof(expbar));// this is work
			        from.SendGump(new expbar(from)); // this is work
                      // but i want call the command if it possible like CommandSystem.Prefix + "expbar";
				break;
				}
}
 
you can use the initialize static method to run a command registration to open your gump, however you could also use the Login event to open the gump then too. Both would be registered with the initialize method, it's a special method that the core looks for when compiling scripts and runs it at the appropriate time.
 
i put InvokeCommand
Code:
[LIST=1]
[*]switch(info.ButtonID)
[*]           {
[*]               case 0:
[*]               {
[*]               this.InvokeCommand("expbar");
[*]               break;
[*]               }
[*]}
[*]
View attachment aplay.elderultima.com_error.bmp_.jpg
and my top of page
Code:
[*]using System;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Commands;
using Server.Targeting;
using Server.Mobiles;
using Server.Accounting;
using Server.Engines.XmlSpawner2;
[*]
[/LIST]
 

Attachments

  • error.bmp
    1.4 MB · Views: 5
Add

Code:
private void InvokeCommand(string c)
{
CommandSystem.Handle(this.m_From, String.Format("{0}{1}", CommandSystem.Prefix, c));
}

Or Reference AdminGump and reuse the method.
 
Please post the whole script....I see missing brackets, expecting the whole class or namespace is missing.
 
Code:
using System;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Commands;
using Server.Targeting;
using Server.Mobiles;
using Server.Accounting;
//using Server.SlayerTitles;
using Server.Engines.XmlSpawner2;
using Scripts.Mythik.Systems.Achievements.Gumps;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using Server.Targets;

namespace Server.Gumps
{
    public class logooos : Gump
    {
        public logooos(Mobile m)
            : base(0, 0)
        {
        Closable = false;
        Disposable = false;
        Dragable = false;
        Resizable = false;

		AddPage(0);
        AddButton(10, 60, 22124, 22125, 1, GumpButtonType.Reply, 0);
        }
		
		public override void OnResponse(NetState sender, RelayInfo info)
		{
			Mobile from = sender.Mobile;
			from.CloseGump(typeof(logooos));
			from.SendGump(new logooosMENU(from));
		}
	}
	
    private void InvokeCommand(string feats)
    {
    CommandSystem.Handle(this.m_From, String.Format("{0}{1}", CommandSystem.Prefix, feats));
    }
	
	public class logooosMENU : Gump
    {
        public logooosMENU(Mobile m)
            : base(0, 0)
        {
        Closable = false;
        Disposable = false;
        Dragable = false;
        Resizable = false;

		AddPage(0);
		AddButton(10, 60, 22125, 22124, 0, GumpButtonType.Reply, 0);
		AddImage(1, 84, 39);
		AddButton(30, 155, 4005, 4006, 1, GumpButtonType.Reply, 1);

		AddLabel(25, 110, 0x481, "Fast command");
		AddLabel(65, 155, 0x481, "Achievement");
        }
		
		public override void OnResponse(NetState sender, RelayInfo info)
        {
            Mobile from = sender.Mobile;

			Account acct = from.Account as Account;
			//SlayerTitleAttachment attachment = SlayerTitleSystem.FindAttachment(from);

            switch(info.ButtonID)
            {
                case 0:
				{
				from.CloseGump(typeof(logooosMENU));
			    from.SendGump(new logooos(from));
				break;
				}
				case 1:
				{
                                InvokeCommand( "feats" ); // MythikAchievmentSystem-master
				}
            }
        }
	}
}

MythikAchievmentSystem-master

Code:
#define STOREONITEM

using Server;
using System;
using System.Collections.Generic;
using Server.Mobiles;
using Server.Items;
using Server.Commands;
using Server.Misc;

#if STOREONITEM
#else
using Scripts.Mythik.Mobiles;
#endif

using Scripts.Mythik.Systems.Achievements.Gumps;

namespace Scripts.Mythik.Systems.Achievements
{
    //TODO
    //page limit?
    /*thought of eating a lemon (and other foods), consume pots,
     *  craft a home, 
     *  own home (more for larger homes), 
     *  loot x amount of gold, 
     *  find a uni, 
     *  kill each mob in the game,
     *   enter an event,
     *    tame all tamables,
     *     use a max powerscroll (or skill stone), 
     *     ride each type of mount
     */
    public class AchievmentSystem
    {
        public class AchievementCategory
        {
            public int ID { get; set; }
            public int Parent { get; set; }
            public string Name;


            public AchievementCategory(int id, int parent, string v3)
            {
                ID = id;
                Parent = parent;
                Name = v3;
            }
        }
        public static List<BaseAchievement> Achievements = new List<BaseAchievement>();
        public static List<AchievementCategory> Categories = new List<AchievementCategory>();

        public static void Initialize()
        {
            Categories.Add(new AchievementCategory(1, 0, "Exploration"));
                Categories.Add(new AchievementCategory(2, 1, "Towns"));
                Categories.Add(new AchievementCategory(3, 1, "Dungeons"));
                Categories.Add(new AchievementCategory(4, 1, "Points of Interest"));

            Categories.Add(new AchievementCategory(1000, 0, "Crafting"));
            Categories.Add(new AchievementCategory(2000, 0, "Resource Gathering"));
            Categories.Add(new AchievementCategory(3000, 0, "Hunting"));
            Categories.Add(new AchievementCategory(4000, 0, "Character Development"));
            Categories.Add(new AchievementCategory(5000, 0, "Other"));


            Achievements.Add(new DiscoveryAchievement(0, 2, 0x14EB, false, null, "Cove!", "Discover the Cove Township", 5, "Cove"));
            Achievements.Add(new DiscoveryAchievement(1, 2, 0x14EB, false, null, "Britain!", "Discover the City Britain", 5, "Britain"));
            Achievements.Add(new DiscoveryAchievement(2, 2, 0x14EB, false, null, "Minoc!", "Discover the Minoc Township", 5, "Minoc"));
            Achievements.Add(new DiscoveryAchievement(3, 2, 0x14EB, false, null, "Ocllo!", "Discover the Ocllo Township", 5, "Ocllo"));
            Achievements.Add(new DiscoveryAchievement(4, 2, 0x14EB, false, null, "Trinsic!", "Discover the City of Trinsic", 5, "Trinsic"));
            Achievements.Add(new DiscoveryAchievement(5, 2, 0x14EB, false, null, "Vesper!", "Discover the City of Vesper", 5, "Vesper"));
            Achievements.Add(new DiscoveryAchievement(6, 2, 0x14EB, false, null, "Yew!", "Discover the Yew Township", 5, "Yew"));
            Achievements.Add(new DiscoveryAchievement(7, 2, 0x14EB, false, null, "Wind!", "Discover the City of Wind", 5, "Wind"));
            Achievements.Add(new DiscoveryAchievement(8, 2, 0x14EB, false, null, "Serpent's Hold!", "Discover the City of Serpent's Hold", 5, "Serpent's Hold"));
            Achievements.Add(new DiscoveryAchievement(9, 2, 0x14EB, false, null, "Skara Brae!", "Discover the Island of Skara Brae", 5, "Skara Brae"));
            Achievements.Add(new DiscoveryAchievement(10, 2, 0x14EB, false, null, "Nujel'm!", "Discover the Island of Nujel'm", 5, "Nujel'm"));
            Achievements.Add(new DiscoveryAchievement(11, 2, 0x14EB, false, null, "Moonglow!", "Discover the City of Moonglow", 5, "Moonglow"));
            Achievements.Add(new DiscoveryAchievement(12, 2, 0x14EB, false, null, "Magincia!", "Discover the City of Magincia", 5, "Magincia"));
            Achievements.Add(new DiscoveryAchievement(13, 2, 0x14EB, false, null, "Buccaneer's Den!", "Discover the Secrets of Buccaneer's Den", 5, "Buccaneer's Den"));

            Achievements.Add(new DiscoveryAchievement(25, 3, 0x14EB, false, null, "Covetous!", "Discover the dungeon of Covetous", 5, "Covetous"));
            Achievements.Add(new DiscoveryAchievement(26, 3, 0x14EB, false, null, "Deceit!", "Discover the dungeon of Deceit", 5, "Deceit"));
            Achievements.Add(new DiscoveryAchievement(27, 3, 0x14EB, false, null, "Despise!", "Discover the dungeon of Despise", 5, "Despise"));
            Achievements.Add(new DiscoveryAchievement(28, 3, 0x14EB, false, null, "Destard!", "Discover the dungeon of Destard", 5, "Destard"));
            Achievements.Add(new DiscoveryAchievement(29, 3, 0x14EB, false, null, "Hythloth!", "Discover the dungeon of Hythloth", 5, "Hythloth"));
            Achievements.Add(new DiscoveryAchievement(30, 3, 0x14EB, false, null, "Wrong!", "Discover the dungeon of Wrong", 5, "Wrong"));
            Achievements.Add(new DiscoveryAchievement(31, 3, 0x14EB, false, null, "Shame!", "Discover the dungeon of Shame", 5, "Shame"));

            Achievements.Add(new DiscoveryAchievement(100, 4, 0x14EB, false, null, "Cotton!", "Discover A Cotton Field in Moonglow", 5, "A Cotton Field in Moonglow"));
            Achievements.Add(new DiscoveryAchievement(101, 4, 0x14EB, false, null, "Carrots!", "Discover A Carrot Field in Skara Brae", 5, "A Carrot Field in Skara Brae"));

            //these two show examples of adding a reward or multiple rewards
            var achieve = new HarvestAchievement(500, 2000, 0x0E85, false, null, 500, "500 Iron Ore", "Mine 500 Iron Ore", 5, typeof(IronOre), typeof(AncientSmithyHammer));
            Achievements.Add(achieve);
            Achievements.Add(new HarvestAchievement(501, 2000, 0x0E85, false, achieve, 5000, "5000 Iron Ore", "Mine 5000 Iron Ore", 5, typeof(IronOre), typeof(AncientSmithyHammer),typeof(TinkerTools),typeof(HatOfTheMagi)));

            Achievements.Add(new HunterAchievement(1000, 3000, 0x25D1, false, null, 5, "Dog Slayer", "Slay 5 Dogs", 5, typeof(Dog)));
            Achievements.Add(new HunterAchievement(1001, 3000, 0x25D1, false, null, 50, "Dragon Slayer", "Slay 50 Dragon", 5, typeof(Dragon)));




            CommandSystem.Register("feats", AccessLevel.Player, new CommandEventHandler(OpenGumpCommand));

        }

        public static void OpenGump(Mobile from, Mobile target)
        {
            if (from == null || target == null)
                return;
            if (target as PlayerMobile != null)
            {
#if STOREONITEM
                var player = target as PlayerMobile;
           if (!AchievementSystemMemoryStone.GetInstance().Achievements.ContainsKey(player.Serial))
                AchievementSystemMemoryStone.GetInstance().Achievements.Add(player.Serial, new Dictionary<int, AchieveData>());
            var achieves = AchievementSystemMemoryStone.GetInstance().Achievements[player.Serial];
                var total = AchievementSystemMemoryStone.GetInstance().GetPlayerPointsTotal(player);
#else
                var achieves = (target as MythikPlayerMobile).Achievements;
                var total = (target as MythikPlayerMobile).AchievementPointsTotal;
#endif
                from.SendGump(new AchievementGump(achieves, total));
            }
        }
        [Usage("feats"), Aliases("ach", "achievement", "achs", "achievements")]
        [Description("Opens the Achievements gump")]
        private static void OpenGumpCommand(CommandEventArgs e)
        {
            OpenGump(e.Mobile, e.Mobile); 
        }

        internal static void SetAchievementStatus(PlayerMobile player, BaseAchievement ach, int progress)
        {
#if STOREONITEM
           if (!AchievementSystemMemoryStone.GetInstance().Achievements.ContainsKey(player.Serial))
                AchievementSystemMemoryStone.GetInstance().Achievements.Add(player.Serial, new Dictionary<int, AchieveData>());
            var achieves = AchievementSystemMemoryStone.GetInstance().Achievements[player.Serial]; 
#else
            var achieves = (player as MythikPlayerMobile).Achievements;
#endif
            if (achieves.ContainsKey(ach.ID))
            {
                if (achieves[ach.ID].Progress >= ach.CompletionTotal)
                    return;
                achieves[ach.ID].Progress += progress;
            }
            else
            {
                achieves.Add(ach.ID, new AchieveData() { Progress = progress });
            }

            if (achieves[ach.ID].Progress >= ach.CompletionTotal)
            {
                player.SendGump(new AchievementObtainedGump(ach),false);
                achieves[ach.ID].CompletedOn = DateTime.UtcNow;
#if STOREONITEM
                AchievementSystemMemoryStone.GetInstance().AddPoints(player,ach.RewardPoints);
#else
                (player as MythikPlayerMobile).AchievementPointsTotal += ach.RewardPoints;
#endif
                if (ach.RewardItems != null && ach.RewardItems.Length > 0)
                {
                    try
                    {
                        player.SendAsciiMessage("You have recieved an award for completing this achievment!");
                        var item = (Item)Activator.CreateInstance(ach.RewardItems[0]);
                        if (!WeightOverloading.IsOverloaded(player))
                            player.Backpack.DropItem(item);
                        else
                            player.BankBox.DropItem(item);
                    }
                    catch { }
                }
            }
        }


    }
}
[doublepost=1487349705][/doublepost]im trying made a menu bar and can see MythikAchievmentSystem-master achievement very fast without any command
 
Put InvokeCommand in

public class logooosMENU : Gump

or in another class and switch from private to public.
 
aplay.elderultima.com_error76.png Still not work, i have try [c] and [feats]
and i try inside the gump , inside the OnResponse
will give up this projet, will send direct gump
 
Code:
public static void Initialize()
{
CommandSystem.Register("Admin", AccessLevel.Administrator, new CommandEventHandler(Admin_OnCommand));
}

Code:
[Usage("Admin")]
[Description("Opens an interface providing server information and administration features including client, account, and firewall management.")]
public static void Admin_OnCommand(CommandEventArgs e)
{
e.Mobile.SendGump(new AdminGump(e.Mobile, AdminGumpPage.Clients, 0, null, null, null));
}

Those are the two parts, the first registers, and supplies the delegate method that's used when the command is used, the delegate command (admin_oncommand) then opens the gump.
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back