ScriptUO

Scripting Resources & Utilities => Stealth Client => Topic started by: rwo001 on December 30, 2015, 05:57:10 PM

Title: [C#] Buff Event Question
Post by: rwo001 on December 30, 2015, 05:57:10 PM
Code: [Select]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ScriptSDK.API;

namespace StealthUO
{
    class Program
    {       
        static void Main(string[] args)
        {
            Stealth.Client.Buff_DebuffSystem += _onBuff;           
            Stealth.Client.CastSpell("Lightning Strike");  // Toggle On
            Stealth.Client.CastSpell("Lightning Strike");  // Toggle Off
           
            Console.ReadKey();
        }

        public static void _onBuff(object sender, Buff_DebuffSystemEventArgs e)
        {
            Console.WriteLine(e.AttributeId);
            Console.WriteLine(e.IsEnabled);           
        }
    }
}

I expected the about code shoud return
Code: [Select]
1096
True
1096
False
But the result is
Code: [Select]
1096
False
1096
False

Anyone knows what the problem is?
Title: Re: [C#] Buff Event Question
Post by: rwo001 on December 30, 2015, 06:25:08 PM
Code: [Select]
namespace ScriptSDK.API
{
  public class Buff_DebuffSystemEventArgs : ObjectEventArgs
  {
    public ushort AttributeId { get; private set; }

    public bool IsEnabled { get; private set; }

    public Buff_DebuffSystemEventArgs(uint objectId, ushort attributeId, bool isEnabled)
      : base(objectId)
    {
      this.AttributeId = attributeId;
      this.IsEnabled = this.IsEnabled;
      // Is it the reason why the return value incorrect?
      // this.IsEnabled = isEnabled?
    }
  }
}
Title: Re: [C#] Buff Event Question
Post by: Crome969 on December 31, 2015, 01:28:32 AM
The ScriptSDK.API is Maxwells handler for using Stealth in C# if we look at the event properly we will see :

Code: [Select]
this.IsEnabled = this.IsEnabled;Boolean Values are false by Default. So if you assign x = x then x is ... x.
Correct should be :
Code: [Select]
this.IsEnabled = this.isEnabled;
And then it has 2 different variables and get the correct assignment.

I go now check if he fixed it on his source if not i will fix it on his side as well
Title: Re: [C#] Buff Event Question
Post by: Crome969 on December 31, 2015, 01:57:40 AM
* Fixed on SDK
* Fixed on Maxwells Repo
* Rebuild and upload on Sourceforge