FiftyTifty
Member
- ServUO Version
- Publish 57
- Ultima Expansion
- High Seas
For my first script, I decided to do something that I thought would be simple. Add a context menu to hireable NPCs (peasants, fighters, etc), that makes them say a line of dialogue.
No errors, scripts.dll compiles fine, but an additional entry doesn't appear. Here's what I've done:
1. Created a new .cs file called PeasantOwnership.cs, located in Scripts\FyTy
2. Use the Server.Mobiles namespace, create a class derived from BaseHire
3. Copy and edit a derived ContextMenuEntry class called PeasantOwnershipEntry
4. Copy the GetContextMenuEntries function, edit to use the new PeasantOwnershipEntry class
5. Add an OnClick event that makes the NPC say a line of dialogue
Unfortunately, this doesn't do anything. There's not a second Hire entry in the hireable NPC's context menu, and they don't say the dialogue line. Any idea what I'm doing wrong here?
And what does base(6120, 3) mean? I know that 3 is the distance between the player and the mobile, but I can't find any info on what the first number is.
Edit: For the second question, Voxpire said in the discord that there's actually an offset for CLI numbers. 6120 is actually 3006120, due to the way the client works.
No errors, scripts.dll compiles fine, but an additional entry doesn't appear. Here's what I've done:
1. Created a new .cs file called PeasantOwnership.cs, located in Scripts\FyTy
2. Use the Server.Mobiles namespace, create a class derived from BaseHire
3. Copy and edit a derived ContextMenuEntry class called PeasantOwnershipEntry
4. Copy the GetContextMenuEntries function, edit to use the new PeasantOwnershipEntry class
5. Add an OnClick event that makes the NPC say a line of dialogue
C#:
using Server.ContextMenus;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Server.Mobiles
{
public class PeasantOwnership : BaseHire
{
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> listContextMenuEntries)
{
if (Deleted)
return;
if (!Controlled)
{
if (CanPaperdollBeOpenedBy(from))
listContextMenuEntries.Add(new PaperdollEntry(this));
listContextMenuEntries.Add(new PeasantOwnershipEntry(from, this));
}
else
{
base.GetContextMenuEntries(from, listContextMenuEntries);
}
}
public class PeasantOwnershipEntry : ContextMenuEntry
{
private readonly Mobile m_Peasant;
private readonly PeasantOwnership m_Own;
public PeasantOwnershipEntry(Mobile from, PeasantOwnership own)
: base(6120, 3)
{
m_Own = own;
m_Peasant = from;
}
public override void OnClick()
{
//3006103 = "Buy"
m_Peasant.Say(3006103);
}
}
}
}
Unfortunately, this doesn't do anything. There's not a second Hire entry in the hireable NPC's context menu, and they don't say the dialogue line. Any idea what I'm doing wrong here?
And what does base(6120, 3) mean? I know that 3 is the distance between the player and the mobile, but I can't find any info on what the first number is.
Edit: For the second question, Voxpire said in the discord that there's actually an offset for CLI numbers. 6120 is actually 3006120, due to the way the client works.