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!

[RunUO 2.0 RC1] On-site Dueling System 2.0

Kreamy

Wanderer
i am not good with scripting ive only been trying to do it for a short time...
sooo
could you show me how to make it to where when the duel is over they stop fighting?
 

UO_Talon

Sorceror
I edited the AllowBenifical Return like stated in post #18, and got this error!

Code:
Errors:
+ Customs/Duel/Onsite Duel System/Components/DuelController.cs:
    CS0117: Line 394: 'Server.Misc.NotorietyHandlers' does not contain a definit
ion for 'Mobile_AllowBenificial'
 

UO_Talon

Sorceror
I found benifical spelt two differnt way threw out the entire script. Should it be spelt Beneficial or Benificial?

Here is an example of what I'm referring to

Code:
PlayerMobile.AllowBeneficialHandler = new AllowBeneficialHandler( PlayerMobile_AllowBenificial );
 

zetamine

Sorceror
I found benifical spelt two differnt way threw out the entire script. Should it be spelt Beneficial or Benificial?

Here is an example of what I'm referring to

Code:
PlayerMobile.AllowBeneficialHandler = new AllowBeneficialHandler( PlayerMobile_AllowBenificial );


I would try "Beneficial" as it is the proper spelling of the word and in your previous post "Benificial" is what is being named as undefined.
 

Pure Insanity

Sorceror
The reason why you have problems with it, is because it's actually a typo that was fixed with one of the releases...which one I don't know. So you should change it to the proper spelling, that's if you're using a new enough server that had the typo fixed.
 

Vitremer

Sorceror
with this system i've obtained this message of crash

Code:
RunUO Version 2.0, Build 2968.26078
Operating System: Microsoft Windows NT 6.1.7600.0
.NET Framework: 2.0.50727.4959
Time: 01/09/2011 01:31:30
Mobiles: 264
Items: 444
Exception:
System.Exception: World Save event threw an exception.  Save failed! ---> System.UnauthorizedAccessException: Access to the path '\Saves\OnsitePoints' is denied.
  at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
  at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, DirectorySecurity dirSecurity)
  at System.IO.Directory.CreateDirectory(String path, DirectorySecurity directorySecurity)
  at Server.Dueling.DuelController.EventSink_WorldSave(WorldSaveEventArgs e)
  at Server.WorldSaveEventHandler.Invoke(WorldSaveEventArgs e)
  at Server.World.Save(Boolean message)
  --- End of inner exception stack trace ---
  at Server.World.Save(Boolean message)
  at Server.Misc.AutoSave.Save()
  at Server.Commands.CommandSystem.Handle(Mobile from, String text, MessageType type)
  at Server.Mobile.DoSpeech(String text, Int32[] keywords, MessageType type, Int32 hue)
  at Server.Mobiles.PlayerMobile.DoSpeech(String text, Int32[] keywords, MessageType type, Int32 hue)
  at Server.Network.PacketHandlers.UnicodeSpeech(NetState state, PacketReader pvSrc)
  at Server.Network.MessagePump.HandleReceive(NetState ns)
  at Server.Network.MessagePump.Slice()
  at Server.Core.Main(String[] args)
any suggestions ?
 

Iraq-

Sorceror
Code:
Access to the path '\Saves\OnsitePoints' is denied.

Change the permissions on your OnSitePoints file in saves folder so that it can write over it, im guessing it's read-only atm.
 

Pure Insanity

Sorceror
Yeah, it's probably read only. Gotta be careful with that. I've noticed over the past few years, that a lot of the stuff on here seems to be readonly...I suggest checking everything you put in. As a minor thing like this can cause repeated crashes when you're not around to take care of it. =P
 

Vitremer

Sorceror
don't exists an 'OnSitePoints' file in my Saves folder.
i think the problem is this : for first i test this system on local server at my home. then i put it in server host folder, with saves taken to my local server folder. I think the server in host searching for a OnSitePoints folderpath that is that of my local server and then differents from that of server host and i've obtain this message of don't saving.
 

Vitremer

Sorceror
and i've also this problem

I believe I found a bug? Maybe its a personal mistake I dont know.

If I un-check "Allow Duel Invites" it no longer allows me to close out the Main Duel Gump and it gives me this message:
Code:
You cant start a duel if you have chosen to not accept duel invites.
Check the allow duel invites box before you start a duel
Also so now that its already been un-checked, and I cannot close it out because of this message I go to re-check this box but does not allow me to re-check it, and gives me that exact message again for what reason?
The only way I found to close it out is to log out and re-login..

Now that ive logged out and logged back in to close that gump and I go to use [duel again It tells me this:
Code:
You are currently in a duel.
What could be the problem for all this?
 

Fixxxer

Sorceror
After I added this system players could not heal pets or other players, I looked for a fix and I could not find one, I am using Orbsyida SA server. Any ideas would be great cause this system is really good.
 

Fixxxer

Sorceror
The more I dug around with this system and trying to find what needs to be edited to allow healing of people and pets, I could not figure it out myself. This is the script that is causing the problem, any help would be great thanks.

Code:
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
 
using Server;
using Server.Misc;
using Server.Items;
using Server.Gumps;
using Server.Regions;
using Server.Mobiles;
using Server.Commands;
 
namespace Server.Dueling
{
    public class DuelController
    {
        private int _MaxDistance = 30;
        private int _DuelLengthInSeconds = 1800;
 
        private static bool _Enabled = false;
 
        [CommandProperty(AccessLevel.Administrator)]
        public static bool Enabled { get { return _Enabled; } set { _Enabled = value; } }
 
        [CommandProperty( AccessLevel.Administrator )]
        public int DuelLengthInSeconds { get { return _DuelLengthInSeconds; } set { _DuelLengthInSeconds = value; } }
 
        [CommandProperty( AccessLevel.Administrator )]
        public int MaxDistance { get { return _MaxDistance; } set { _MaxDistance = value; } }
 
        private static List<Mobile> _DeclineDuelList;
        public static List<Mobile> DeclineDuelList { get { return _DeclineDuelList; } }
 
        private static DuelController _Instance;
        public static DuelController Instance { get { return _Instance; } }
 
        private static Dictionary<Serial, LogoutTimeoutTimer> _TimeoutTable;
        private static Dictionary<Serial, DuelStartTimer> _DuelStartTimeoutTable;
        private static Dictionary<Serial, Duel> _DuelTable;
        private static Dictionary<Serial, DuelPoints> _PointsTable;
 
        public static Dictionary<Serial, Duel> DuelTable { get { return _DuelTable; } set { _DuelTable = value; } }
        public static Dictionary<Serial, DuelStartTimer> DuelStartTimeoutTable { get { return _DuelStartTimeoutTable; } set { _DuelStartTimeoutTable = value; } }
 
        public static void Initialize()
        {
            EventSink.PlayerDeath += new PlayerDeathEventHandler( EventSink_PlayerDeath );
            EventSink.Logout += new LogoutEventHandler( EventSink_Logout );
            EventSink.Login += new LoginEventHandler( EventSink_Login );
            EventSink.Movement += new MovementEventHandler( EventSink_Movement );
            EventSink.WorldSave += new WorldSaveEventHandler( EventSink_WorldSave );
 
            //PlayerMobile.AllowBeneficialHandler = new AllowBeneficialHandler( PlayerMobile_AllowBenificial );
            //PlayerMobile.AllowHarmfulHandler = new AllowHarmfulHandler( PlayerMobile_AllowHarmful );
 
            Notoriety.Handler = new NotorietyHandler( Notoriety_HandleNotoriety );
           
            CommandSystem.Register( "OnsiteConfig", AccessLevel.Administrator, new CommandEventHandler( OnCommand_OnsiteConfig ) );
            CommandSystem.Register( "Duel", AccessLevel.Player, new CommandEventHandler( OnCommand_Duel ) );
 
            _Instance = new DuelController();
            _TimeoutTable = new Dictionary<Serial, LogoutTimeoutTimer>();
            _DuelTable = new Dictionary<Serial, Duel>();
            _PointsTable = new Dictionary<Serial, DuelPoints>();
            _DeclineDuelList = new List<Mobile>();
            _DuelStartTimeoutTable = new Dictionary<Serial, DuelStartTimer>();
 
            LoadSaves(); 
        }
 
        private static void OnCommand_Duel( CommandEventArgs e )
        {
            Mobile m = e.Mobile;
 
            if( m == null )
                return;
 
 
            if (!_Enabled)
            {
                m.SendMessage("Sorry the duel system is currently offline. Please try again later.");
                return;
            }
 
            if( !CanDuel( m ) )
                return;
 
            Duel duel = new Duel( m );
                       
            if( !_DuelTable.ContainsKey( m.Serial ) )
                _DuelTable.Add(m.Serial, duel);
 
            m.CloseGump( typeof( DuelConfigGump ) );
            m.SendGump( new DuelConfigGump( duel ) );
        }
 
        public static bool CanDuel( Mobile m )
        {
            Duel duel;
 
            if( m.Criminal )
            {
                m.SendMessage( "You may not start a duel while flagged criminal." );
                return false;
            }
            /*else if( _DeclineDuelList.Contains( m ) )
            {
                m.SendMessage( "You have elected to not duel, use \"[AllowDuel true\" to be able to duel." );
                return false;
            }*/
            else if( Spells.SpellHelper.CheckCombat( m ) )
            {
                m.SendMessage( "You cannot start a duel while in combat." );
                return false;
            }         
            else if( IsInDuel( m, out duel) )
            {
                m.SendMessage( "You are currently in a duel." );
                return false;
            }
            else if( m.Hits != m.HitsMax )
            {
                m.SendMessage( "Try again when you have full health." );
                return false;
            }
            else if( Factions.Sigil.ExistsOn( m ) )
            {
                m.SendMessage( "You may not challenge someone while you have a faction sigil." );
                return false;
            }
 
            return true;
        }
 
        private static void OnCommand_OnsiteConfig( CommandEventArgs e )
        {
            Mobile m = e.Mobile;
 
            if( m == null )
                return;
 
            m.CloseGump( typeof( PropertiesGump ) );
            m.SendGump( new PropertiesGump( m, _Instance ) );
        }
 
        private static void LoadSaves()
        {
            if( !File.Exists( Path.Combine( Core.BaseDirectory, "\\Saves\\OnsitePoints\\Points.sav" ) ) )
                return;
 
            Console.ForegroundColor = ConsoleColor.Blue;
            Console.Write( "Onsite: Loading Points " );
 
            BinaryFileReader read = new BinaryFileReader(
                new BinaryReader( new FileStream( Path.Combine( Core.BaseDirectory, "\\Saves\\OnsitePoints\\Points.sav" ),
                FileMode.Open ) )
                );
 
            GenericReader reader = read;
 
            InternalLoad( reader );
            read.Close();
            DrawPercent(100);
            Console.WriteLine( "" );
            Console.WriteLine( "Onsite: Load Complete. " );
 
            Console.ForegroundColor = ConsoleColor.Gray;
        }
 
        private static void InternalLoad( GenericReader reader )
        {
            int version = reader.ReadInt();
 
            switch( version )
            {
                case 1:
                    {
                        _Enabled = reader.ReadBool();
                        _Instance._DuelLengthInSeconds = reader.ReadInt();
                        _Instance._MaxDistance = reader.ReadInt();
                        goto case 0;
                    }
                case 0:
                    {
                        int count = reader.ReadInt();
 
                        for( int i = 0; i < count; i++ )
                        {
                            Serial serial = ( Serial )reader.ReadInt();
                            DuelPoints points = new DuelPoints( reader );
                            _PointsTable.Add( serial, points );
                            DrawPercent( GetPercent( i, count ) );
                        }
 
                        _DeclineDuelList = reader.ReadStrongMobileList();
 
                        break;
                    }
            }
        }
 
        public static bool IsInDuel( Mobile m )
        {
            Duel d;
            return IsInDuel( m, out d );
        }
 
        public static bool IsInDuel( Mobile m, out Duel duel )
        {
            duel = null;
 
            if( _DuelTable.ContainsKey( m.Serial ) )
            {
                duel = _DuelTable[m.Serial];
                return true;
            }
 
            return false;
        }
 
        private static void EventSink_WorldSave( WorldSaveEventArgs e )
        {
            int oldX, oldY;
 
            oldX = Console.CursorLeft;
            oldY = Console.CursorTop;
 
            Console.CursorVisible = false;
 
            if( !Directory.Exists( Path.Combine( Core.BaseDirectory, "\\Saves\\OnsitePoints" ) ) )
                Directory.CreateDirectory( Path.Combine( Core.BaseDirectory, "\\Saves\\OnsitePoints" ) );
 
            GenericWriter writer = new BinaryFileWriter( new FileStream( Path.Combine( Core.BaseDirectory, "\\Saves\\OnsitePoints\\Points.sav" ), FileMode.OpenOrCreate ), true );
 
            Console.WriteLine("");
            Console.ForegroundColor = ConsoleColor.Blue;
            Console.Write( "Onsite: Saving Points " );
            InternalSave( writer );
            writer.Close();
            DrawPercent(100);
            Console.WriteLine("");
            Console.WriteLine("Onsite: Complete. ");
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.Write( "World: " );
        }
 
        private static void InternalSave( GenericWriter writer )
        {
            writer.Write( ( int )1 );
 
            writer.Write( ( bool )_Enabled );
            writer.Write( ( int )_Instance._DuelLengthInSeconds );
            writer.Write( ( int )_Instance._MaxDistance );
 
            int count = _PointsTable.Count;
 
            writer.Write( ( int )count );
            IDictionaryEnumerator myEnum = _PointsTable.GetEnumerator();
 
            int i = 0;
            while( myEnum.MoveNext() )
            {
                Serial serial = ( Serial )myEnum.Key;
                DuelPoints duelPoints = ( DuelPoints )myEnum.Value;
 
                writer.Write( ( int )serial );
                duelPoints.Serialize( writer );
 
                DrawPercent( GetPercent( i, count ) );
                i++;
            }
 
            writer.WriteMobileList<Mobile>( _DeclineDuelList );
        }
 
        public static int GetPercent( long current, long total )
        {
            return ( int )( ( current * 100 ) / total );
        }
 
        private static void DrawPercent( int percent )
        {
            int oldX = Console.CursorLeft;
            int oldY = Console.CursorTop;
            int totalblocks = 20;
            int blocks = percent / 5;
            int remainingblocks = totalblocks - blocks;
            Console.Write( "[" );
 
            for( int i = 0; i < blocks; i++ )
                DrawBlock( percent );
 
            for( int i = 0; i < remainingblocks; i++ )
                Console.Write( "=" );
 
            Console.Write( "]{0}%", percent );
            Console.SetCursorPosition( oldX, oldY );
        }
 
        private static void DrawBlock( int percent )
        {
            ConsoleColor oldColor = Console.BackgroundColor;
            Console.BackgroundColor = GetColor( percent );
            Console.Write( " " );
            Console.BackgroundColor = oldColor;
        }
 
        private static ConsoleColor GetColor( int percent )
        {
            if( percent < 20 )
                return ConsoleColor.DarkRed;
            else if( percent < 40 )
                return ConsoleColor.Red;
            else if( percent < 60 )
                return ConsoleColor.Yellow;
            else if( percent < 80 )
                return ConsoleColor.Green;
            else
                return ConsoleColor.Blue;
        }
 
        private static int Notoriety_HandleNotoriety( Mobile from, Mobile target )
        {
            if( from == null || target == null )
                return NotorietyHandlers.MobileNotoriety( from, target );
 
            Duel fromDuel, targetDuel;
            bool fromInDuel = IsInDuel( from, out fromDuel );
            bool targetInDuel = IsInDuel( target, out targetDuel );
 
            if( fromInDuel && targetInDuel )
            {
                if( fromDuel == null || targetDuel == null )
                    return NotorietyHandlers.MobileNotoriety( from, target );
       
                if( fromDuel == targetDuel )
                {
                    if (fromDuel.Started)
                    {
                        if ((fromDuel.Attackers.Contains(from) && fromDuel.Attackers.Contains(target)) || (fromDuel.Defenders.Contains(from) && fromDuel.Defenders.Contains(target)))
                            return Notoriety.Ally;
                        else
                            return Notoriety.Enemy;
                    }
                    else
                        return NotorietyHandlers.MobileNotoriety(from, target);                   
                }
                else
                    return Notoriety.Invulnerable;
            }
            else if( ( fromInDuel && !targetInDuel ) || ( !fromInDuel && targetInDuel ) )
            {
                if( !target.Player || !from.Player )
                    return NotorietyHandlers.MobileNotoriety( from, target );
                else if( !( target.Region is GuardedRegion ) )
                    return NotorietyHandlers.MobileNotoriety( from, target );
                else
                    if( ( fromInDuel && fromDuel.Started ) || ( targetInDuel && targetDuel.Started ) )
                        return Notoriety.Invulnerable;
                    else
                        return NotorietyHandlers.MobileNotoriety( from, target );
            }
            else
                return NotorietyHandlers.MobileNotoriety( from, target );
        }
 
        private static bool PlayerMobile_AllowHarmful( Mobile from, Mobile target )
        {
            if( from == null || target == null )
              return NotorietyHandlers.Mobile_AllowHarmful( from, target ); ;
 
            Duel fromDuel, targetDuel;
            bool fromInDuel = IsInDuel( from, out fromDuel );
            bool targetInDuel = IsInDuel( target, out targetDuel );
 
            if( fromInDuel && targetInDuel )
            {
                if( fromDuel == null || targetDuel == null )
                    return NotorietyHandlers.Mobile_AllowHarmful( from, target );
 
                return ( fromDuel == targetDuel );
            }
            else if( ( fromInDuel && !targetInDuel ) || ( targetInDuel && !fromInDuel ) )
                if( from.Player && target.Player )
                    return false;
               
            return NotorietyHandlers.Mobile_AllowHarmful( from, target );
        }
 
        private static bool PlayerMobile_AllowBenificial( Mobile from, Mobile target )
        {
            if( from == null || target == null )
                return NotorietyHandlers.Mobile_AllowBeneficial( from, target ); ;
 
            Duel fromDuel, targetDuel;
            bool fromInDuel = IsInDuel( from, out fromDuel );
            bool targetInDuel = IsInDuel( target, out targetDuel );
 
            if( fromInDuel && targetInDuel )
            {
                if( fromDuel == null || targetDuel == null )
                    return NotorietyHandlers.Mobile_AllowBeneficial( from, target );
 
                return ( fromDuel == targetDuel );
            }
            else if( ( fromInDuel && !targetInDuel ) || ( targetInDuel && !fromInDuel ) )
                if( from.Player && target.Player )
                    return false;
               
            return NotorietyHandlers.Mobile_AllowHarmful( from, target );
        }
 
        private static void EventSink_Movement( MovementEventArgs e )
        {
            Mobile m = e.Mobile;
 
            if( m == null )
                return;
 
            if( _DuelTable.ContainsKey( m.Serial ) )
            {
                Duel duel = _DuelTable[m.Serial];
 
                if( duel.Started && duel.CheckDistance() )
                    duel.EndDuel();
            }
        }
 
        private static void EventSink_Login( LoginEventArgs e )
        {
            Mobile m = e.Mobile;
 
            if( m == null )
                return;
 
            if (_TimeoutTable.ContainsKey(m.Serial))
            {
                LogoutTimeoutTimer timer = _TimeoutTable[m.Serial];
                timer.Stop();
 
                _TimeoutTable.Remove(m.Serial);
            }
        }
 
        private static void EventSink_Logout( LogoutEventArgs e )
        {           
            Mobile m = e.Mobile;
 
            if( m == null )
                return;
 
            Duel duel;
 
            if (IsInDuel(m, out duel) && !_TimeoutTable.ContainsKey(m.Serial))
            {
                if( duel != null && duel.Started )
                {
                    LogoutTimeoutTimer timer = new LogoutTimeoutTimer(m, duel);
                    timer.Start();
 
                    _TimeoutTable.Add(m.Serial, timer);
                }
            }
        }
 
        private static void EventSink_PlayerDeath( PlayerDeathEventArgs e )
        {
            Mobile m = e.Mobile;
 
            if( m == null )
                return;
 
            if( _DuelTable.ContainsKey( m.Serial ) )
            {
                Duel duel = _DuelTable[m.Serial];
                if( duel.Started )
                    duel.HandleDeath( m );
            }
        }
 
        internal static void WritePointsDictionary( Dictionary<int, DuelInfo> dictionary, GenericWriter writer )
        {
            writer.Write( ( int )0 );
 
            int count = dictionary.Count;
            writer.Write( ( int )count );
 
            IDictionaryEnumerator myEnum = dictionary.GetEnumerator();
 
            while( myEnum.MoveNext() )
            {
                int key = ( int )myEnum.Key;
                DuelInfo info = ( DuelInfo )myEnum.Value;
 
                writer.Write( ( int )key );
                info.Serialize( writer );
            }
        }
 
        internal static void WriteIntDictionary( Dictionary<int, int> dictionary, GenericWriter writer )
        {
            writer.Write( ( int )0 );
 
            int count = dictionary.Count;
            writer.Write( ( int )count );
 
            IDictionaryEnumerator myEnum = dictionary.GetEnumerator();
 
            while( myEnum.MoveNext() )
            {
                int key = ( int )myEnum.Key;
                int info = ( int )myEnum.Value;
 
                writer.Write( ( int )key );
                writer.Write( ( int )info );
            }
        }
 
        internal static Dictionary<int, DuelInfo> ReadPointsDictionary( GenericReader reader )
        {
            Dictionary<int, DuelInfo> dictionary = new Dictionary<int, DuelInfo>();
 
            int version = reader.ReadInt();
 
            switch( version )
            {
                case 0:
                    {
                        int count = reader.ReadInt();
 
                        for( int i = 0; i < count; i++ )
                        {
                            int key = reader.ReadInt();
                            DuelInfo dInfo = new DuelInfo( reader );
                            dictionary.Add( key, dInfo );
                        }
 
                        break;
                    }
            }
 
            return dictionary;
        }
 
        internal static Dictionary<int, int> ReadIntDictionary( GenericReader reader )
        {
            Dictionary<int, int> dictionary = new Dictionary<int, int>();
 
            int version = reader.ReadInt();
 
            switch( version )
            {
                case 0:
                    {
                        int count = reader.ReadInt();
 
                        for( int i = 0; i < count; i++ )
                        {
                            int key = reader.ReadInt();
                            int value = reader.ReadInt();
                            dictionary.Add( key, value );
                        }
 
                        break;
                    }
            }
 
            return dictionary;
        }
 
        internal static void DestroyDuel( Duel duel )
        {
            List<Mobile> mobs = new List<Mobile>();
 
            if( _DuelTable.ContainsKey( duel.Creator.Serial ) )
                _DuelTable.Remove( duel.Creator.Serial );
 
            if( duel.Attackers != null )
                mobs.AddRange( duel.Attackers );
            if( duel.Defenders != null )
                mobs.AddRange( duel.Defenders );
            if( duel.Contestants != null )
                mobs.AddRange( duel.Contestants );
 
            for( int i = 0; i < mobs.Count; i++ )
            {
                if( _DuelTable.ContainsKey( mobs[i].Serial ) )
                    _DuelTable.Remove( mobs[i].Serial );
            }
 
            duel = null;
        }
 
        internal static void Broadcast( string msg, List<Mobile> broadcastTo )
        {
            if( broadcastTo == null )
                return;
 
            for( int i = 0; i < broadcastTo.Count; i++ )
                broadcastTo[i].SendMessage( msg );
        }       
 
        internal static void AddWin( Duel duel, Mobile m )
        {
            if( _PointsTable.ContainsKey( m.Serial ) )
            {
                DuelPoints dPoints = _PointsTable[m.Serial];
                DuelInfo dInfo = new DuelInfo( duel.Attackers.Contains( m ) ? duel.Attackers : duel.Defenders, TimeSpan.FromSeconds( duel.DuelTimer.SecondsRemaining ) );
                dPoints.AddWin( duel.Attackers.Count, dInfo );
                _PointsTable[m.Serial] = dPoints;
            }
            else
            {
                DuelPoints dPoints = new DuelPoints( m );               
                DuelInfo dInfo = new DuelInfo( duel.Attackers.Contains( m ) ? duel.Attackers : duel.Defenders, TimeSpan.FromSeconds( duel.DuelTimer.SecondsRemaining ) );
                dPoints.AddWin( duel.Attackers.Count, dInfo );
                _PointsTable.Add( m.Serial, dPoints );
            }
        }
 
        internal static void AddLoss( Duel duel, Mobile m )
        {
            if( _PointsTable.ContainsKey( m.Serial ) )
            {
                DuelPoints dPoints = _PointsTable[m.Serial];
                DuelInfo dInfo = new DuelInfo( duel.Attackers.Contains( m ) ? duel.Attackers : duel.Defenders, TimeSpan.FromSeconds( duel.DuelTimer.SecondsRemaining ) );
                dPoints.AddLoss( duel.Attackers.Count, dInfo );
            }
            else
            {
                DuelPoints dPoints = new DuelPoints( m );
                DuelInfo dInfo = new DuelInfo( duel.Attackers.Contains( m ) ? duel.Attackers : duel.Defenders, TimeSpan.FromSeconds(  duel.DuelTimer.SecondsRemaining ) );
                dPoints.AddLoss( duel.Attackers.Count, dInfo );
            }
        }
    }
}

I commented out the these because this allows the system to be on my server without it causing any problems, however the code dealing with that is what I cannot fix.
Code:
//PlayerMobile.AllowBeneficialHandler = new AllowBeneficialHandler( PlayerMobile_AllowBenificial );
 
            //PlayerMobile.AllowHarmfulHandler = new AllowHarmfulHandler( PlayerMobile_AllowHarmful );

Using the system when these are commented out make the rule set the same as trammel where no one can be attacked, so the duel does not work because the handlers are not allowing it anymore, and like I said I did this so that the system could just say on my server until fixed without causing problems.
 

Iraq-

Sorceror
You're almost done, you just need to also move the code from here:
Code:
private static int Notoriety_HandleNotoriety( Mobile from, Mobile target )
        {
            if( from == null || target == null )
                return NotorietyHandlers.MobileNotoriety( from, target );
 
            Duel fromDuel, targetDuel;
            bool fromInDuel = IsInDuel( from, out fromDuel );
            bool targetInDuel = IsInDuel( target, out targetDuel );
 
            if( fromInDuel && targetInDuel )
            {
                if( fromDuel == null || targetDuel == null )
                    return NotorietyHandlers.MobileNotoriety( from, target );
   
                if( fromDuel == targetDuel )
                {
                    if (fromDuel.Started)
                    {
                        if ((fromDuel.Attackers.Contains(from) && fromDuel.Attackers.Contains(target)) || (fromDuel.Defenders.Contains(from) && fromDuel.Defenders.Contains(target)))
                            return Notoriety.Ally;
                        else
                            return Notoriety.Enemy;
                    }
                    else
                        return NotorietyHandlers.MobileNotoriety(from, target);               
                }
                else
                    return Notoriety.Invulnerable;
            }
            else if( ( fromInDuel && !targetInDuel ) || ( !fromInDuel && targetInDuel ) )
            {
                if( !target.Player || !from.Player )
                    return NotorietyHandlers.MobileNotoriety( from, target );
                else if( !( target.Region is GuardedRegion ) )
                    return NotorietyHandlers.MobileNotoriety( from, target );
                else
                    if( ( fromInDuel && fromDuel.Started ) || ( targetInDuel && targetDuel.Started ) )
                        return Notoriety.Invulnerable;
                    else
                        return NotorietyHandlers.MobileNotoriety( from, target );
            }
            else
                return NotorietyHandlers.MobileNotoriety( from, target );
        }
 
        private static bool PlayerMobile_AllowHarmful( Mobile from, Mobile target )
        {
            if( from == null || target == null )
              return NotorietyHandlers.Mobile_AllowHarmful( from, target ); ;
 
            Duel fromDuel, targetDuel;
            bool fromInDuel = IsInDuel( from, out fromDuel );
            bool targetInDuel = IsInDuel( target, out targetDuel );
 
            if( fromInDuel && targetInDuel )
            {
                if( fromDuel == null || targetDuel == null )
                    return NotorietyHandlers.Mobile_AllowHarmful( from, target );
 
                return ( fromDuel == targetDuel );
            }
            else if( ( fromInDuel && !targetInDuel ) || ( targetInDuel && !fromInDuel ) )
                if( from.Player && target.Player )
                    return false;
           
            return NotorietyHandlers.Mobile_AllowHarmful( from, target );
        }
into your Notoriety.cs inside of their respective methods...

Do not forget to comment out this line in DuelController.cs as well:
Code:
Notoriety.Handler = new NotorietyHandler( Notoriety_HandleNotoriety );

Also, some of the methods such as IsInDuel( mobile from, out bool ) are static methods within the DuelController class. You will need to specify the class for these methods ( ie. DuelController.IsInDuel( from, out fromDuel ); ) in order for them to be called from within Notoriety.cs.
 

Fixxxer

Sorceror
Thank you for the help with the notoriety, I get the errors you are talking about with the IsInDuel not working. Not sure where I need to make these edits and what they are exactly. In the DuelController.cs there are many statements of IsInDuel.

Code:
Errors:
+ Misc/Notoriety.cs:
    CS0246: Line 62: The type or namespace name 'Duel' could not be found (are y
ou missing a using directive or an assembly reference?)
    CS0103: Line 63: The name 'IsInDuel' does not exist in the current context
    CS0103: Line 64: The name 'IsInDuel' does not exist in the current context
    CS0246: Line 90: The type or namespace name 'GuardedRegion' could not be fou
nd (are you missing a using directive or an assembly reference?)
    CS0246: Line 107: The type or namespace name 'Duel' could not be found (are
you missing a using directive or an assembly reference?)
    CS0103: Line 108: The name 'IsInDuel' does not exist in the current context
    CS0103: Line 109: The name 'IsInDuel' does not exist in the current context

It could be that I cannot script anything and that I am a bit lost with this part.
 

zack0428

Page
can someone tell me what might be wrong here >

heres the shard crash log

Items: 269338
Exception:
System.ArgumentException: An item with the same key has already been added.
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at Server.Dueling.DuelPoints.AddWin(Int32 numPerTeam, DuelInfo duelInfo)
at Server.Dueling.DuelController.AddWin(Duel duel, Mobile m)
at Server.Dueling.Duel.AttackersWin()
at Server.Dueling.Duel.EndDuel()
at Server.Dueling.DuelController.EventSink_PlayerDeath(PlayerDeathEventArgs e)
at Server.PlayerDeathEventHandler.Invoke(PlayerDeathEventArgs e)
at Server.Mobile.OnDeath(Container c)
at Server.Mobiles.PlayerMobile.OnDeath(Container c)
at Server.Mobile.Kill()
at Server.Mobile.Damage(Int32 amount, Mobile from, Boolean informMount)
at Server.AOS.Damage(Mobile m, Mobile from, Int32 damage, Boolean ignoreArmor, Int32 phys, Int32 fire, Int32 cold, Int32 pois, Int32 nrgy, Int32 chaos, Int32 direct, Boolean keepAlive, Boolean archer, Boolean deathStrike)
at Server.Items.BaseWeapon.OnHit(Mobile attacker, Mobile defender, Double damageBonus)
at Server.Items.BaseAxe.OnHit(Mobile attacker, Mobile defender, Double damageBonus)
at Server.Items.BaseWeapon.OnSwing(Mobile attacker, Mobile defender, Double damageBonus)
at Server.Mobile.CombatTimer.OnTick()
at Server.Timer.Slice()
at Server.Core.Main(String[] args)
 
Top