function LivelyChatSupport_agent($id = false)
{
    global $wpdb;
    $agent = false;
    $livelychatsupport = LivelyChatSupport_details();
    if ($id) {
        $agent = (object) array("id" => $id, "name" => get_user_meta($id, "livelychatsupport-name", true), "mobile" => get_user_meta($id, "livelychatsupport-mobile", true), "avatar" => get_user_meta($id, "livelychatsupport-avatar", true), "active" => get_user_meta($id, "livelychatsupport-active", true));
    }
    if (!$agent) {
        $agents = LivelyChatSupport_agents();
        if ($livelychatsupport["online"] == "hours") {
            $hour = LivelyChatSupport_hour();
            if ($hour != null) {
                if ($hour->responder_id == 0) {
                    $agent = $agents[rand(0, sizeof($agents) - 1)];
                } else {
                    $agent = LivelyChatSupport_agent($hour->responder_id);
                }
            }
        }
        if (!$agent) {
            if (!empty($agents)) {
                $agent = $agents[rand(0, sizeof($agents) - 1)];
            }
        }
    }
    return $agent;
}
<?php

global $wpdb;
$agents_table = $wpdb->prefix . "livelychatsupport_agents";
$agents = LivelyChatSupport_agents(true);
?>

<h2><?php 
_e("Customer Support Agents", "lively-chat-support");
?>
</h2>

<div class="updated">
  <?php 
if (strpos($livelychatsupport["addons"], "sms") !== false) {
    ?>
    <p><?php 
    _e("<strong>Phone Number</strong> - should include country code (eg. 19998887777). ", "lively-chat-support");
    ?>
</p>
  <?php 
}
?>

  <p><?php 
echo sprintf(__("<strong>Email Address</strong> - Can be changed in the <a href=\"%s\">WP Users</a> section.", "lively-chat-support"), admin_url("users.php"));
?>
</p>
  <p><?php 
_e("<strong>Display Name</strong> - Shows in the \"You're Chatting With\" section of the chat box.", "lively-chat-support");
?>
<?php

global $wpdb;
$hours_table = $wpdb->prefix . "livelychatsupport_hours";
$hours = $wpdb->get_results("SELECT * FROM {$hours_table}");
$agents = LivelyChatSupport_agents();
?>

<form action="admin.php?page=livelychatsupport&tab=schedule" method="post">
  
  <h2><?php 
_e("Schedule & Office Hours", "lively-chat-support");
?>
</h2>
  
  <div class="field">
    <select name="online" id="online">
      <option <?php 
if ($livelychatsupport["online"] == "hours") {
    echo "selected='selected'";
}
?>
value="hours"><?php 
_e("Online According to Office Hours", "lively-chat-support");
?>
</option>
      <option <?php 
if ($livelychatsupport["online"] == "online") {
    echo "selected='selected'";
}
?>