Izex

Member
I added a script, found it online on runuo, and it is supposed to create a skill ball when it is the players first character on their account. I am not sure why it isn't working and was looking for some help with it. Here is the link to the forum post I found the code on.

Code:
using System;
using Server.Accounting;
using Server.Engines.XmlSpawner2;
using Server.Items;
using Server.Mobiles;
using Server.Network;


namespace Server.Misc
{
    public class CharacterCreation
    {
        private static readonly CityInfo m_NewHavenInfo = new CityInfo("New Haven", "The Bountiful Harvest Inn", 3503, 2574, 14, Map.Trammel);
        private static Mobile m_Mobile;
        public static void Initialize()
        {
            // Register our event handler
            EventSink.CharacterCreated += new CharacterCreatedEventHandler(EventSink_CharacterCreated);
        }

        public static bool VerifyProfession(int profession)
        {
            if (profession < 0)
                return false;
            else if (profession < 4)
                return true;
            else if (Core.AOS && profession < 6)
                return true;
            else if (Core.SE && profession < 8)
                return true;
            else
                return false;
        }

        private static void AddBackpack(Mobile m)
        {
            Container pack = m.Backpack;

            if (pack == null)
            {
                pack = new Backpack();
                pack.Movable = false;

                m.AddItem(pack);
            }
           
            bool FirstChar = Convert.ToBoolean( ((Account)m.Account).GetTag("FirstChar") );

            if ( FirstChar ) //this part checks to see if the account already has this tag, if it does it will add the following items

                        {
                            PackItem(new SkillBall());
                        }
                       
                        else
                        {

            PackItem(new RedBook("a book", m.Name, 20, true));
            PackItem(new Gold(5000)); // Starting gold can be customized here
            PackItem(new Candle());
            PackItem(new README());
           
            if (m.Race != Race.Gargoyle)
                PackItem(new Dagger());
            else
                PackItem(new GargishDagger());
        }
        }
 
Code:
EventSink.CharacterCreated += new CharacterCreatedEventHandler(EventSink_CharacterCreated);

This line is the one that tells the script what method to run when a new character is created. The method that's being called is EventSink_CharacterCreated, however there's no method with that name in the script so it can't be run (and I'm surprised if it compiles).

You'd want to have a method (that takes the event arguments into account too) named EventSink_CharacterCreated. It would then define the mobile (from the args would be my guess) and then call the AddBackpack Method, passing in the defined mobile. Providing the account has the functionality for defining the tag "FirstChar" correctly that should fix it. If not then you have other things you'd need to do.
 
I can't help on the script...but it seems like a complicated way to get an item to a new character. In the CharacterCreation.cs (scripts/misc) there is a section you simply add the item to their pack. That is what I do for my skill ball and statball.
 
Most of what you said is correct Jack, and while yes most of the time you want to use Initialize method to add to the EventSink, the truth of the matter is no, it wouldn't need to be in that section, an example would be you could have a command that has a static "CharacterCreatedEventHandler" that on command you add, and on a different command you could remove essentially turning on and off the ability. However for this placing it inside the initialize is the best move.
 
Yeah I removed my post because I had a brain fart moment where I thought you were talking about something completely different. Haven't had much sleep :p
 
I was just confused who he was talking to ha ha... I only saw my comment, and my name is not usually Jack :)
 
yeah that made it confusing I'm sure. I didn't see your post last night Tukaram. However the misc/charactercreation.cs script is using the same event to create the character. It is easy enough to create a new script or edit that one but either way it'll still be happening on the same event.
 
Thank you for all of your responses. Since I don't know much about programming I will just remove the first character script and keep it as all characters get one on creation.
 
Oh, I just remembered this great script. Pandora's Gift Box. You can set up gift boxes for one per character, or one per account. It is a physical box you put items in, and make the settings... and the players get a copy of the box & contents. I have one for 'per account' and one for 'per character' - so the first character on a new account will get one of each box, all other characters on that account get just the one.

It works great. You might find it useful.

https://www.servuo.com/threads/pandoras-gift-box.3828/#post-25482
 
Last edited:
Over the years I've been taking "notes" as I run across shortcuts, tips, tricks, etc. I too wondered how to create items that were more unique (one per account, one per character, etc). I don't recall who gave me this code, but I saved it in my notes.

Code:
//One Per Account Here.
			Account ac = m.Account as Account;
            if ( ac != null )
            {
                if (ac.Count == 1 )
                {
	                //Noob one time only pack loot
                    PackItem( MakeNewbie ( new TambourineTassel() ) );
                    PackItem( MakeNewbie ( new Candle() ) );
					PackItem( MakeNewbie ( new Scissors() ) );
					PackItem( MakeNewbie ( new Dagger() ) );
					PackItem( new Apple() );
					PackItem( new RedBook( "a book", m.Name, 20, true ) );
                //Region Ethy (Method used to hue item on creation)
					EtherealHorse mount = new EtherealHorse();
					mount.Hue = ( Utility.RandomMetalHue() );
					PackItem( mount );
				//End Region
			//Noob one time only bank loot caller
					NewbBank( m );
			//Noob Broadcast
					World.Broadcast( 33, true, ""+m.Name+" has joined Mystic for the first time!");
				
                }
            }
 
Look for new player ticket and add it there. That is where I put a special item for the first character only and it works like a gem :]
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back