|
||
|
|||||||
| Script Support Get support for modifying RunUO Scripts, or writing your own! |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Forum Expert
|
I am working on a new more pvp guild like faction system, so far i have begun by trying to create the stone, it compiles but...
On the restart it says this: Code:
World: Loading...An error was encountered while loading a saved object - Type: Server.Items.SunFactionStone - Serial: 0x40000215 Delete the object? (y/n) here is script: Code:
using System;
using Server;
using Server.Gumps;
using Server.Items;
using Server.Mobiles;
using System.Collections;
using Server.Network;
using Server.Prompts;
using Server.Commands;
using Server.Targeting;
namespace Server.Items
{
public class SunFactionStone : Item
{
private ArrayList members;
private int totalmembers;
private int points;
private string name;
[Constructable]
public SunFactionStone()
: base(0xEDC)
{
Movable = false;
}
public override void GetProperties(ObjectPropertyList list)
{
base.GetProperties(list);
if (members != null)
{
totalmembers = members.Count;
}
else
{
totalmembers = 0;
}
name = "Faction Stone of Sun";
//points = GetFactionPoints("Sun");
list.Add(name);
list.Add("Members: "+totalmembers);
list.Add("Points: "+points);
}
public override void OnDoubleClick(Mobile from)
{
if (members == null)
{
members = new ArrayList();
Console.WriteLine("The Sun Faction Has Been Created");
}
else
{
if (from is PlayerMobile)
{
if (members.Contains(from))
{
from.SendGump(new SunJoinGump());
}
else
{
from.SendGump(new SunJoinGump());
}
}
}
}
public SunFactionStone(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0); // version
if (members != null)
{
writer.WriteMobileList(members);
}
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
if (members != null)
{
members = reader.ReadMobileList();
}
}
}
}
thanks for all help.
__________________
Advertise Your Server On JoinUO! JoinUO @ - joinuo.com
|
|
|
|
|
|
#2 (permalink) |
|
Forum Expert
Join Date: Sep 2002
Location: Houston, Texas
Age: 22
Posts: 3,917
|
Initialize the members array inline so you're guaranteed that it is not null, so when you go to serialize/deserialize, you just remove the null checks and save/load the array - even if it is empty.
|
|
|
|
|
|
#3 (permalink) |
|
Forum Expert
|
jesus, thank you heaps i drove y self a bit crazy trying to figure out what it was but now with your advice i realize that members == null because it had not been loaded yet
![]() thank you!
__________________
Advertise Your Server On JoinUO! JoinUO @ - joinuo.com
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|