tass23

Member
I don't know why I'm having trouble with this. It seems like such a simple concept: Get a property from an item and if it's <= X, then send this gump to players within NamedRegion.

I've tried looking at SkillCheck.cs and several other scripts that involve mobilesInRange, but I can't get the property from the item AND send the gump to players. It seems it's one or the other.

Has anyone got a code example they could post that would show this particular method? I'd be able to apply that logic/code to what I have to work out errors from there. I'm SO close though...grr
 
Sounds like you know how to do both already lol
Check the property on the item first, if it doesnt match what you want, stop
then loop thru all players in the same region and send the gump to them.

You dont do both things at once, lay out what you want done on paper in pseudo code first.

Code:
        private void Checkitem(Item item)
        {
            if (item.PoisonResistance > 80)
                return;

            var region = Region.Find(item.Location, item.Map);
            foreach(var player in region.GetPlayers())
            {
                player.SendGump(new MyGump(item, player));
            }

        }
 
Thanks man, I was stuck on getting it to check for players in range. The region is named, but not in the Regions.xml, so I was stumbling over that part. Thanks again!
 
I finally got back to this project and I thought I was making progress, but I'm stuck :|

This code:
Code:
		public void CheckKills(UnderworldSystem sys)
        {
            if (sys.RegularKillCount >= 250)
                return;

            var region = Region.Find(sys.Location, sys.Map);
            foreach(var player in region.GetPlayers())
            {
                player.SendGump(new GUnderworldGump(player, sys));
            }
        }
		
		public void PerformCheck()
		{
			if ( this.m_CurrentStage == 1 && this.m_RegularKillCount >= 250 )
			{
				this.m_CurrentStage = 2;
				this.WipeRegSpawnNodes();
				World.Broadcast( 1150, true, "The Underworld Gauntlet has begun!" );
				Acheron ach = new Acheron();
				ach.Home = m_AcheronSpawnPoint;
				ach.RangeHome = 1;
				ach.MoveToWorld( m_AcheronSpawnPoint, m_UnderworldMap );
				m_CurrentBoss = ach;
			}
			else
			{
				CheckBoss();
				CheckKills();
			}
		}

Produces these errors.
Code:
 + Customs/Underworld System/Control/UnderworldSystem.cs:
    CS1502: Line 292: The best overloaded method match for 'Server.Gumps.GUnderw
orldGump.GUnderworldGump(Server.Mobiles.PlayerMobile, Server.Engines.Underworld.
UnderworldSystem)' has some invalid arguments
    CS1503: Line 292: Argument 1: cannot convert from 'Server.Mobile' to 'Server
.Mobiles.PlayerMobile'
    CS1501: Line 312: No overload for method 'CheckKills' takes 0 arguments

Here is the gump:
Code:
public class GUnderworldGump : Gump
	{
		public PlayerMobile m_From;
		public UnderworldSystem m_Sys;

		public GUnderworldGump(PlayerMobile m, UnderworldSystem sys) : base( 0, 0 )
		{
			m_From = m;
			m_Sys = sys;
			
			this.Closable=true;
			this.Disposable=true;
			this.Dragable=true;
			this.Resizable=false;

			AddPage(0);
			AddBackground(0, 0, 170, 100, 5054);
			AddLabel(14, 9, 1080, @"Greek Underworld Kills");
			AddLabel(15, 60, 1153, @"Needed:");
			AddLabel(75, 60, 1074, @"250");
			AddLabel(15, 35, 1153, @"Current:");
			AddLabel(75, 35, 1074, sys.RegularKillCount.ToString("{0}"));	
		}
	}

What am I not seeing folks? Any help is greatly appreciated!
 
For this:

  • foreach(var player in region.GetPlayers())
  • {
  • player.SendGump(new GUnderworldGump(player, sys));
}

Try this:

Code:
            foreach(var player in region.GetPlayers())
            {
                if (player is PlayerMobile)
                {
                    player.SendGump(new GUnderworldGump((PlayerMobile)player, sys));
                }
            }

For the other error, I would need to see more of the script, because I don't know if you have a reference to "UnderworldSystem" that you can pass over to "CheckKills", but that is what you need to do.
 
Thanks Lokai! :D

Okay, I changed it up a tad, because I was originally going to have a command to open the gump, but I figured if it was in this method, which already does a check, that it should send the gump, but it doesn't.

Here is the check that's already being done:
Code:
public void PerformCheck()
		{
			if ( this.m_CurrentStage == 1 && this.m_RegularKillCount >= 250 )
			{
				this.m_CurrentStage = 2;
				this.WipeRegSpawnNodes();
				World.Broadcast( 1150, true, "The Underworld Gauntlet has begun!" );
				Acheron ach = new Acheron();
				ach.Home = m_AcheronSpawnPoint;
				ach.RangeHome = 1;
				ach.MoveToWorld( m_AcheronSpawnPoint, m_UnderworldMap );
				m_CurrentBoss = ach;
			}
			else if (this.m_CurrentStage == 1 && this.m_RegularKillCount <= 249) //This is the section I added with Lokai's help
			{ 
				var region = Region.Find(this.Location, this.Map);
				foreach(var player in region.GetPlayers())
				{
					if (player is PlayerMobile)
					{
						player.SendGump(new GUnderworldGump((PlayerMobile)player, this));
					}
				}
			}
			else
			{
				CheckBoss();
			}
		}

Here is the gump code:
Code:
namespace Server.Gumps
{
	public class GUnderworldGump : Gump
	{
		public PlayerMobile m_From;
		public UnderworldSystem m_Sys;
		public GUnderworldGump(PlayerMobile m, UnderworldSystem sys) : base( 0, 0 )
		{	
			PlayerMobile m_From;
			UnderworldSystem m_Sys;
			
			this.Closable=true;
			this.Disposable=true;
			this.Dragable=true;
			this.Resizable=false;

			AddPage(0);
			AddBackground(0, 0, 170, 100, 5054);
			AddLabel(14, 9, 1080, @"Greek Underworld Kills");
			AddLabel(15, 60, 1153, @"Needed:");
			AddLabel(75, 60, 1074, @"250");
			AddLabel(15, 35, 1153, @"Current:");
			AddLabel(75, 35, 1074, sys.RegularKillCount.ToString("{0}"));	
		}
	}
}

Everything compiles, but the gump never opens (alternatively, if an automatic call to the gump won't work for whatever reason, a command would be the other route).
 
I still don't see the whole thing. If you would rather message it to me that's fine. In the meantime, if you just want to see if that code is being considered but just not sending a gump, you can try this:

Code:
                foreach(var player in region.GetPlayers())
                {
                    if (player is PlayerMobile)
                    {
                        Console.WriteLine("{0} was in the Region.", ((PlayerMobile)player).Name);
                        player.SendGump(new GUnderworldGump((PlayerMobile)player, this));
                    }
                }

If the name of someone you thought would see the gump shows up in the Console, but no gump, then you know there is a problem with the gump call, otherwise, there is a problem with the logic leading to this code.
 
Much thanks to Lokai for giving me a hand with this!
Here is the section of code that works to send a gump to each player in that region (it will close it and send a new one to refresh).

Code:
var region = Region.Find(this.Location, m_UnderworldMap);
				foreach(Mobile player in region.GetPlayers())
                {
                    if (player is PlayerMobile)
                    {
						player.CloseGump( typeof( GUnderworldGump));
                        player.SendGump(new GUnderworldGump((PlayerMobile)player, this));
                    }
                }

Couple of things I want to add to this:
1. The item in question is a control device, but it originally wasn't in the same location as the region itself. That is paramount! If the control device is not within the same region, the gump won't show up (but the code will work).

2. Those of you using this code as an example, please do not forget to CLOSE the gump before sending a new one (I missed that part and almost crashed myself because I had 500 gumps open Lol).

3. I used Regions-In-A-Box to set up the region where the control device was moved to and that finally identified the region properly.

Thanks again Lokai for the solution and thanks to DarkLotus for getting the ball rolling for me :)
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back