I have tried a few ways to edit the onsingleclick in playermobile.cs to show a players selected title using the STS custom system but have not been successful. From what I understand the system uses the collection title entries from the OPL and that is what I have been working with. I have had some success with displaying values from the OPL to onsingleclick for items but this one is beyond my ability. Any help or nudge in the right direction would be greatly appreciated.
Thanks!
 
I did it!
ai.imgur.com_mzYXMkc.jpg

If any other oldschoolers want to use this system, this is what I put above the faction stuff under OnSingleClick.
PlayerMobile.cs

Code:
public override void OnSingleClick(Mobile from)
        {
           //STS
           if (m_CollectionTitles != null && m_SelectedTitle > -1)
            {
                if (m_SelectedTitle < m_CollectionTitles.Count)
                {
                    string text;
                    bool ascii = true;
                  
                    text = String.Concat(this.m_CollectionTitles[m_SelectedTitle]);
                    int hue = (38);
                    PrivateOverheadMessage(MessageType.Label, hue, ascii, text, from.NetState);
                }
                  
            }   
           //STS
This is the second custom systems (food effects) that I am using and both are very easy and fun to configure and manipulate.
 
Last edited:
Omg so its possible! I have few system that are not showing above player head, i willl try this tomorrow, should work, thanks fisher!!


Is this system the ''Custom Slayer Title'' ? i think it is the Slayer title system v2.5...none of them talks about that playermobile edit.I guess that edit is necessary for PREAOS servers.
Ive check the installation instructions and it only requires a small basecreature.cs edit

The STS 2.5 was designed for forkuo, it gives me few errors:

Errors:
+ KUSTOM/Slayer Titles/Core/SlayerModule.cs:
CS0246: Line 25: The type or namespace name 'BaseModule' could not be found
(are you missing a using directive or an assembly reference?)
+ KUSTOM/Slayer Titles/Core/SlayerTitleCore.cs:
CS0246: Line 25: The type or namespace name 'BaseCore' could not be found (a
re you missing a using directive or an assembly reference?)
CS0246: Line 29: The type or namespace name 'BaseCore' could not be found (a
re you missing a using directive or an assembly reference?)
+ KUSTOM/Slayer Titles/Examples/SlayerTitleExamples.cs:
CS0234: Line 35: The type or namespace name 'BaseCore' does not exist in the
namespace 'CustomsFramework' (are you missing an assembly reference?)



SlayerModule.cs

Code:
/*****************************************************************************************************************************
*
* Slayer Title Core
* Version 2.5
* Designed for ForkUO 0.2
*
* Authored by Dougan Ironfist
* Last Updated on 2/5/2013
*
* The purpose of these scripts is to allow shard administrators to create fun kill-based titles that players can earn.
  *
****************************************************************************************************************************/

using System;
using System.Collections;

using Server;
using Server.Gumps;
using Server.Mobiles;

/// THIS IS A CORE SCRIPT AND SHOULD NOT BE ALTERED ///

namespace CustomsFramework.Systems.SlayerTitleSystem
{
    public class SlayerModule : BaseModule
    {
        private Hashtable m_TitleEntries = new Hashtable();

        public SlayerModule(Mobile from) : base()
        {
            this.Enabled = true;
            this.LinkMobile(from);
        }

        public SlayerModule(Serial serial) : base(serial)
        {
        }

        public override String Name
        {
            get
            {
                if (this.LinkedMobile != null)
                    return String.Format("Slayer Title Module - {0}", this.LinkedMobile.Name);
                else
                    return "Unlinked Slayer Title Module";
            }
        }

        public override String Description
        {
            get
            {
                if (this.LinkedMobile != null)
                    return String.Format(@"Slayer Title Module that is linked to {0}", this.LinkedMobile.Name);
                else
                    return "Unlinked Slayer Title Module";
            }
        }

        public override String Version
        {
            get
            {
                return SlayerTitleCore.SystemVersion;
            }
        }

        public override AccessLevel EditLevel
        {
            get
            {
                return AccessLevel.Developer;
            }
        }

        public override Gump SettingsGump
        {
            get
            {
                return base.SettingsGump;
            }
        }

        public override void Prep()
        {
            base.Prep();
        }

        public override void Update()
        {
        }

        public void IncrementCounter(String titleName)
        {
            if (m_TitleEntries.ContainsKey(titleName))
                m_TitleEntries[titleName] = (Int32)m_TitleEntries[titleName] + 1;
            else
                m_TitleEntries[titleName] = 1;
        }

        public Int32 GetSlayerCount(String titleName)
        {
            if (m_TitleEntries.ContainsKey(titleName))
                return (Int32)m_TitleEntries[titleName];

            return 0;
        }

        public void SetSlayerCount(String titleName, Int32 count)
        {
            m_TitleEntries[titleName] = count;
        }

        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);

            Utilities.WriteVersion(writer, 0);

            // Version 0
            writer.Write((Int32)m_TitleEntries.Keys.Count);

            foreach (String title in m_TitleEntries.Keys)
            {
                writer.Write((String)title);
                writer.Write((Int32)m_TitleEntries[title]);
            }
        }

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

            Int32 version = reader.ReadInt();

            switch (version)
            {
                case 0:
                    // Version 0
                    Int32 entryCount = reader.ReadInt();

                    for (Int32 i = 0; i < entryCount; i++)
                        m_TitleEntries[reader.ReadString()] = reader.ReadInt();

                    break;
            }
        }
    }
}

SlayerTitleCore.cs

Code:
/*****************************************************************************************************************************
*
* Slayer Title Core
* Version 2.5
* Designed for ForkUO 0.2
*
* Authored by Dougan Ironfist
* Last Updated on 2/5/2013
*
* The purpose of these scripts is to allow shard administrators to create fun kill-based titles that players can earn.
  *
****************************************************************************************************************************/

using System;
using System.Collections.Generic;

using Server;
using Server.Gumps;
using Server.Mobiles;

/// THIS IS A CORE SCRIPT AND SHOULD NOT BE ALTERED ///

namespace CustomsFramework.Systems.SlayerTitleSystem
{
    public class SlayerTitleCore : BaseCore
    {
        #region Event Handlers
        public delegate void KilledByEventHandler(BaseCreature creature, PlayerMobile player);
        public delegate void PostPrepEventHandler(BaseCore core);
        public delegate void SlayerTitleAwardedEventHandler(Mobile from, string titleSystem, string titleAwarded);

        public static event KilledByEventHandler KilledByEvent;
        public static event PostPrepEventHandler PostPrep;
        public static event SlayerTitleAwardedEventHandler SlayerTitleAwarded;
        public static event SlayerTitleAwardedEventHandler MaxSlayerTitleAchieved;

        public static void OnKilledByEvent(BaseCreature creature, PlayerMobile player)
        {
            if (KilledByEvent != null)
                KilledByEvent(creature, player);
        }
        #endregion

        private static Dictionary<String, List<Type>> m_CreatureRegistry = new Dictionary<String, List<Type>>();
        private static Dictionary<String, List<TitleEntry>> m_TitleRegistry = new Dictionary<String, List<TitleEntry>>();

        public const String SystemVersion = "2.5";

        public SlayerTitleCore() : base()
        {
            this.Enabled = true;
        }

        public SlayerTitleCore(Serial serial)
            : base(serial)
        {
        }

        public override String Name
        {
            get
            {
                return "Slayer Title Core";
            }
        }

        public override String Description
        {
            get
            {
                return "Core that contains everything for the Slayer Title System.";
            }
        }

        public override String Version
        {
            get
            {
                return SystemVersion;
            }
        }

        public override AccessLevel EditLevel
        {
            get
            {
                return AccessLevel.Developer;
            }
        }

        public override Gump SettingsGump
        {
            get
            {
                return null;
            }
        }

        public static void Initialize()
        {
            SlayerTitleCore core = World.GetCore(typeof(SlayerTitleCore)) as SlayerTitleCore;

            if (core == null)
            {
                core = new SlayerTitleCore();
                core.Prep();
            }
        }

        public override void Prep() // Called after all cores are loaded
        {
            // See note regarding installing the OnKilledBy hook in BaseCreature.cs at the bottom of this script
            SlayerTitleCore.KilledByEvent += SlayerTitleCore_KilledByEvent;

            if (PostPrep != null)
                PostPrep(this);
        }

        public void RegisterTitleSystem(String titleName, List<Type> creatureTypes, List<TitleEntry> titleEntries)
        {
            if (m_CreatureRegistry.ContainsKey(titleName) || m_TitleRegistry.ContainsKey(titleName))
                return;

            m_CreatureRegistry[titleName] = creatureTypes;
            m_TitleRegistry[titleName] = titleEntries;
        }

        private void SlayerTitleCore_KilledByEvent(BaseCreature creature, PlayerMobile player)
        {
            if (!this.Enabled)
                return;

            // Manual module lookup until next commit of FortkUO
            List<BaseModule> results = World.GetModules(player);

            SlayerModule module = null;

            foreach (BaseModule mod in results)
            {
                if (mod is SlayerModule)
                {
                    module = (SlayerModule)mod;
                    break;
                }
            }

         //   SlayerModule module = player.GetModule(typeof(SlayerModule)) as SlayerModule;

            if (module == null)
                module = new SlayerModule(player);

            foreach (KeyValuePair<String, List<Type>> pair in m_CreatureRegistry)
            {
                if (pair.Value.Contains(creature.GetType()))
                {
                    List<TitleEntry> entries = null;
                    m_TitleRegistry.TryGetValue(pair.Key, out entries);

                    if (entries != null)
                    {
                        module.IncrementCounter(pair.Key);

                        Int32 value = module.GetSlayerCount(pair.Key);
                        TitleEntry titleToSet = null;

                        foreach (TitleEntry entry in entries)
                            if (entry.CountNeeded == value)
                                titleToSet = entry;

                        if (titleToSet != null)
                        {
                            foreach (TitleEntry entry in entries)
                                if (player.CollectionTitles.Contains(entry.Title) && entry != titleToSet)
                                    player.CollectionTitles.Remove(entry.Title);

                            player.AddCollectionTitle(titleToSet.Title);
                            player.SendSound(0x3D);
                            player.SendMessage(0xC8, String.Format("Your have been awarded the title of '{0}' for {1} kills.", titleToSet.Title, value));

                            if (SlayerTitleAwarded != null)
                                SlayerTitleAwarded(player, pair.Key, titleToSet.Title);

                            if (IsMaxTitle(titleToSet.Title, entries) && MaxSlayerTitleAchieved != null)
                                MaxSlayerTitleAchieved(player, pair.Key, titleToSet.Title);

                        }
                    }
                }
            }
        }

        private Boolean IsMaxTitle(String title, List<TitleEntry> entries)
        {
            Int32 maxCount = 0;
            Int32 titleCount = 0;

            foreach (TitleEntry entry in entries)
            {
                if (entry.CountNeeded > maxCount)
                    maxCount = entry.CountNeeded;

                if (entry.Title == title)
                    titleCount = entry.CountNeeded;
            }

            if (titleCount == maxCount)
                return true;
            else
                return false;
        }

        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);

            Utilities.WriteVersion(writer, 0);
        }

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

            Int32 version = reader.ReadInt();

            switch (version)
            {
                case 0:
                    break;
            }
        }
    }
}

SlayerTitleExamples.cs


Code:
/*****************************************************************************************************************************
*
* Slayer Title Core - Examples
* Version 2.5
* Designed for ForkUO 0.2
*
* Authored by Dougan Ironfist
* Last Updated on 1/31/2013
*
* The purpose of these scripts is to allow shard administrators to create fun kill-based titles that players can earn.
*
****************************************************************************************************************************/

using System;
using System.Collections.Generic;

using Server;
using Server.Items;
using Server.Mobiles;

using CustomsFramework.Systems.SlayerTitleSystem;

/// THIS IS AN EXAMPLE SCRIPT AND MAY BE USED TO CREATE ADDITIONAL SLAYER TITLE GROUPS ///

namespace Dougan.SlayerTitle.Examples
{
    public class SlayerTitleExamples
    {
        public static void Configure()
        {
            SlayerTitleCore.PostPrep += SlayerTitleCore_PostPrep;
            SlayerTitleCore.MaxSlayerTitleAchieved += SlayerTitleCore_MaxSlayerTitleAchieved;
        }

        static void SlayerTitleCore_PostPrep(CustomsFramework.BaseCore core)
        {
            if (core is SlayerTitleCore)
            {
                // Sheep Slayer Titles
                ((SlayerTitleCore)core).RegisterTitleSystem("Sheep Slayer",
                    new List<Type>()
                    {
                        typeof(Sheep)
                    },
                    new List<TitleEntry>()
                    {
                        new TitleEntry("Hunter of Mutton", 50),
                        new TitleEntry("Master of the Feast", 100),
                        new TitleEntry("Mammoth of the Wool", 250)
                    });

                // Dragon Slayer Titles
                ((SlayerTitleCore)core).RegisterTitleSystem("Dragon Slayer",
                    new List<Type>()
                    {
                        typeof(Wyvern),
                        typeof(Drake),
                        typeof(Dragon),
                        typeof(WyvernRenowned),
                        typeof(WhiteWyrm),
                        typeof(ShadowWyrm),
                        typeof(AncientWyrm),
                        typeof(StygianDragon),
                        typeof(CrimsonDragon),
                        typeof(GreaterDragon),
                        typeof(SerpentineDragon),
                        typeof(SkeletalDragon)
                    },
                    new List<TitleEntry>()
                    {
                        new TitleEntry("Apprentice Dragonslayer", 50),
                        new TitleEntry("Accomplished Dragon Hunter", 250),
                        new TitleEntry("Master of the Leather Winged", 1000),
                        new TitleEntry("Terror of the Skyborn", 5000)
                    });
            }
        }

        public static void SlayerTitleCore_MaxSlayerTitleAchieved(Mobile from, String titleSystem, String titleAwarded)
        {
            if (!from.IsPlayer())
                return;

            // Award a dragon statuette when the maximum Dragon Slayer title is achieved
            if (titleSystem == "Dragon Slayer")
            {
                MonsterStatuette statue = new MonsterStatuette(MonsterStatuetteType.Dragon);

                if (!from.PlaceInBackpack(statue))
                {
                    from.BankBox.AddItem(statue);

                    from.SendMessage("A reward statue has been placed in your bankbox.");
                }
                else
                {
                    from.SendMessage("A reward statue has been placed in your backpack.");
                }
            }
        }
    }
}

--------------------------------------- Custom Slayer Title System---------------------------------------

This one is almost the same as the previous system. it throws less errors tho


Errors:

Errors:
+ KUSTOM/SlayerTitles/Core/BaseSlayerTitle.cs:
CS1061: Line 70: 'Server.Mobiles.PlayerMobile' does not contain a definition
for 'CollectionTitles' and no extension method 'CollectionTitles' accepting a f
irst argument of type 'Server.Mobiles.PlayerMobile' could be found (are you miss
ing a using directive or an assembly reference?)
CS1061: Line 74: 'Server.Mobiles.PlayerMobile' does not contain a definition
for 'AddCollectionTitle' and no extension method 'AddCollectionTitle' accepting
a first argument of type 'Server.Mobiles.PlayerMobile' could be found (are you
missing a using directive or an assembly reference?)



BaseSlayerTitle.cs

Code:
/*
*
* Slayer Title System
* Beta Version 1.0
* Designed for SVN 663 + ML
*
* Authored by Dougan Ironfist
* Last Updated on 3/5/2011
*
* The purpose of these scripts is to allow shard administrators to create fun kill-based titles that players can earn.
*
*/

using System;
using System.Collections.Generic;
using Server;
using Server.Mobiles;

/// THIS IS A CORE SCRIPT AND SHOULD NOT BE ALTERED ///

namespace Server.SlayerTitles
{
    public abstract class BaseSlayerTitle
    {
        #region Event Handler
        public delegate void KilledByEventHandler(BaseCreature creature, PlayerMobile player);
        public static event KilledByEventHandler KilledByEvent;

        public static void OnKilledByEvent(BaseCreature creature, PlayerMobile player)
        {
            if (KilledByEvent != null)
                KilledByEvent(creature, player);
        }
        #endregion

        public abstract string SlayerTitleName { get; }

        private List<SlayerTitleEntry> m_SlayerTitleEntries = new List<SlayerTitleEntry>();

        public BaseSlayerTitle()
        {
        }

        public void AddSlayerTitleEntry(SlayerTitleEntry entry)
        {
            m_SlayerTitleEntries.Add(entry);
            m_SlayerTitleEntries.Sort(ComapreByNumber);
        }

        public void IncrementSlayerCount(PlayerMobile player)
        {
            SlayerTitleAttachment attachment = SlayerTitleSystem.FindAttachment(player);

            if (attachment != null)
            {
                SlayerSystemTracker tracker = attachment.FindSystemName(SlayerTitleName);

                if (tracker != null)
                {
                    tracker.SlayerCount += 1;

                    string newTitle = GetTitleAwarded(tracker.SlayerCount);

                    if (newTitle != null)
                    {
                        if (tracker.LastTitleAwarded == null || tracker.LastTitleAwarded != newTitle)
                        {
                            if (tracker.LastTitleAwarded != null && tracker.LastTitleAwarded != newTitle)
                            {
                                try { player.CollectionTitles.Remove(tracker.LastTitleAwarded); }
                                catch { }
                            }

                            player.AddCollectionTitle(newTitle);
                            tracker.LastTitleAwarded = newTitle;
                            player.SendSound(0x3D);
                            player.SendMessage(0xC8, String.Format("Your have been awarded the title of '{0}' for {1} kills.", newTitle, tracker.SlayerCount));
                        }
                    }
                }
            }
        }

        private string GetTitleAwarded(int counter)
        {
            string title = null;

            foreach (SlayerTitleEntry entry in m_SlayerTitleEntries)
            {
                int lastCount = 0;

                if (counter >= entry.SlayerCount && counter >= lastCount)
                {
                    lastCount = entry.SlayerCount;
                    title = entry.SlayerTitle;
                }

            }

            return title;
        }

        public static int ComapreByNumber(SlayerTitleEntry x, SlayerTitleEntry y)
        {
            return x.SlayerCount.CompareTo(y.SlayerCount);
        }
    }

    public class SlayerTitleEntry
    {
        private int m_SlayerCount = 0;
        public int SlayerCount { get { return m_SlayerCount; } }

        private string m_SlayerTitle = "";
        public string SlayerTitle { get { return m_SlayerTitle; } }

        public SlayerTitleEntry(int slayerCount, string slayerTitle)
        {
            m_SlayerCount = slayerCount;
            m_SlayerTitle = slayerTitle;
        }
    }
}



 
Last edited:
The version of the system I am using used to be part of the servuo repo but I believe it was removed. It was in scripts/custom systems/ along with a vip and food effects system. I attached the STS and a copy of my PlayerMobile.cs. My playermobile file has been modified but hopefully it will help. I also have a modified copy of the food effects system that works with the era if you are interested.
 

Attachments

  • Slayer Title System.7z
    6.4 KB · Views: 19
  • PlayerMobile.cs
    135.3 KB · Views: 13
Back