Ejemplo n.º 1
0
 public DialogScript(DB_Dialog data, MapServer server)
 {
     _id      = data.ID;
     _server  = server;
     _npcs    = new WO_NPC[2];
     _entries = data.Entries;
 }
Ejemplo n.º 2
0
        public static bool SelectAllDialogs(out Dictionary <int, DB_Dialog> data)
        {
            var locked = false;

            data = new Dictionary <int, DB_Dialog>();
            if (!IsConnected)
            {
                return(false);
            }
            try
            {
                using (MySqlCommand _cmd = _connection.CreateCommand())
                {
                    _cmd.CommandText = $"SELECT * FROM {tb_08};";
                    Monitor.Enter(_connection, ref locked);
                    using (MySqlDataReader _result = _cmd.ExecuteReader())
                    {
                        ushort id; short state; DB_Dialog script;
                        if (_result.HasRows)
                        {
                            while (_result.Read())
                            {
                                id    = _result.GetUInt16(0);
                                state = _result.GetInt16(1);
                                if (!data.TryGetValue(id, out script))
                                {
                                    data[id] = script = new DB_Dialog(id);
                                }
                                script.Entries.Add(state, new DialogEntry(_result.GetByte(2), _result.GetByte(3), _result.GetInt32(4), _result.GetByte(5),
                                                                          _result.GetInt32(6), _result.GetInt32(7), _result.GetByte(8), _result.GetInt32(9), _result.GetInt32(10)));
                            }
                        }
                    }
                }
                return(true);
            }
            catch { return(false); }
            finally { if (locked)
                      {
                          Monitor.Exit(_connection);
                      }
            }
        }
Ejemplo n.º 3
0
 public static async Task <Dictionary <int, DB_Dialog> > SelectAllDialogsAsync()
 {
     try
     {
         using (var connection = await GetConnectionAsync())
         {
             using (var command = connection.CreateCommand())
             {
                 command.CommandText = $"SELECT * FROM {tb_08};";
                 using (var reader = await command.ExecuteReaderAsyncEx())
                 {
                     var result = new Dictionary <int, DB_Dialog>();
                     if (reader.HasRows)
                     {
                         while (await reader.ReadAsyncEx())
                         {
                             var id    = reader.GetUInt16(0);
                             var state = reader.GetInt16(1);
                             if (!result.TryGetValue(id, out var entry))
                             {
                                 result[id] = entry = new DB_Dialog(id);
                             }
                             entry.Entries.Add(state, new DialogEntry(reader.GetByte(2), reader.GetByte(3), reader.GetInt32(4), reader.GetByte(5),
                                                                      reader.GetInt32(6), reader.GetInt32(7), reader.GetByte(8), reader.GetInt32(9), reader.GetInt32(10)));
                         }
                     }
                     return(result);
                 }
             }
         }
     }
     catch (Exception exp)
     {
         ServerLogger.LogException(exp);
         return(null);
     }
 }
Ejemplo n.º 4
0
 public static bool Select(int id, out DB_Dialog entry)
 {
     return(m_dialogs.TryGetValue(id, out entry));
 }