# Status codes

"Command status code" is additional information you receive with the AdminBot event.

## How to get the code

Events come to your script using `link_message`:

```csharp
link_message( integer sender_num, integer num, string str, key id )
```

The "Command status code" is located in the `str` variable  
(while `num` holds the AdminBot event ID).

## Status Codes

The possible status codes are listed below:

| Possible events | Status code | Description |
|-----------------|-------------|-------------|
| `SB_STATUS_REPLY` | `OK`        | Command succeed, group subscription valid. |
| `SB_COMMAND_FAILED` | `UNKNOWN_COMMAND` | The command you've sent is unknown. Try upgrading to the most newest version. |
| `SB_COMMAND_FAILED` | `SERVICE_UNAVAILABLE` | This SmartBots service is not available for you. Refer to SmartBots Services page for details. |
| `SB_COMMAND_FAILED`, `SB_SETUP_FAILED`, `SB_STATUS_REPLY` | `GROUP_NOTSET` | You are trying to issue the command, but AdminBot does not know it's group yet (use [`SB_SETUP_SETGROUP`](/doc/sb_setup_setgroup-3NAcXE4AdF) command) |
| `SB_COMMAND_FAILED`, `SB_SETUP_FAILED`, `SB_STATUS_REPLY` | `GROUP_NOTEXIST` | The group you are trying to use does not exist. You have to visit [mysmartbots.com](https://mysmartbots.com) and list your group |
| `SB_SETUP_FAILED` | `GROUP_WRONGSECURITY` | You have specified the wrong Security Code while setting the group using [`SB_SETUP_SETGROUP`](/doc/sb_setup_setgroup-3NAcXE4AdF). |
| `SB_COMMAND_FAILED`, `SB_SETUP_FAILED`, `SB_STATUS_REPLY` | `GROUP_NOTPAID` | You've listed your group with SmartBots, but did not paid your subscription yet. |
| `SB_COMMAND_FAILED`, `SB_SETUP_FAILED`, `SB_STATUS_REPLY` | `GROUP_EXPIRED` | Your SmartBots subscription has expired. The expiration date attached. |
| `SB_COMMAND_FAILED`, `SB_SETUP_FAILED`, `SB_STATUS_REPLY` | `GROUP_NOTSETUP` | Editor will process and start your order shortly. Please wait a bit. |
| `SB_COMMAND_FAILED` | `CHAT_LISTEN_FAILED` | Error occured while trying to listen for the group chat |

## Example

The following example shows how to parse group setup error.

In this example we receive the [`SB_SETUP_FAILED`](/doc/sb_setup_failed-LLqcCiwisK) event: this means that AdminBot can't use the group you've asked.  
We should try to understand what's wrong with the group (usually the group name error, or SmartBots subscription has expired).

```csharp
link_message(integer sender, integer cmd, string data, key id) {
  /////////////////// Group setup failed event
  if(cmd == SB_SETUP_FAILED) {
    // We split the string parameter to the lines
    list parts = llParseString2List(data, ["\n"], []);

    // The first line is a status code, and second line is the group expiration date
    string code = llList2String(parts, 0);
    string expires = llList2String(parts, 1);
    
    // Inform user
    llOwnerSay("AdminBot group setup failed:\n" +
      "error code: " + code + "\n" +
      "expired: " + expires);
  }
}
```