ServUO Version
Publish 57
Ultima Expansion
Endless Journey
Getting the following error when trying to use two scripts that were downloaded from here, the error:
C#:
error CS0118: 'BirthdayCake' is a namespace but is used like a type [C:\ServUO\Scripts\Scripts.csproj]
the code causing the error:
C#:
            BirthdayCake bc = new BirthdayCake();
            bc.Hue = 6;
            bc.Name = "Happy Birthday Nathan!";
            box.DropItem( bc );
and the script it is referencing:
C#:
using System;
using System.Collections;
using Server;
using Server.Network;

namespace Server.Items
{
    public class BirthdayCake : Food
    {

        [Constructable]
        public BirthdayCake() : this( 1 )
        {   
        }
        
        [Constructable]
        public BirthdayCake( int amount ) : base( 0xF8F, amount )
        {
            this.Hue = 2634;
            this.Name = "A Happy Birthday cake";
            this.Movable = true;
            this.ItemID = 2537;
            this.Amount = amount;
            this.FillFactor = 20;
            this.Weight = 0;
            this.Stackable = true;
        }
        
        public override void GetProperties( ObjectPropertyList list )
        {
            base.GetProperties( list );

            list.Add( "Happy Birthday!" );
        }

        public BirthdayCake( Serial serial ) : base( serial )
        {
        }
        
        public override void Serialize( GenericWriter writer )
        {
            base.Serialize( writer );

            writer.Write( (int) 0 ); // version
        }

        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize( reader );

            int version = reader.ReadInt();
        }
    }
}

Sample script with the code causing the error:
C#:
using System;
using Server;
using Server.Items;
using Server.Gumps;

namespace Server.Misc
{
    public class NathanBirthdayCakeGiver : GiftGiver
    {
        public static void Initialize()
        {
            GiftGiving.Register( new NathanBirthdayCakeGiver() );
        }

        public override DateTime Start{ get{ return new DateTime( 1980, 6, 26 ); } }
        public override DateTime Finish{ get{ return new DateTime( 2023, 6, 29 ); } }

        public override void GiveGift( Mobile mob )
        {
            GiftBox box = new GiftBox();
            box.Hue = Utility.RandomList( 1436 );

            box.DropItem( new FireworksWand() );

            BirthdayCake bc = new BirthdayCake();
            bc.Hue = 6;
            bc.Name = "Happy Birthday Nathan!";
            box.DropItem( bc );

            bool pack = GiveGift( mob, box);
            mob.SendGump( new GiftPackageGump( pack, "Happy Birthday Nathan!" ));
        }
    }
}
 
It's because you have another script with the namespace BirthdayCake

Like this
 

Attachments

  • Screenshot_20220628-163343_Chrome.jpg
    Screenshot_20220628-163343_Chrome.jpg
    20.8 KB · Views: 6
Well that's dumb.. you think it'd throw an error with 2 items named the same lol.. I was not aware of that one, thanks Zero I'll fix when I get home.. sigh..
 
Last edited:
I
Well that's dumb.. you think it'd throw an error with 2 items named the same lol.. I was no aware of that one, thanks Zero I'll fix when I get home.. sigh..
It would but the class name is BirthdayCakeAddon

It's a symptom of giving too much "power" via ceo's addon gen. Only in rare instances should the namespace be something besides the default: Server.Addons
 
Back