public static Pet CreatePet(SqlDatabaseClient MySqlClient, uint UserId, int Type, string Name, int Race) { MySqlClient.SetParameter("userid", UserId); MySqlClient.SetParameter("type", Type); MySqlClient.SetParameter("name", Name); MySqlClient.SetParameter("race", Race); MySqlClient.SetParameter("timestamp", UnixTimestamp.GetCurrent()); string RawId = MySqlClient.ExecuteScalar("INSERT INTO pets (user_id,type,name,race,timestamp) VALUES (@userid,@type,@name,@race,@timestamp); SELECT LAST_INSERT_ID();").ToString(); uint Id = 0; uint.TryParse(RawId, out Id); if (Id == 0) { return null; } return new Pet(Id, Name, Type, Race, UserId, 0, new Vector3(0, 0, 0), UnixTimestamp.GetCurrent(), 0, 120, 100, 0); }
public static Item CreateItem(SqlDatabaseClient MySqlClient, uint DefinitionId, uint UserId, string Flags, string FlagsDisplay, double ExpireTimestamp, bool Untradable = false) { MySqlClient.SetParameter("definitionid", DefinitionId); MySqlClient.SetParameter("userid", UserId); MySqlClient.SetParameter("flags", Flags); MySqlClient.SetParameter("flagsd", FlagsDisplay); MySqlClient.SetParameter("untradable", Untradable ? "1" : "0"); MySqlClient.SetParameter("expiretimestamp", ExpireTimestamp); string RawId = MySqlClient.ExecuteScalar("INSERT INTO items (definition_id,user_id,flags,flags_display,untradable,expire_timestamp) VALUES (@definitionid,@userid,@flags,@flagsd,@untradable,@expiretimestamp); SELECT LAST_INSERT_ID();").ToString(); uint Id = 0; uint.TryParse(RawId, out Id); if (Id == 0) { return null; } return new Item(Id, DefinitionId, UserId, 0, new Vector3(), string.Empty, 0, Flags, Flags, Untradable, 0, 0, ExpireTimestamp); }
public static void FillCache(SqlDatabaseClient MySqlClient, uint LinkedItemId) { if (mCache.ContainsKey(LinkedItemId)) { mCache.Remove(LinkedItemId); } uint IdValue = 0; MySqlClient.SetParameter("id", LinkedItemId); object Result = MySqlClient.ExecuteScalar("SELECT room_id FROM items WHERE id = @id LIMIT 1"); if (Result != null) { IdValue = (uint)Result; } if (IdValue > 0) { mCache.Add(LinkedItemId, IdValue); } }