Gates don't work after update.
After I updated to Beta 18 and changed MyMobile to PlayerMobile, my gates don't work at all. I get no errors, just nothing happens when I walk into them :? Please help
. Here are the 3 scripts.
ElfGate.cs
[code:1]
namespace Server.Scripts
{
public class ElfGate : Item
{
private Point3D newLocation;
[Constructable]
public ElfGate() : base(0x0F6D)
{
Name = "An Elf Race Gate";
this.Movable = false;
}
public ElfGate( Serial serial ) : base( serial )
{
}
public override bool OnMoveOver(Mobile from)
{
Mobile somemobile = from;
PlayerMobile someperso = somemobile as PlayerMobile;
if ( someperso != null )
{
someperso.Hue = 0x224; //gives the player their race's skin colour if different from human's
someperso.InitStats(50, 120, 90); //here are the stats for the race str, dex, intell
someperso.PgRace = RaceType.Elf; //gives the character stats for the gate
Item hair = new Item( Utility.RandomList( 0x203C, 0x203D ) );
hair.Hue = Utility.RandomNondyedHue();
hair.Layer = Layer.Hair;
hair.Movable = false;
someperso.AddItem( hair );
someperso.SendMessage("You are now an Elf"
;
switch ( Utility.Random( 2 ) )
{
case 0:
from.Location = new Point3D( 1432, 1695, 0 ); //in front of britain bank
break;
case 1:
from.Location = new Point3D( 1434, 1688, 20 ); //on top of britain bank
break;
}
}
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();
}
}
}
[/code:1]
MyOwnMobile.cs
[code:1]
using System;
using Server;
using Server.Items;
using System.Collections;
using Server.Mobiles;
using Server.Network;
namespace Server.Scripts
{
public enum RaceType
{
None, Human, Elf, Orc //all the races available
}
public class PlayerMobile : Mobile
{
private RaceType Elf; //Create a private RaceType variable it will countain the race of you're character
public PlayerMobile()
{
PgRace = RaceType.Elf; //don't forget to init the private variable
}
public PlayerMobile( Serial serial ) : base( serial )
{
}
[CommandProperty( AccessLevel.GameMaster )]
public RaceType PgRace
{
get {return Elf;}
set {Elf = value;}
}
public override void OnSingleClick( Mobile from )
{
from.LocalOverheadMessage( MessageType.Regular, 0, false, String.Format( "{0} the {1}", Name, PgRace ) );
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 );
writer.Write((int) Elf ); // don't forget to save you're characters race
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
switch ( version )
{
case 0:
{
Elf = (RaceType)reader.ReadInt(); //neither to load it
break;
}
}
}
}
}
[/code:1]
CharacterFunction.cs
[code:1]
using System;
using Server;
using Server.Network;
namespace Server.Scripts
{
public class RaceFunction
{
public static void Initialize()
{
Server.Commands.Register( "MyCommand", AccessLevel.Player, new CommandEventHandler( MyCommand_OnCommand ) ); //register the function and is access
}
private static void MyCommand_OnCommand( CommandEventArgs e )
{
Mobile somemobile = e.Mobile;
PlayerMobile from = somemobile as PlayerMobile;
if ( from != null )
{
if (from.PgRace == RaceType.Human) //check you're character race
{
//Put you're action code here
}else{
from.SendMessage("You can not use it."
;
}
}
}
}
}
[/code:1]