Default character on create.

Lemke

Squire
Sep 26, 2015
164
19
18
38
Hello,i have an issue using a script to create all characters standard,my shard is 1 acount per ip,1 character per ip.
Script is running well but if i delete my character and try to create another one,i can choose a new race and starter options (standard).
I want to be only humans shard so its a problem for me,here the script can be found here at the forum:

C#:
using System;
using System.Collections.Generic;
using System.Text;
using Server;
using Server.Accounting;
using Server.Mobiles;
using Server.Misc;
using Server.Network;
using Server.Items;

namespace Bittiez.DefaultCharacter
{
    public class Main
    {
        [CallPriority(Int32.MaxValue)]
        public static void Initialize()
        {
            EventSink.AccountLogin += new AccountLoginEventHandler(EventSink_AccountLogin);
            Console.ForegroundColor = System.ConsoleColor.DarkMagenta;
            Console.WriteLine("Default Character Loaded.");
            Console.ForegroundColor = System.ConsoleColor.White;
        }


        private static Mobile CreateMobile(Account a)
        {
            if (a.Count >= a.Limit)
                return null;

            for (int i = 0; i < a.Length; ++i)
            {
                if (a[i] == null)
                    return (a[i] = new PlayerMobile());
            }

            return null;
        }

        private static void EventSink_CharacterCreated(CharacterCreatedEventArgs args)
        {
            //Console.WriteLine("TEST");
            args.Profession = 0;
            NetState state = null;
            if (args.State != null) state = args.State;

            //if (state == null)                return;

            Mobile newChar = CreateMobile(args.Account as Account);

            if (newChar == null)
            {
                Utility.PushColor(ConsoleColor.Red);
                Console.WriteLine("Login: {0}: Character creation failed, account full", state == null ? "" : state.Address.ToString());
                Utility.PopColor();
                return;
            }

            args.Mobile = newChar;
            newChar.Player = true;
            newChar.AccessLevel = args.Account.AccessLevel;
            newChar.Female = args.Female;

            if (Core.Expansion >= args.Race.RequiredExpansion)
                newChar.Race = args.Race;    //Sets body
            else
                newChar.Race = Race.DefaultRace;

            newChar.Hue = newChar.Race.ClipSkinHue(args.Hue & 0x3FFF) | 0x8000;

            newChar.Hunger = 20;

            bool young = false;

            if (newChar is PlayerMobile)
            {
                PlayerMobile pm = (PlayerMobile)newChar;

                pm.Profession = args.Profession;

                if (((Account)pm.Account).Young)
                    young = pm.Young = true;
            }

            newChar.Name = args.Name;
            newChar.Str = args.Str;
            newChar.Dex = args.Dex;
            newChar.Int = args.Int;
            AddBackpack(newChar);

            Race race = newChar.Race;

            if (race.ValidateHair(newChar, args.HairID))
            {
                newChar.HairItemID = args.HairID;
                newChar.HairHue = race.ClipHairHue(args.HairHue & 0x3FFF);
            }

            if (race.ValidateFacialHair(newChar, args.BeardID))
            {
                newChar.FacialHairItemID = args.BeardID;
                newChar.FacialHairHue = race.ClipHairHue(args.BeardHue & 0x3FFF);
            }

            CityInfo city = new CityInfo("", "", 1, 1, 10);

            newChar.MoveToWorld(city.Location, Map.Felucca);

            new WelcomeTimer(newChar).Start();

            //XmlAttach.AttachTo(newChar, new XmlPoints());
            //XmlAttach.AttachTo(newChar, new XmlMobFactions());
        }

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

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

                m.AddItem(pack);
            }

        }


        public static void EventSink_AccountLogin(AccountLoginEventArgs e)
        {
            if (e.Accepted)
            {
                IAccount acc = Accounts.GetAccount(e.Username);
                if (acc == null || acc.Count > 0)
                    return;
                CharacterCreatedEventArgs arg = new CharacterCreatedEventArgs(
                    null,
                    acc,
                    "New player",
                    false,
                    33770,
                    100,
                    100,
                    100,
                    new CityInfo("", "", 1, 1, 1),
                    null,
                    1,
                    1,
                    1,
                    1,
                    1,
                    1,
                    1,
                    Race.Human
                    );
                EventSink_CharacterCreated(arg);
                Console.ForegroundColor = System.ConsoleColor.DarkMagenta;
                Console.WriteLine("[DC]New character created for account " + acc.Username);
                Console.ForegroundColor = System.ConsoleColor.White;
            }
        }
    }
}
Its possible if anyone delete his own character,go back to the call of this script?Thank you!
Post automatically merged:

I think i need to work on accounthandler.cs:


C#:
private static void EventSink_DeleteRequest(DeleteRequestEventArgs e)
        {
            NetState state = e.State;
            int index = e.Index;

            Account acct = state.Account as Account;

            if (acct == null)
            {
                state.Dispose();
            }
            else if (index < 0 || index >= acct.Length)
            {
                state.Send(new DeleteResult(DeleteResultType.BadRequest));
                state.Send(new CharacterListUpdate(acct));
            }
            else
            {
                Mobile m = acct[index];

                if (m == null)
                {
                    state.Send(new DeleteResult(DeleteResultType.CharNotExist));
                    state.Send(new CharacterListUpdate(acct));
                }
                else if (m.NetState != null)
                {
                    state.Send(new DeleteResult(DeleteResultType.CharBeingPlayed));
                    state.Send(new CharacterListUpdate(acct));
                }
                else if (RestrictDeletion && DateTime.UtcNow < (m.CreationTime + DeleteDelay))
                {
                    state.Send(new DeleteResult(DeleteResultType.CharTooYoung));
                    state.Send(new CharacterListUpdate(acct));
                }
                else if (m.IsPlayer() && Region.Find(m.LogoutLocation, m.LogoutMap).GetRegion(typeof(Jail)) != null)    //Don't need to check current location, if netstate is null, they're logged out
                {
                    state.Send(new DeleteResult(DeleteResultType.BadRequest));
                    state.Send(new CharacterListUpdate(acct));
                }
                else
                {
                    Utility.PushColor(ConsoleColor.Red);
                    Console.WriteLine("Client: {0}: Deleting character {1} (0x{2:X})", state, index, m.Serial.Value);
                    Utility.PopColor();

                    acct.Comments.Add(new AccountComment("System", String.Format("Character #{0} {1} deleted by {2}", index + 1, m, state)));

                    m.Delete();
                    state.Send(new CharacterListUpdate(acct));
                }
            }
        }
Post automatically merged:

UPDATE: I do an account delete with a character delete cause i want players loose his account time when restart the character,it doing well but same problem when the button "New" appears.
Note:If you go back arrow or restart client i got desired results and players can create his new standard char,so im looking how can i do the arrow button result on the new button.
 
Last edited: