Chucl

Member
ServUO Version
Publish Unknown
Ultima Expansion
None
Hello im trying to add the screeneffect packets to rununo 2.2

I added on packets.cs then compiled the server


packets.cs:
    public enum ScreenEffectType
    {
        FadeOut = 0x00,
        FadeIn = 0x01,
        LightFlash = 0x02,
        FadeInOut = 0x03,
        DarkFlash = 0x04
    }

    public class ScreenEffect : Packet
    {
        public ScreenEffect( ScreenEffectType type )
            : base( 0x70, 28 )
        {
            m_Stream.Write( (byte)0x04 );
            m_Stream.Fill( 8 );
            m_Stream.Write( (short)type );
            m_Stream.Fill( 16 );
        }
    }

    public sealed class ScreenFadeOut : ScreenEffect
    {
        public static readonly Packet Instance = Packet.SetStatic( new ScreenFadeOut() );

        public ScreenFadeOut()
            : base( ScreenEffectType.FadeOut )
        {
        }
    }

    public sealed class ScreenFadeIn : ScreenEffect
    {
        public static readonly Packet Instance = Packet.SetStatic( new ScreenFadeIn() );

        public ScreenFadeIn()
            : base( ScreenEffectType.FadeIn )
        {
        }
    }

    public sealed class ScreenFadeInOut : ScreenEffect
    {
        public static readonly Packet Instance = Packet.SetStatic( new ScreenFadeInOut() );

        public ScreenFadeInOut()
            : base( ScreenEffectType.FadeInOut )
        {
        }
    }

    public sealed class ScreenLightFlash : ScreenEffect
    {
        public static readonly Packet Instance = Packet.SetStatic( new ScreenLightFlash() );

        public ScreenLightFlash()
            : base( ScreenEffectType.LightFlash )
        {
        }
    }

    public sealed class ScreenDarkFlash : ScreenEffect
    {
        public static readonly Packet Instance = Packet.SetStatic( new ScreenDarkFlash() );

        public ScreenDarkFlash()
            : base( ScreenEffectType.DarkFlash )
        {
        }
    }

Nothing happens in game whenever it try to send the packet

I even tried to ''register'' the packet in packethandlers.cs

Register(0x70, 28, true, new OnPacketReceive(HandleScreenEffect));

also tried this in packethandlers.cs



This is the code trying to send the packet in game:

sendingpacketscript.cs:
var playerprocess = World.Mobiles.Values
    .OfType<PlayerMobile>()
    .Where(pm => pm != null && !pm.Deleted);

foreach (PlayerMobile pm in playerprocess)
{
    NetState ns = pm.NetState;
    Console.WriteLine("Processing player: " + pm.Name + ", NetState: " + (ns != null ? "Not Null" : "Null"));

    if (ns != null)
    {
        Console.WriteLine("Sending packet to " + pm.Name);
        Random random = new Random();
        Array values = Enum.GetValues(typeof(ScreenEffectType));
        ScreenEffectType randomEffect = (ScreenEffectType)values.GetValue(random.Next(values.Length));

        Packet packetToSend = null;

        switch (randomEffect)
        {
            case ScreenEffectType.FadeOut:
                packetToSend = ScreenFadeOut.Instance;
                pm.Say("Recibo packet: FadeOut");
                break;
            case ScreenEffectType.FadeIn:
                packetToSend = ScreenFadeIn.Instance;
                pm.Say("Recibo packet: FadeIn");
                break;
            case ScreenEffectType.LightFlash:
                packetToSend = ScreenLightFlash.Instance;
                pm.Say("Recibo packet: LightFlash");
                break;
            case ScreenEffectType.FadeInOut:
                packetToSend = ScreenFadeInOut.Instance;
                pm.Say("Recibo packet: FadeInOut");
                break;
            case ScreenEffectType.DarkFlash:
                packetToSend = ScreenDarkFlash.Instance;
                pm.Say("Recibo packet: DarkFlash");
                break;
        }

        if (packetToSend != null)
        {
            Console.WriteLine("Sending packet type: " + randomEffect);
            ns.Send(packetToSend);
            Console.WriteLine("Packet sent to " + pm.Name);
        }
        else
        {
            Console.WriteLine("Packet to send is null!");
        }
    }
}




@Voxpire vox, maybe you know what could be the issue?

Thanks
 
It works only for clients > 7.0.x versions
And doesn't support by ClassicUO

What the client and version do you use ?
 

Active Shards

Donations

Total amount
$250.00
Goal
$500.00
Back