RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Capture the Flag and Double Domination games (Updated)

devilsam

Wanderer
thanks for your new release script.
When i type [add CTFgame , server show me the followings :


Usage:
CTFgame Int32 numTeams
 

bean56

Wanderer
devilsam said:
thanks for your new release script.
When i type [add CTFgame , server show me the followings :


Usage:
CTFgame Int32 numTeams
That's because you have to put how many teams you want after it.
 

crameep

Sorceror
Ctf

It is cool that he is taking a while.. I was just wondering. I am afraid to use the scp with the players because my server is hosted remotely and I can not reopen it if it crashes... so I'll just have to wait.
 

bean56

Wanderer
As long as you do [startgame false you won't have a problem. Does anyone know if this happens with an original version of the script?
 

Dero

Wanderer
DarkJustin said:
Alright... we had that issue too--but with the prexisting coding we put the...

Code:
	//check if they are mounted and dismount them
		IMount mount = from.Mount;
		if ( mount != null )
		mount.Rider = null;

Above the place where the script pulls off all of your armor. And pack items. And it seems to work well... If you don't move this section then it'll just knock the person off their mount and the ethy will be in pack. But if you move it under the armor/pack check but before the actual banking check it'll work perfectly for you.


could you tell me the script name? cant find it where i have to change it

thx a lot
 

Dero

Wanderer
thx bean!

but where do i have to put this?



using System;
using System.Collections;
using Server.Items;
using Server.Gumps;

namespace Server.Items
{
[FlipableAttribute( 0xEDC, 0xEDB )]
public class GameJoinStone : Item
{
private CTFGame m_Game;
private string m_GameName;

[Constructable]
public GameJoinStone( string gameName ) : base( 0xEDC )
{
m_GameName = gameName;

Name = m_GameName + " Signup Stone";
Movable = false;
}

public GameJoinStone( Serial serial ) : base( serial )
{
}

[CommandProperty( AccessLevel.Seer )]
public CTFGame Game{ get{ return m_Game; } set{ m_Game = value; } }

[CommandProperty( AccessLevel.Seer )]
public string GameName{ get{ return m_GameName; } set{ m_GameName = value; } }

public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );

writer.Write( (int)0 ); // version
writer.Write( m_GameName );
writer.Write( m_Game );
}

public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );

int version = reader.ReadInt();
switch ( version )
{
case 0:
{
m_GameName = reader.ReadString();
m_Game = reader.ReadItem() as CTFGame;
break;
}
}
}

public override void OnDoubleClick( Mobile from )
{
if ( m_Game != null )
{
if ( m_Game.OpenJoin )
{
if ( m_Game.IsInGame( from ) )
{
from.SendGump( new GameTeamSelector( m_Game ) );
}
else
{
if ( from.AccessLevel == AccessLevel.Player )
from.SendGump( new GameJoinGump( m_Game, m_GameName ) );
else
from.SendMessage( "It might not be wise for staff to be playing..." );
}
}
else
{
from.SendMessage( "{0} join is closed.", m_GameName );
}
}
else
{
from.SendMessage( "This stone must be linked to a game stone. Please contact a game master." );
}
}

public override void OnSingleClick( Mobile from )
{
base.OnSingleClick( from );
LabelTo( from, "[{0} Signup {1}]", m_GameName, m_Game == null ? "UNLINKED" : (m_Game.OpenJoin ? "Open" : "Closed") );
}
}
}
 

bean56

Wanderer
I meant gamejoingump.cs and it's quite obvious where to put it since I included the whole function. Also post code in the code tags.
 

Dero

Wanderer
I must be a pain in the ass but heres anothe problem=)

i got the following error when i´ve customized the script:

Scripts: Compiling C# scripts...failed (1 errors, 0 warnings)
- Error: Scripts\Custom\Capture the Flag\GameJoinGump.cs: CS1513: (line 180, co
lumn 3) } expected
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.

My code looks like this:

Code:
using System;
using Server.Gumps;
using Server.Items;
using Server.Network;
using.server.mobiles;

namespace Server.Gumps
{
	public class GameTeamSelector : Gump
	{
		private CTFGame m_Game;
		private int m_TeamSize;

		public GameTeamSelector( CTFGame game ) : this( game, game.TeamSize )
		{
		}

		public GameTeamSelector( CTFGame game, int teamSize ) : base( 50, 50 )
		{
			m_Game = game;
			m_TeamSize = teamSize;

			Closable = false;
			Dragable = false;

			AddPage( 0 );
			AddBackground( 0, 0, 250, 220, 5054 );
			AddBackground( 10, 10, 230, 200, 3000 );

			AddPage( 1 );
			AddLabel( 20, 20, 0, "Select a team:" );
			for (int i=0;i<m_Game.Teams.Count;i++)
			{
				CTFTeam team = (CTFTeam)m_Game.Teams[i];
				if ( team.ActiveMemberCount < m_TeamSize )
				{
					AddButton( 20, 60 + i*20, 4005, 4006, i+1, GumpButtonType.Reply, 0 );
					AddLabel( 55, 60 + i*20, 0, "Join Team " + team.Name );	
				}
			}
		}

		public override void OnResponse( NetState state, RelayInfo info )
		{
			Mobile from = state.Mobile;
			from.CloseGump( typeof( GameTeamSelector ) );
			
			if ( m_Game.Deleted )
				return;
			
			CTFTeam team = m_Game.GetTeam( info.ButtonID - 1 );
			if ( team != null && team.ActiveMemberCount < m_TeamSize )
			{
				bool freeze = from.Frozen;

				from.Kill();
				if ( from.Corpse != null && !from.Corpse.Deleted )
					from.Corpse.Delete();
				from.Location = team.Home;
				from.Map = team.Map;
				from.Resurrect();

				from.Frozen = freeze;
				
				m_Game.SwitchTeams( from, team );

				from.SendMessage( "You have joined team {0}!", team.Name );
			}
			else
			{
				from.SendMessage( "That team is full, please try again." );
				from.SendGump( new GameTeamSelector( m_Game ) );
			}
		}
	}

	public class GameJoinGump : Gump
	{
		private CTFGame m_Game;
		public GameJoinGump( CTFGame game, string gameName ) : base( 20, 30 )
		{
			m_Game = game;

			AddPage( 0 );
			AddBackground( 0, 0, 550, 220, 5054 );
			AddBackground( 10, 10, 530, 200, 3000 );
			
			AddPage( 1 );
			AddLabel( 20, 20, 0, String.Format( "Welcome to {0}!", gameName ) );
			//AddLabel( 20, 60, 0, "Let it be known to all who join the the melee that lays within, you will not" );
			AddLabel( 20, 60, 0, "Enter the game with caution! ll non-bless/non-newbied items will be lost!" );
			AddLabel( 20, 80, 0, "All pets will be lost! Bank your items before joining, supplies" );
			AddLabel( 20, 100, 0, "will be provided.  Enjoy!" );

			AddLabel( 55, 180, 0, "Cancel" );
			AddButton( 20, 180, 4005, 4006, 0, GumpButtonType.Reply, 0 );
			AddLabel( 165, 180, 0, "Okay, Join!" );
			AddButton( 130, 180, 4005, 4006, 1, GumpButtonType.Reply, 0 );
		}

		public override void OnResponse( NetState state, RelayInfo info )
		{
			Mobile from = state.Mobile;
			from.CloseGump( typeof( GameTeamSelector ) );
			
			if ( m_Game.Deleted )
				return;
			
			CTFTeam team = m_Game.GetTeam( info.ButtonID - 1 );
			if ( team != null && team.ActiveMemberCount < m_TeamSize )
			{
				bool freeze = from.Frozen;

				if ( from.Backpack != null )
				{
					if( from.FindItemOnLayer( Layer.TwoHanded) != null )
						from.Backpack.DropItem( from.FindItemOnLayer( Layer.TwoHanded) );
					if( from.FindItemOnLayer( Layer.Shoes) != null )
						from.Backpack.DropItem( from.FindItemOnLayer( Layer.Shoes) );
					if( from.FindItemOnLayer( Layer.Pants) != null )
						from.Backpack.DropItem( from.FindItemOnLayer( Layer.Pants) );
					if( from.FindItemOnLayer( Layer.Shirt) != null )
						from.Backpack.DropItem( from.FindItemOnLayer( Layer.Shirt) );
					if( from.FindItemOnLayer( Layer.Helm) != null )
						from.Backpack.DropItem( from.FindItemOnLayer( Layer.Helm) );
					if( from.FindItemOnLayer( Layer.Gloves) != null )
						from.Backpack.DropItem( from.FindItemOnLayer( Layer.Gloves) );
					if( from.FindItemOnLayer( Layer.Ring) != null )
						from.Backpack.DropItem( from.FindItemOnLayer( Layer.Ring) );
					if( from.FindItemOnLayer( Layer.Neck) != null )
						from.Backpack.DropItem( from.FindItemOnLayer( Layer.Neck) );
					if( from.FindItemOnLayer( Layer.OneHanded) != null )
						from.Backpack.DropItem( from.FindItemOnLayer( Layer.OneHanded) );
					if( from.FindItemOnLayer( Layer.Waist) != null )
						from.Backpack.DropItem( from.FindItemOnLayer( Layer.Waist) );
					if( from.FindItemOnLayer( Layer.InnerTorso) != null )
						from.Backpack.DropItem( from.FindItemOnLayer( Layer.InnerTorso) );
					if( from.FindItemOnLayer( Layer.Bracelet) != null )
						from.Backpack.DropItem( from.FindItemOnLayer( Layer.Bracelet) );
					if( from.FindItemOnLayer( Layer.MiddleTorso) != null )
						from.Backpack.DropItem( from.FindItemOnLayer( Layer.MiddleTorso) );
					if( from.FindItemOnLayer( Layer.Earrings) != null )
						from.Backpack.DropItem( from.FindItemOnLayer( Layer.Earrings) );
					if( from.FindItemOnLayer( Layer.Arms) != null )
						from.Backpack.DropItem( from.FindItemOnLayer( Layer.Arms) );
					if( from.FindItemOnLayer( Layer.Cloak) != null )
						from.Backpack.DropItem( from.FindItemOnLayer( Layer.Cloak) );
					if( from.FindItemOnLayer( Layer.OuterTorso) != null )
						from.Backpack.DropItem( from.FindItemOnLayer( Layer.OuterTorso) );
					if( from.FindItemOnLayer( Layer.OuterLegs) != null )
						from.Backpack.DropItem( from.FindItemOnLayer( Layer.OuterLegs) );

					from.Backpack.Movable = true;
					from.BankBox.AddItem( from.Backpack );

					Backpack pack = new Backpack();
					pack.Movable = false;

					from.AddItem( pack );
				}
				//check if they are mounted and dismount them
				IMount mount = from.Mount;
				if ( mount != null )
					mount.Rider = null;

				from.Location = team.Home;
				from.Map = team.Map;

				from.Frozen = freeze;
				
				m_Game.SwitchTeams( from, team );

				from.SendMessage( "You have joined team {0}!", team.Name );
			}
			else
			{
				from.SendMessage( "That team is full, please try again." );
				from.SendGump( new GameTeamSelector( m_Game ) );
			}
		}
	}
 

Dero

Wanderer
Man this script is driving me insane!

After I added beans code I got the following error:

Code:
 Scripts: Compiling C# scripts...done (0 errors, 0 warnings)
Scripts: Compiling VB.net scripts...no files found.
Scripts: Verifying...done (1627 items, 427 mobiles)
World: Loading...An error was encountered while loading a saved object
- Type: Server.Mobiles.PlayerMobile
- Serial: 0x0000091E
Delete the object? (y/n)
n
After pressing return an exception will be thrown and the server will terminate

Error:
System.Exception: Load failed (items=False, mobiles=True, guilds=False, regions=
False, type=Server.Mobiles.PlayerMobile, serial=0x0000091E) ---> System.Argument
OutOfRangeException: capacity was less than the current size.
Parameter name: capacity
at System.Collections.ArrayList..ctor(Int32 capacity)
at Server.BinaryFileReader.ReadMobileList()
at Server.Mobiles.PlayerMobile.Deserialize(GenericReader reader)
at Server.World.Load()
--- End of inner exception stack trace ---
at Server.World.Load()
at Server.ScriptCompiler.Compile(Boolean debug)
at Server.Core.Main(String[] args)
This exception is fatal, press return to exit
 

bean56

Wanderer
Your deserialize and serialize in your player mobile are screwed up so it can't load the last save cause the deserialize doesn't match the serialize. This has nothing to do with this since it doesn't require you editing your player mobile at all.
 

coldrake

Wanderer
Is there a way to set the Auto Supply stone to only let players click on it once until they die again? Or does anyone have a work around? Otherwise players can click on it 10 times and get tons of pots, regs, etc. Also, the supply stone does not give necromancers necro regs :/

Another issue I have is with the scoreboard. I added it, linked it to the game stone and it doesnt work. :(

Otherwise everything is working great!
 

bean56

Wanderer
The scoreboards work fine. you just have to click it. You'll have to add a check for necro skill and give necro regs to the stone. I'm not sure what you can do other than adding a tag or something to the account to keep them from double clicking it. You could make it so they spawn with all the stuff and eliminate the stone. What I do is put the stone in a different place where they start away from the arena and most people don't think ahead and click it more than once.
 

Dero

Wanderer
i have the same problem with the scoreboard, i have linked it to the controllstone but if you click it nothing happens
 

bean56

Wanderer
The system seems to be designed for non aos hence the no necro regs. So I bet it only works if you have aos disabled cause it's in the single click funtion. You will probably need to add a properties function.
 

coldrake

Wanderer
Ok I changed the scoreboard to doubleclick and it is working now.

I also had to change the region settings, they were not wide enough and half of the East hall was not included in the region.

Lastly, when a player loses connection they are stuck in the game. I have 5 or 6 players who are just sitting in each home base. They have not logged back in and are stuck in there. I just wonder what will happen after several months of game play when dozens upon dozens of players are all stuck in the game. Would be nice if there was a timer that would auto boot them from the game... 24 hours or something.
 

coldrake

Wanderer
One more quick question. Is there a way to make it so the teams are random or so it automatically balances the teams. Right now players have to pick teams each time and I have to make sure they are even. It's an administrative nightmare.

Also, if there was a way for a player to start the game that would rock.

Thanks!
 

Theirlaw

Wanderer
Girl said:
Am I the only one having a problem with players no longer being able to log out of UO correctly or being able to actually exit the game properly once they have played CTF? I tested it on my server and my players dont log out correctly, in fact hours later after they have logged, their characters are still there. and long after they've left the game area, if I use command [startgame on the stone, the players in the previous game will die and be sent to the game area.

Is there something I am missing? Maybe a command? Any help is appreciated, thanks =)

After fiddling with this script for close to two days now, I have noticed the exact same problem. If a player logs out once they have joined a team, they disconnect properly, but their PlayerMobile object does not properly clean up (I'm assuming because it is retaining its persistance due to the fact that its still being used by the Double Domination scripts). This results in the character disconnecting, but the actual link-dead avatar stands there doing nothing forever remaining on the team they selected.

Just as Girl stated, if you use the [startgame and [endgame commands, the link-dead avatar reacts to the commands as if they are still on the team they selected but in actuallity there is no one controlling the character.

Overall, I wouldn't consider this a major issue because once the character logs back in, all they have to do is enter a Leave Gate and everything is fine 'n dandy... but until they do log back in, they remain standing there lifelessly. :(
 
Top