thor86
Member
Hello I wanted to make a script where if your hair grows after so many hours like back on a old sphere shard like if you had bald hair it grow into short hair then longer then really long & same with beard, I found a Hair Brush script off runuo by Liacs I tried to add a timer & change some things around to test & if i got it growing hair I was gonna customize it the way I wanted the hair to grow, I probably did it all wrong & there's probably a easier way of doing it I just dont know how to,
I got it to compile but once I log in the shard crashes if anyone knows a easier way to do this can you point me in right direction or tell me if this script will even work the way I have it set up & what I did wrong for it to crash shard on player login?
here is the crash log
& here is the code I was tinkering with
I tried it with & without the if (m != null) i probably did that wrong & put it in wrong spot too , Thank's
I got it to compile but once I log in the shard crashes if anyone knows a easier way to do this can you point me in right direction or tell me if this script will even work the way I have it set up & what I did wrong for it to crash shard on player login?
here is the crash log
Code:
Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
at Server.Misc.HairGrowthTimer.HairGrowth(Mobile m) in c:\Users\Desktop\backups\ServUO-TEST\Scripts\Custom Systems\HairGrowth.cs:line 49
at Server.Misc.HairGrowthTimer.HairGrowth() in c:\Users\Desktop\backups\ServUO-TEST\Scripts\Custom Systems\HairGrowth.cs:line 35
at Server.Misc.HairGrowthTimer.OnTick() in c:\Users\Desktop\backups\ServUO-TEST\Scripts\Custom Systems\HairGrowth.cs:line 28
at Server.Timer.Slice() in c:\Users\Desktop\test\ServUO-master\Server\Timer.cs:line 386
at Server.Core.Main(String[] args) in c:\Users\Desktop\test\ServUO-master\Server\Main.cs:line 621
Code:
using System;
using Server;
using System.Collections;
using Server.Targeting;
using Server.Mobiles;
using Server.Items;
using Server.Network;
namespace Server.Misc
{
public class HairGrowthTimer : Timer
{
public static void Initialize()
{
new HairGrowthTimer().Start();
}
public HairGrowthTimer()
: base(TimeSpan.FromSeconds(60), TimeSpan.FromSeconds(60))
{
Priority = TimerPriority.OneSecond;
}
protected override void OnTick()
{
HairGrowth();
}
public static void HairGrowth()
{
foreach (NetState state in NetState.Instances)
{
HairGrowth(state.Mobile);
}
}
public static void HairGrowth(Mobile m)
{
if (m != null)
if (m.HairItemID == 0x2044) // Mohawk
{
// m.SendMessage("You take your hair together.");
m.HairItemID = 0x204A; //Krisna
return;
}
if (m.HairItemID == 0x204A) // Krisna
{
// m.SendMessage("You open your hair.");
m.HairItemID = 0x2044; // Mohawk
return;
}
//short
if (m.HairItemID == 0x2045) // Pageboy
{
if (!m.Female)
{
// m.SendMessage("You curl your hair.");
m.HairItemID = 0x2047; // Afro
return;
}
else
{
// m.SendMessage("You brush your hair.");
m.HairItemID = 0x203B; // Short
return;
}
}
if (m.HairItemID == 0x203B && m.Female) // Short
{
// m.SendMessage("You curl your hair.");
m.HairItemID = 0x2047; // Afro
return;
}
if (m.HairItemID == 0x2047) // Afro
{
// m.SendMessage("You straighten your hair.");
m.HairItemID = 0x2FBF; //MidLong
return;
}
if (m.HairItemID == 0x2FBF) // MidLong
{
// m.SendMessage("You put a feather in your hair.");
m.HairItemID = 0x2FC0; // Feather
return;
}
if (m.HairItemID == 0x2FC0) // Feather
{
// m.SendMessage("You brush your hair and take the feather out.");
m.HairItemID = 0x2FC2; // Mullet
return;
}
if (m.HairItemID == 0x2FC2) // Mullet
{
// m.SendMessage("You make a knot.");
m.HairItemID = 0x2FCE; // ElfKnot
return;
}
if (m.HairItemID == 0x2FCE) // ElfKnot
{
// m.SendMessage("You make a bun.");
m.HairItemID = 0x2FD0; // BigBun
return;
}
if (m.HairItemID == 0x2FD0) // BigBun
{
// m.SendMessage("You brush your hair.");
m.HairItemID = 0x2045; // Pageboy
return;
}
//long
if (m.HairItemID == 0x2046) // Buns
{
// m.SendMessage("You open your hair.");
m.HairItemID = 0x203C; // Long
return;
}
if (m.HairItemID == 0x203C) // Long
{
// m.SendMessage("You brush your hair.");
m.HairItemID = 0x2FCD; // LongElf
return;
}
if (m.HairItemID == 0x2FCD) // LongElf
{
// m.SendMessage("You take your hair together in a ponytail.");
m.HairItemID = 0x203D; // Ponytail
return;
}
if (m.HairItemID == 0x203D) // Ponytail
{
// m.SendMessage("You braid your hair.");
m.HairItemID = 0x2FCF; // BraidElf
return;
}
if (m.HairItemID == 0x2FCF) // BraidElf
{
if (!m.Female)
{
// m.SendMessage("You make two pigtails.");
m.HairItemID = 0x2049; // Two Pigtails
return;
}
else
{
// m.SendMessage("You put a flower in your hair.");
m.HairItemID = 0x2FCC; // Flower
return;
}
}
if (m.HairItemID == 0x2FCC) // Flower
{
// m.SendMessage("You make two pigtails.");
m.HairItemID = 0x2049; // Two Pigtails
return;
}
if (m.HairItemID == 0x2049) // Two Pigtails
{
if (!m.Female)
{
// m.SendMessage("You open your hair.");
m.HairItemID = 0x203C; // Long
return;
}
else
{
// m.SendMessage("You roll your pigtails up in buns.");
m.HairItemID = 0x2046; // Buns
return;
}
}
//short / receeding
if (m.HairItemID == 0x2048) // receeding
{
// m.SendMessage("You brush your hair.");
m.HairItemID = 0x2FC1; // ShortElven
return;
}
if (m.HairItemID == 0x2FC1) // ShortElven
{
// m.SendMessage("You brush your hair.");
m.HairItemID = 0x2FD1; // Spiked
return;
}
if (m.HairItemID == 0x2FD1) // Spiked
{
if (!m.Female)
{
// m.SendMessage("You brush your hair.");
m.HairItemID = 0x203B; // Short
return;
}
else
{
// m.SendMessage("You brush your hair.");
m.HairItemID = 0x2048; // receeding
return;
}
}
if (!m.Female && m.HairItemID == 0x203B) // Short
{
// m.SendMessage("You brush your hair.");
m.HairItemID = 0x2048; // receeding
return;
}
else
{
m.SendMessage("Your hair can't grow.");
return;
}
}
}
}
I tried it with & without the if (m != null) i probably did that wrong & put it in wrong spot too , Thank's