Hey guys,
I dont know what Im doing wrong
I added a MySqlReader for the MobSpawns
so I looked in Spawn.cs
and it said
Object reference is not set to an instance of an object,
I don't know how to solve this prob, Any advice?
Im still a learner , so a little help would be very appriciated :)
thanks in advance
I dont know what Im doing wrong
I added a MySqlReader for the MobSpawns
but there are no spawns at all..Quote:
public static void GetSpawns()
{
MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);
cmd.Select("mobspawns");
uint Count = 0;
MySqlReader r = new MySqlReader(cmd);
while (r.Read())
{
MobSpawn S = new MobSpawn(r.ReadUInt16("Amount"), Dictionary.BaseMobs[r.ReadUInt16("SpawnMob")], r.ReadUInt16("X"), r.ReadUInt16("Y"), r.ReadUInt16("Spread"), r.ReadUInt16("Map"));
Count += (uint)S.Members.Count;
}
Console.WriteLine(Program.Title + " Spawning " + Count + " monsters into the world");
}
so I looked in Spawn.cs
I added a catch (Exception E) { Console.WriteLine(E.ToString()); } to gimme the errors,Quote:
public class MobSpawn
{
public Mob MobCoords(Mob M)
{
M.X = (ushort)Program.Rand.Next(X - Spread, Y + Spread);
M.Y = (ushort)Program.Rand.Next(Y - Spread, Y + Spread);
return M;
}
public MobSpawn(uint Amount, BaseMob Type, ushort BindX, ushort BindY,ushort Dist, ushort BindMap)
{
try
{
MobType = Type;
TotalSpawn = Amount;
X = BindX;
Y = BindY;
Spread = Dist;
if(!Dictionary.Maps.ContainsKey(BindMap))
{
Map = new Map(Enum.PkType.None);
Dictionary.Maps.ThreadSafeAdd(BindMap, Map);
}
for (uint I = 0; I < Amount; I++)
{
Mob M = new Mob();
M.Map = BindMap;
M = MobCoords(M);
int Tries = 10;
while (Tries > 0 && !Calculations.FreeCoord(M.X, M.Y, M.Map, M.Instance))
{ M = MobCoords(M); Tries--; }
M.UID = this.Map.MobCounter + I;
}
Map.MobCounter += Amount;
}
catch (Exception E) { Console.WriteLine(E.ToString()); }
}
public Dictionary<uint, Mob> Members = new Dictionary<uint, Mob>();
BaseMob MobType;
public uint TotalSpawn;
public uint TotalDead
{
get
{
uint Count = 0;
foreach (Mob M in Members.Values)
if (!M.Alive)
Count++;
return Count;
}
}
public ushort X, Y, Spread;
public Map Map;
}
}
and it said
Object reference is not set to an instance of an object,
I don't know how to solve this prob, Any advice?
Im still a learner , so a little help would be very appriciated :)
thanks in advance