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!

Knives Chat 3.0 Beta 9 Crash

Zoul

Wanderer
Hey guys, I just got all setup with one of the posts on the site and I am running 2.5 I did this a very long time ago and trying it again for just a few of us friends and family. love the site good job all...

I got this Knives Chat 3.0 Beta 9 and trying to install it I attached the crash report picture and the file itself. The crash happens in the chat3Party.cs, it is saying has invalid arguments and also can't convert from Server.Mobile to Server.Engines.PartySystem.PartyMemberInfo

what do I need to change in the code to make this work? does it just need a using statement added? is it a path issue? hope someone can help me, thanks!
 

Attachments

  • Chat3Party.cs
    3.8 KB · Views: 1
  • Crash.jpg
    31.9 KB · Views: 8

daat99

Moderator
Staff member
I can't tell you much about the code because I can't download cs files here.
If you can post the cs file in code tags than I could look at it.

However, the picture you posted isn't a crash but an error saying you are calling a method and giving it something it doesn't know how to handle.
This is most likely due to missing code or wrong merge.
 

Zoul

Wanderer
I can't tell you much about the code because I can't download cs files here.
If you can post the cs file in code tags than I could look at it.

However, the picture you posted isn't a crash but an error saying you are calling a method and giving it something it doesn't know how to handle.
This is most likely due to missing code or wrong merge.


Hi, thanks for getting back to me so quick! I believe the problem is here in the quote in the data.Mobile argument... the picture I attached with the error is eluding to this.

if (data.GlobalW && !p.Members.Contains(data.Mobile))

The error says it can't convert from Server.Mobile to Server.Engines.PartySystem.PartyMemberInfo, has invalid arguments. What do the arguments need to be changed to? or does the file PartyMemberInfo that sits in Scripts.Engines.party.PartyMemberInfo need to be modified? I have that code at the very bottom in a quote.




This is where the error is occurring in Chat3Party.cs
The Knives chat is sitting in my custom folder at the moment.
public override void OnPublicMessage( Mobile from, string text )
{
if ( text.Length > 128 || (text = text.Trim()).Length == 0 )
return;

Party p = Party.Get( from );

if (p != null)
{
p.SendPublicMessage(from, text);

foreach (Data data in Data.Datas.Values)
if (data.GlobalW && !p.Members.Contains(data.Mobile))
data.Mobile.SendMessage(data.GlobalWC, "(Global) <World->Party> {0}: {1}", from.Name, text);
}
else
from.SendLocalizedMessage(3000211); // You are not in a party.








This is all the code in ChatParty.cs
C#:
using System;
using Server;
using Server.Network;
using Knives.Chat3;
 
namespace Server.Engines.PartySystem
{
    public class Chat3Party : PartyCommands
    {
        public static void Initialize()
        {
            Timer.DelayCall(TimeSpan.Zero, new TimerCallback(AfterInit));
        }
 
        private static void AfterInit()
        {
            PartyCommands.Handler = new Chat3Party();
        }
 
        public override void OnAdd( Mobile from )
        {
            Party p = Party.Get( from );
 
            if ( p != null && p.Leader != from )
                from.SendLocalizedMessage( 1005453 ); // You may only add members to the party if you are the leader.
            else if ( p != null && (p.Members.Count + p.Candidates.Count) >= Party.Capacity )
                from.SendLocalizedMessage( 1008095 ); // You may only have 10 in your party (this includes candidates).
            else
                from.Target = new AddPartyTarget( from );
        }
 
        public override void OnRemove( Mobile from, Mobile target )
        {
            Party p = Party.Get( from );
 
            if ( p == null )
            {
                from.SendLocalizedMessage( 3000211 ); // You are not in a party.
                return;
            }
 
            if ( p.Leader == from && target == null )
            {
                from.SendLocalizedMessage( 1005455 ); // Who would you like to remove from your party?
                from.Target = new RemovePartyTarget();
            }
            else if ( (p.Leader == from || from == target) && p.Contains( target ) )
            {
                p.Remove( target );
            }
        }
 
        public override void OnPrivateMessage( Mobile from, Mobile target, string text )
        {
            if ( text.Length > 128 || (text = text.Trim()).Length == 0 )
                return;
 
            Party p = Party.Get( from );
 
            if ( p != null && p.Contains( target ) )
                p.SendPrivateMessage( from, target, text );
            else
                from.SendLocalizedMessage( 3000211 ); // You are not in a party.
        }
 
        public override void OnPublicMessage( Mobile from, string text )
        {
            if ( text.Length > 128 || (text = text.Trim()).Length == 0 )
                return;
 
            Party p = Party.Get( from );
 
            if (p != null)
            {
                p.SendPublicMessage(from, text);
 
                foreach (Data data in Data.Datas.Values)
                    if (data.GlobalW && !p.Members.Contains(data.Mobile))
                        data.Mobile.SendMessage(data.GlobalWC, "(Global) <World->Party> {0}: {1}", from.Name, text);
            }
            else
                from.SendLocalizedMessage(3000211); // You are not in a party.
        }
 
        public override void OnSetCanLoot( Mobile from, bool canLoot )
        {
            Party p = Party.Get( from );
 
            if ( p == null )
            {
                from.SendLocalizedMessage( 3000211 ); // You are not in a party.
            }
            else
            {
                PartyMemberInfo mi = p[from];
 
                if ( mi != null )
                {
                    mi.CanLoot = canLoot;
 
                    if ( canLoot )
                        from.SendLocalizedMessage( 1005447 ); // You have chosen to allow your party to loot your corpse.
                    else
                        from.SendLocalizedMessage( 1005448 ); // You have chosen to prevent your party from looting your corpse.
                }
            }
        }
 
        public override void OnAccept( Mobile from, Mobile sentLeader )
        {
            Mobile leader = from.Party as Mobile;
            from.Party = null;
 
            Party p = Party.Get( leader );
 
            if ( leader == null || p == null || !p.Candidates.Contains( from ) )
                from.SendLocalizedMessage( 3000222 ); // No one has invited you to be in a party.
            else if ( (p.Members.Count + p.Candidates.Count) <= Party.Capacity )
                p.OnAccept( from );
        }
 
        public override void OnDecline( Mobile from, Mobile sentLeader )
        {
            Mobile leader = from.Party as Mobile;
            from.Party = null;
 
            Party p = Party.Get( leader );
 
            if ( leader == null || p == null || !p.Candidates.Contains( from ) )
                from.SendLocalizedMessage( 3000222 ); // No one has invited you to be in a party.
            else
                p.OnDecline( from, leader );
        }
    }
}

Code:
code=csharp
 
public override void OnPublicMessage( Mobile from, string text )
        {
            if ( text.Length > 128 || (text = text.Trim()).Length == 0 )
                return;
 
            Party p = Party.Get( from );
 
            if (p != null)
            {
                p.SendPublicMessage(from, text);
 
                foreach (Data data in Data.Datas.Values)
                    if (data.GlobalW && !p.Members.Contains(data.Mobile))
                        data.Mobile.SendMessage(data.GlobalWC, "(Global) <World->Party> {0}: {1}", from.Name, text);
            }
            else
                from.SendLocalizedMessage(3000211); // You are not in a party.
        }







This is the other file PartyMemberInfo that sits in Scripts.Engines.Party and comes with RunUO
using System;
using Server;

namespace Server.Engines.PartySystem
{
public class PartyMemberInfo
{
private Mobile m_Mobile;
private bool m_CanLoot;

public Mobile Mobile{ get{ return m_Mobile; } }
public bool CanLoot{ get{ return m_CanLoot; } set{ m_CanLoot = value; } }

public PartyMemberInfo( Mobile m )
{
m_Mobile = m;
m_CanLoot = !Core.ML;
}
}
}
 

daat99

Moderator
Staff member
The stupid/lazy workaround would be to iterate on the "party member info"s and look for your mobile.
so I change this:
Code:
foreach (Data data in Data.Datas.Values)
    if (data.GlobalW && !p.Members.Contains(data.Mobile))
        data.Mobile.SendMessage(data.GlobalWC, "(Global) <World->Party> {0}: {1}", from.Name, text);
to this:
Code:
foreach (Data data in Data.Datas.Values)
{
    if (data.GlobalW)
    {
        bool exist = false;
        foreach ( PartyMemberInfo pmi in p.Members )
        {
              if ( pmi.Mobile == data.Mobile )
              {
                  exist = true;
                  break;
              }
        }
        if ( !exist )
        {
            data.Mobile.SendMessage(data.GlobalWC, "(Global) <World->Party> {0}: {1}", from.Name, text);
        }
    }
}

The correct fix is to see what code you are missing.
Basically the code you posted suggested that either there was (in older code than yours) or currently is (in newer code than yours) some code which can check if a party contains a specific mobile (not PartyMemberInfo).
Locating the missing code will be the best approach.
 

daat99

Moderator
Staff member
Make sure it actually does what it is supposed to do.
Having the code compile doesn't always means it's working right :)
 
Top