> For the complete documentation index, see [llms.txt](https://grp-development.gitbook.io/solid-scripts/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://grp-development.gitbook.io/solid-scripts/resources/solid-multichar/exports-and-events.md).

# Exports and events

Open character selection and react to it from your own resources.

#### Client exports

| Export     | What it does                                                       |
| ---------- | ------------------------------------------------------------------ |
| `Open()`   | Opens character selection, when the player has no character loaded |
| `IsOpen()` | `true` while character selection is open                           |

```lua
if not exports['solid-multichar']:IsOpen() then
    exports['solid-multichar']:Open()
end
```

#### Events that open it

| Event                                 | Side   | What it does                                               |
| ------------------------------------- | ------ | ---------------------------------------------------------- |
| `solid-multichar:client:open`         | Client | Opens character selection                                  |
| `qb-multicharacter:client:chooseChar` | Client | The qb-multicharacter event, so other scripts keep working |
| `qbx_core:client:playerLoggedOut`     | Client | Opens it again after a Qbox logout                         |

From the server:

```lua
TriggerClientEvent('solid-multichar:client:open', source)
```

#### Client events

| Event                                      | Arguments | When                                                                                           |
| ------------------------------------------ | --------- | ---------------------------------------------------------------------------------------------- |
| `solid-multichar:client:characterCreated`  | `info`    | A new character was created                                                                    |
| `solid-multichar:client:characterSelected` | `info`    | An existing character was picked                                                               |
| `solid-multichar:client:spawned`           | `info`    | SOLID Multichar placed the character in the world itself, not when a spawn selector takes over |

`info` holds `citizenid`, `isNew`, `gender` (`'male'` or `'female'`), `name`, `position` (existing characters) and `starter` (new characters, the starter apartments on offer).

```lua
AddEventHandler('solid-multichar:client:characterCreated', function(info)
    print(('welcome %s'):format(info.name))
end)
```

#### Server events

| Event                                     | Arguments               | When                                   |
| ----------------------------------------- | ----------------------- | -------------------------------------- |
| `solid-multichar:server:characterCreated` | `src, citizenid`        | A new character was created            |
| `solid-multichar:server:characterLoaded`  | `src, citizenid, isNew` | A character was logged in              |
| `solid-multichar:server:enteredCity`      | `src, citizenid, isNew` | The player left the lobby for the city |
| `solid-multichar:server:characterDeleted` | `citizenid`             | A character was deleted                |

```lua
AddEventHandler('solid-multichar:server:enteredCity', function(src, citizenid, isNew)
    if isNew then
        print(('%s joined the city for the first time'):format(citizenid))
    end
end)
```

#### State

While a player is choosing, `Player(src).state.solidLobby` is `true` (client: `LocalPlayer.state.solidLobby`), and `invBusy` is `true` so the inventory stays closed.
