1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Gold as resource

Discussion in 'Script Support' started by Redmoon, Feb 19, 2014.

  1. Redmoon
    Offline

    Redmoon Active Member

    Joined:
    Sep 16, 2013
    Messages:
    264
    Likes Received:
    39
    Publish Number:
    54
    I'm trying to make gold dust, and am getting this crash:
    Code (C#):
    1. Server Crash Report
    2. ===================
    3.  
    4. RunUO Version 0.5, Build 5151.20665
    5. Operating System: Microsoft Windows NT 6.1.7601 Service Pack 1
    6. .NET Framework: 4.0.30319.18444
    7. Time: 2/19/2014 3:46:19 PM
    8. Mobiles: 43317
    9. Items: 236651
    10. Exception:
    11. System.MissingMethodException: No parameterless constructor defined for this object.
    12.   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
    13.   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
    14.   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
    15.   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
    16.   at System.Activator.CreateInstance(Type type)
    17.   at Server.Engines.Craft.CraftItem.CompleteCraft(Int32 quality, Boolean makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CustomCraft customCraft)
    18.   at Server.Engines.Craft.CraftItem.InternalTimer.OnTick()
    19.   at Server.Timer.Slice() in c:\Reds Domain Pub 54\Server\Timer.cs:line 387
    20.   at Server.Core.Main(String[] args) in c:\Reds Domain Pub 54\Server\Main.cs:line 622
    Here is the simple GoldDust.cs (no problems adding it IG)
    Code (C#):
    1. using System;
    2. using Server.Items;
    3. using Server.Network;
    4.  
    5. namespace Server.Items
    6. {
    7.  
    8.     public class GoldDust : Item
    9.     {
    10.         [Constructable]
    11.         public GoldDust(int amount) : base(0x4C09)
    12.         {
    13.             Name = "Gold Dust";
    14.             Stackable = true;
    15.             Hue = 1161;//get hue
    16.             Weight = 1.0;
    17.             Amount = amount;
    18.         }
    19.  
    20.         public GoldDust(Serial serial)
    21.             : base(serial)
    22.         {
    23.         }
    24.  
    25.         public override void Serialize(GenericWriter writer)
    26.         {
    27.             base.Serialize(writer);
    28.  
    29.             writer.Write((int)0); // version
    30.         }
    31.  
    32.         public override void Deserialize(GenericReader reader)
    33.         {
    34.             base.Deserialize(reader);
    35.  
    36.             int version = reader.ReadInt();
    37.         }
    38.     }
    39.  
    40. }
    And the DefAlchemy.cs:
    Code (C#):
    1.          
    2. index = this.AddCraft(typeof(GoldDust), 1098336, 1098337, 90.0, 120.0, typeof(Gold), 3000083, 1000, 1150747);
    3.  this.SetNeededExpansion(index, Expansion.SA);
    I'm thinking it has something to do with this in the Gold.cs:
    Code (C#):
    1.         public Gold(int amountFrom, int amountTo)
    2.             : this(Utility.RandomMinMax(amountFrom, amountTo))
     
  2. Kalamus
    Offline

    Kalamus Active Member

    Joined:
    Apr 24, 2013
    Messages:
    288
    Likes Received:
    33
    You need a parameterless constructor. Try adding this and see if it works. I don't have access to test it at the moment.
    Code (C#):
    1. [Constructable]
    2. public GoldDust() : this(1)
    3. {
    4. }
     
  3. Redmoon
    Offline

    Redmoon Active Member

    Joined:
    Sep 16, 2013
    Messages:
    264
    Likes Received:
    39
    I get a client crash, and re-crashes on re-log with this one, but the new art for the gold dust shows up now.
     
  4. Kalamus
    Offline

    Kalamus Active Member

    Joined:
    Apr 24, 2013
    Messages:
    288
    Likes Received:
    33
    Are the crashes happening from crafting? Does the '[add golddust' or '[add golddust 100' commands work?
     
  5. dmurphy
    Offline

    Admin ServUO Developer

    Joined:
    Feb 10, 2014
    Messages:
    1,011
    Likes Received:
    199
    try removing :this(1) in Kalamus's code above and see how it goes. I just tried there and had no crash but I do not have your art.
     
    • Bravery Award Bravery Award x 1
  6. Kalamus
    Offline

    Kalamus Active Member

    Joined:
    Apr 24, 2013
    Messages:
    288
    Likes Received:
    33
    The ': this(1)' just calls the other constructor with int value of 1. It's the same as as doing '[add golddust 1' but without having to assign the 1 value. If that's removed then then it won't call the base constructor or add any of the values assigned in the other constructor.
     
    • Like Like x 1
  7. dmurphy
    Offline

    Admin ServUO Developer

    Joined:
    Feb 10, 2014
    Messages:
    1,011
    Likes Received:
    199
    My bad :p
     
  8. Redmoon
    Offline

    Redmoon Active Member

    Joined:
    Sep 16, 2013
    Messages:
    264
    Likes Received:
    39
    Yes, these work fine. I'm thinking it's due to converting Gold.cs into a resource?

    Code (C#):
    1. (int amountFrom, int amountTo)
     
  9. Kalamus
    Offline

    Kalamus Active Member

    Joined:
    Apr 24, 2013
    Messages:
    288
    Likes Received:
    33
    I just tested the GoldDust with the added constructor and the DefAlchemy change you posted above. Add commands and crafting is working fine for me. Did you make any changes anywhere else?
     
  10. Redmoon
    Offline

    Redmoon Active Member

    Joined:
    Sep 16, 2013
    Messages:
    264
    Likes Received:
    39
    Not at all.
     
  11. Redmoon
    Offline

    Redmoon Active Member

    Joined:
    Sep 16, 2013
    Messages:
    264
    Likes Received:
    39
    Though, it shouldn't matter, can I ask what section you put it in in the DefAlchemy.cs?
     
  12. Kalamus
    Offline

    Kalamus Active Member

    Joined:
    Apr 24, 2013
    Messages:
    288
    Likes Received:
    33
    I just added it to the very end of the init list, past the Plant Pigments/Natural Dyes area.

    Recap everything for me. What client version are you using? Are you using custom art? When is the client crashing, when you [add the golddust or craft it? Does your script match up with what I have below?

    I'm guessing there's something different about your client if you are getting client crashes but not server crashes.

    Here's the full GoldDust script with the added constructor just for recapping purposes.
    Code (C#):
    1. using System;
    2. using Server.Items;
    3. using Server.Network;
    4.  
    5. namespace Server.Items
    6. {
    7.  
    8.     public class GoldDust : Item
    9.     {
    10.         [Constructable]
    11.         public GoldDust()
    12.             : this(1)
    13.         {
    14.         }
    15.  
    16.         [Constructable]
    17.         public GoldDust(int amount)
    18.             : base(0x4C09)
    19.         {
    20.             Name = "Gold Dust";
    21.             Stackable = true;
    22.             Hue = 1161;//get hue
    23.             Weight = 1.0;
    24.             Amount = amount;
    25.         }
    26.  
    27.         public GoldDust(Serial serial)
    28.             : base(serial)
    29.         {
    30.         }
    31.  
    32.         public override void Serialize(GenericWriter writer)
    33.         {
    34.             base.Serialize(writer);
    35.  
    36.             writer.Write((int)0); // version
    37.         }
    38.  
    39.         public override void Deserialize(GenericReader reader)
    40.         {
    41.             base.Deserialize(reader);
    42.  
    43.             int version = reader.ReadInt();
    44.         }
    45.     }
    46.  
    47. }
     
    • Winner Winner x 1
    • Love You Love You x 1
  13. Redmoon
    Offline

    Redmoon Active Member

    Joined:
    Sep 16, 2013
    Messages:
    264
    Likes Received:
    39
    I could hug ya!!! Yep I didn't have the same script as you. It's working now! WOOT! WOOT! Now to finish adding in the rest of the craftables.
     
  14. Kalamus
    Offline

    Kalamus Active Member

    Joined:
    Apr 24, 2013
    Messages:
    288
    Likes Received:
    33
    Ahh sweet, glad I was able to help :).
     
  15. Redmoon
    Offline

    Redmoon Active Member

    Joined:
    Sep 16, 2013
    Messages:
    264
    Likes Received:
    39
    Me too! Me too! *knuckle bombs Kalamus* :D
     
Similar Threads: Gold resource
Forum Title Date
Custom Releases Gold Safe Jul 14, 2018
Archived Bug Reports SOS - Should drop more gold Jul 13, 2018
Script Support Fixing Gold Dropping to Feet Jul 13, 2018
Script Support Party Gold Splitting Jun 30, 2018
Script Support Withdrawing gold from bankbox Jun 20, 2018
Archived Bug Reports "withdraw XXXX" gold from Bank not working on shared account gold - new characters only May 21, 2018
Archived Bug Reports Golden stuff and luck bonus May 16, 2018