> 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-shellcreator/exports-and-events.md).

# Exports and events

Load shells in your own scripts, from a simple enter to your own housing.

`key` is a shell id or its name. The manager shows the ready code for every shell under **Use it anywhere** > **Any script**.

#### Server exports

| Export                                   | Returns                | What it does                                                                                                                                                                                                                              |
| ---------------------------------------- | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `EnterShell(source, key, options)`       | `{ ok, error }`        | Sends a player into a shell. `options` = `{ instance, exit, draft, point }`: players with the same `instance` share one copy (default: an own copy), `exit` is a vector4 (default: where the player stands), `point` the spawn point name |
| `ExitShell(source)`                      | `{ ok, error }`        | Takes a player out to their exit                                                                                                                                                                                                          |
| `GetPlayerShell(source)`                 | table or nil           | `{ shell, label, instance, bucket, teleporter, exit }`                                                                                                                                                                                    |
| `GetInstancePlayers(instance)`           | table                  | Player ids in one instance                                                                                                                                                                                                                |
| `GetShell(key, draft)`                   | table                  | The published shell, or the draft with `draft = true`                                                                                                                                                                                     |
| `ListShells()`                           | table                  | `{ id, name, label, live, revision, published, model }` for every shell                                                                                                                                                                   |
| `GetShellModel(key)`                     | string or nil          | The baked model, only when it matches the published version                                                                                                                                                                               |
| `GetShellPicture(key)`                   | table or nil           | `{ url }` or `{ data }`                                                                                                                                                                                                                   |
| `BakeShell(key)`                         | `{ ok, model, error }` | Bakes a shell, needs `solid-shellbake`                                                                                                                                                                                                    |
| `CreateTeleporter(data)`                 | id, error              | A door from your own script, same fields as the **Doors** form                                                                                                                                                                            |
| `RemoveTeleporter(id)`                   | boolean                | Deletes a door                                                                                                                                                                                                                            |
| `GetTeleporters()`                       | table                  | Every door                                                                                                                                                                                                                                |
| `AddHook(name, fn)` / `RemoveHook(name)` | boolean                | Any server [developer edit](https://grp-development.gitbook.io/solid-scripts/resources/solid-shellcreator/developer-edits) from your own resource                                                                                         |

```lua
exports['solid-shellcreator']:EnterShell(source, 'my_villa', {
    instance = 'house:' .. houseId,
    exit = vector4(x, y, z, h),
})

exports['solid-shellcreator']:ExitShell(source)
```

#### Client exports

| Export                             | Returns                        | What it does                                                       |
| ---------------------------------- | ------------------------------ | ------------------------------------------------------------------ |
| `SpawnShell(key, coords, heading)` | handle                         | Builds a shell at `coords`                                         |
| `DespawnShell(handle)`             |                                | Removes it                                                         |
| `GetShellEntities(handle)`         | table                          | Every entity of the shell                                          |
| `GetShellPoint(handle, name)`      | coords                         | World position of `entry`, `exit`, `stash`, `wardrobe` or `garage` |
| `GetShellPoints(handle)`           | table                          | Every point                                                        |
| `CreateQBInterior(key, coords)`    | `{ objects, offsets, handle }` | The shape qb-interior returns, for qb-houses                       |
| `IsInsideShell()`                  | boolean                        | The player is inside a shell                                       |
| `GetCurrentShell()`                | table or nil                   | `{ id, label, instance, handle }`                                  |
| `OpenCreator()`                    |                                | Opens the manager, admins only                                     |
| `IsEditing()`                      | boolean                        | The player is in the editor                                        |

```lua
local handle = exports['solid-shellcreator']:SpawnShell('my_villa', vector3(x, y, z))
local entry = exports['solid-shellcreator']:GetShellPoint(handle, 'entry')
exports['solid-shellcreator']:DespawnShell(handle)
```

#### Client events

| Event                        | Arguments                               | When                         |
| ---------------------------- | --------------------------------------- | ---------------------------- |
| `solid-shellcreator:entered` | shell `{ id, label, instance }`, handle | The player is inside a shell |
| `solid-shellcreator:left`    | shell `{ id, label, instance }`         | The player left it           |
