08-22-2007, 05:40 PM
Well this is just something i caught just browsing some things runuo related, a simple barber script, nonetheless is dated very recently, I believe you should take care on securing the scripts exchange and do the work secured without letting them escape ...
I can give the location I extracted this and others from to an admin of IN-X, dam they are just sitting there in the open without any kind of security ...
*shakes head*
I can give the location I extracted this and others from to an admin of IN-X, dam they are just sitting there in the open without any kind of security ...
*shakes head*
Code:
//Yes, i will upload this to the forums when im done with it
/***************************************************************************
* Barber.cs
* -------------------
* last edited : July 6, 2007
* web site : www.in-x.org
* author : Makaveli
*
*
***************************************************************************/
/***************************************************************************
*
* Created by the Imagine Nation - Xtreme dev team for "IN-X" and the RunUo
* community. If you miss the old school Sphere 0.51 gameplay, and want to
* try it on the best and most stable emulator, visit us at www.in-x.org.
*
* www.in-x.org
* A full sphere 0.51 replica.
*
***************************************************************************/
using System;
using Server;
using Server.Items;
using System.Collections;
using System.Collections.Generic;
namespace Server.Mobiles
{
public class Barber : BaseVendor
{
#region Initiate vars
private ArrayList m_SBInfos = new ArrayList();
protected override ArrayList SBInfos { get { return m_SBInfos; } }
//Seriously, someone change these MSGS
private string m_ToManyStylesBought = "You will have to settle for one hair and beard style!";
private string m_FemaleBuyingBeard = "I'm sorry, but I only know how to style men faces.";
private string m_HairCutDone = "Ahh! Just look in the mirror!";
private string m_PleaseDismount = "I cannott reach your head if you are sitting on your horse.";
//Chance for hair to be dropped on the ground
private double m_HairDropChance = 0.30;
//The amount of time it will take to cut someones hair
private int m_CutTimeInSeconds = 0;
//If the barber has a specific chair
private Item m_BarbersChair;
//Should we use vendors with the shop menu
private bool m_OldStyleHairStylist = true;
private bool m_AllowFemalesBuyingBeard = false;
private bool m_PlayScissorSound = true;
private bool m_DropResidueHair = true;
private bool m_NeedsToBeDismounted = true;
#endregion
[Constructable]
public Barber() : base("the barber")
{
SetSkill(SkillName.Tailoring, 80.0, 100.0);
SetSkill(SkillName.Magery, 90.0, 110.0);
SetSkill(SkillName.TasteID, 85.0, 100.0);
////To add: a new style vendor that reacts on speech
//if (!m_OldStyleHairStylist)
// this.AI = barberAi;
}
public Barber(Serial serial) : base(serial)
{
}
public override void InitSBInfo()
{
m_SBInfos.Add(new SBHairStylist());
}
public override bool OnBuyItems(Mobile buyer, ArrayList list)
{
if (buyer.Mounted && m_NeedsToBeDismounted)
{
Say(m_ToManyStylesBought);
return false;
}
if (list.Count > 2)
{
Say(m_ToManyStylesBought);
return false;
}
int beard = 0, hair = 0;
List<Item> styles = new List<Item>();;
foreach (BuyItemResponse o in list)
{
Item item = World.FindItem(o.Serial);
if (IsHair(item))
{
styles.Add(item);
hair++;
}
else
{
if (buyer.Female && !m_AllowFemalesBuyingBeard)
{
Say(m_FemaleBuyingBeard);
return false;
}
styles.Add(item);
beard++;
}
if (hair > 1 || beard > 1)
break;
}
if (hair > 1 || beard > 1)
{
Say(m_ToManyStylesBought);
return false;
}
StartCutting(styles, buyer);
return true;
}
private bool IsHair(Item item)
{
Type t = item.GetType();
if (t == typeof(ShortHair) || t == typeof(LongHair) || t == typeof(PonyTail) || t == typeof(Mohawk)
|| t == typeof(PageboyHair) || t == typeof(BunsHair) || t == typeof(Afro)
|| t == typeof(ReceedingHair) || t == typeof(TwoPigTails) || t == typeof(KrisnaHair))
return true;
return false;
}
public void StartCutting(List<Item> styles, Mobile customer)
{
if (m_CutTimeInSeconds == 0)
CutHair(styles, customer);
//else
//new CutTimer().Start();
}
public void CutHair(List<Item> styles, Mobile customer)
{
CutHair(styles, customer, true);
}
public void CutHair(List<Item> styles, Mobile customer, bool dropMoreThanOnce)
{
if (m_PlayScissorSound)
PlayScissorSound(customer);
if (m_DropResidueHair)
{
DropHairResidue(customer, dropMoreThanOnce);
//Lets drop a little hair around the vendor too
DropHairResidue(customer, this.Location, dropMoreThanOnce);
}
foreach (Item style in styles)
{
if (IsHair(style))
customer.HairItemID = style.ItemID;
else
customer.FacialHairItemID = style.ItemID;
style.Delete();
}
Say(m_HairCutDone);
}
public override void OnDoubleClick(Mobile from)
{
if (from.AccessLevel >= AccessLevel.GameMaster)
{
//Display coices: "Customize vendor" "Paperdoll"
base.OnDoubleClick(from);
}
else
base.OnDoubleClick(from);
}
public void PlayScissorSound(Mobile customer)
{
customer.PlaySound(0x248);
}
public void DropHairResidue(Mobile customer)
{
DropHairResidue(customer, customer.Location, false);
}
public void DropHairResidue(Mobile customer, bool moreThanOnce)
{
DropHairResidue(customer, customer.Location, moreThanOnce);
}
public void DropHairResidue(Mobile customer, Point3D loc, bool moreThanOnce)
{
int hue = customer.HairHue;
int xLoc = loc.X;
int yLoc = loc.Y;
for (int x = (xLoc - 1); x <= (xLoc + 1); x++)
{
for (int y = (yLoc - 1); y <= (yLoc + 1); y++)
{
if (Utility.RandomDouble() <= m_HairDropChance)
{
HairResidue hr = new HairResidue(customer);
hr.MoveToWorld(new Point3D(x, y, customer.Location.Z), customer.Map);
if (!moreThanOnce)
break;
}
}
}
}
public bool CheckChair(Mobile customer)
{
//Check if the chair is empty, if its not empty tell the customer that someone is ocupying it.
//If its empty tell the customer to sit down and be still
return false;
}
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();
}
}
}