ScriptUO

Scripting Resources & Utilities => Stealth Client => Topic started by: Arathorn on July 31, 2017, 03:50:17 AM

Title: C# Help with gumps
Post by: Arathorn on July 31, 2017, 03:50:17 AM
Hi everyone!

I used to work with stealth and Pascal, but i decided tomove to C#.  Ive been reading the forum but im stuck with events and gumps... Where i can get more information or tutorial with basics scripts for gumps?
Im writting a taming script and i want to release the tamed pets, but i cant work out how to manage the release gumps, any advice?

Code: [Select]
public static void CheckGump(object sender,IncomingGumpEventArgs e)
        {
             Gump.GetGump(e.Serial);
            List<uint> Type = Gump.Types;
            List<GumpButton> buttons =
            foreach (var button in buttons)
            {
                Console.WriteLine("Id: {0}", buttons);
            }
            foreach(var types in Type)
            {
                Console.WriteLine("Id: {0}", types);
            }

Thx in advance!


Post Merge: August 01, 2017, 01:10:31 AM
when i use this code with a runebook, it works  and it clicks on a button. But with this type of gump I get an error:

Code: [Select]
System.NullReferenceException occurred
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=ScriptSDK
  StackTrace:
   at ScriptSDK.Gumps.Gump..ctor(GumpInfo g)
   at ScriptSDK.Gumps.Gump.GetGump(UInt32 Type)
   at ConsoleApp2.Program.OnGump(Object sender, IncomingGumpEventArgs e) in C:\Users\Program.cs:line 31
   at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
   at StealthAPI.Stealth.OnIncomingGump(UInt32 serial, UInt32 gumpId, UInt32 x, UInt32 y)
   at StealthAPI.Stealth.ProcessEvent(ExecEventProcData data)
   at StealthAPI.Stealth.cln_ServerEventRecieve(Object sender, ServerEventArgs e)
   at StealthAPI.StealthClient.OnServerEventRecieve(ExecEventProcData data)
   at StealthAPI.StealthClient.<>c__DisplayClass22_0.<ProcessPacket>b__0()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
Code: [Select]
public static void OnGump(object sender, IncomingGumpEventArgs e)
        {
            Console.WriteLine("Incoming gump...");
            if (e.GumpId == (uint)0x909CC741)
                {
                Gump tmp = Gump.GetGump(e.GumpId);
                List<GumpButton> buttons = tmp.Buttons;
                buttons[0].Click();
                }
           
            Console.ReadKey();
        }
Title: Re: C# Help with gumps
Post by: Crome969 on August 09, 2017, 05:56:29 AM
you might try out my SDK for C# : https://github.com/Crome696/ScriptSDK
It should help you on your journey through stealth and C# and allows anyone to support me via merge requests or issue reports.