I was trying to load an NPC from a MySQL database, but I get NullReference in this code:
Any idea why is it Null? Impulse 5165.
PHP Code:
private void LoadNpcs()
{
Database.MySqlCommand command = new Conquer_Online_Server.Database.MySqlCommand(Conquer_Online_Server.Database.MySqlCommandType.SELECT);
command.Select("npcs").Where("mapid", ID);
Database.MySqlReader reader = new Conquer_Online_Server.Database.MySqlReader(command);
while (reader.Read())
{
INpc npc = new Network.GamePackets.NpcSpawn();
npc.UID = reader.ReadUInt32("id");
npc.Type = reader.ReadUInt16("lookface");
npc.Kind = (Enums.NpcKind)reader.ReadByte("type");
npc.X = reader.ReadUInt16("cellx"); ;
npc.Y = reader.ReadUInt16("celly");
npc.MapID = ID;
AddNpc(npc);
}
reader.Close();
}