Пример #1
0
 /// <summary>
 /// Add a user to the admin list.
 /// It will not add if the name is already on the list.
 /// </summary>
 /// <param name="user">The user's username.</param>
 public void AddAdmin(string user)
 {
     if (!AdminList.Contains(user))
     {
         AdminList.Add(user);
     }
 }
 public void ReadAdmins()
 {
     try
     {
         // Setup the admins array
         Admins = new AdminList();
         OleDbDataReader drAdmins = DB.GetData("select * from haloce_server_admins");
         if (drAdmins.HasRows)
         {
             while (drAdmins.Read())
             {
                 string       name    = drAdmins.GetString(drAdmins.GetOrdinal("name"));
                 string       keyhash = drAdmins.GetString(drAdmins.GetOrdinal("key_hash"));
                 int          id      = drAdmins.GetInt32(drAdmins.GetOrdinal("id"));
                 PlayerRecord pr      = new PlayerRecord();
                 pr.id = id; pr.keyhash = keyhash; pr.name = name;
                 if (!Admins.Contains(keyhash))
                 {
                     Admins.Add(keyhash, pr);
                 }
             }
         }
         drAdmins.Close();
     }
     catch
     {
         Admins = new AdminList();
         Trace.WriteLine("ERROR: Failed to load admins!");
     }
 }
Пример #3
0
 /// <summary>
 /// Is the user on the admin list?
 /// </summary>
 /// <param name="user">The user's username.</param>
 /// <returns>True if the user is on the admin list.</returns>
 public bool isAdmin(string user)
 {
     return(AdminList.Contains(user));
 }