Author Topic: C# Help with gumps  (Read 3378 times)

0 Members and 1 Guest are viewing this topic.

Offline ArathornTopic starter

  • Restricted
  • *
  • Posts: 1
  • Activity:
    0%
  • Reputation Power: 1
  • Arathorn has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
C# Help with gumps
« on: July 31, 2017, 03:50:17 AM »
0
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();
        }
« Last Edit: August 01, 2017, 01:10:31 AM by Arathorn »

Offline Crome969

  • Moderator
  • *
  • *****
  • Posts: 2098
  • Activity:
    0%
  • Reputation Power: 25
  • Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.
  • Gender: Male
  • UO Enthusiast
  • Respect: +211
  • Referrals: 10
    • View Profile
    • ScriptSDK
Re: C# Help with gumps
« Reply #1 on: August 09, 2017, 05:56:29 AM »
0
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.

Tags: