> 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/developer-edits.md).

# Developer edits

Open hooks to plug your own logic into character selection.

`client/cl_edits.lua` and `server/sv_edits.lua` stay open. Leave a function as it is and the script works as normal, or write your own code and return a value to take over that part.

{% hint style="info" %}
If your code has an error, it is printed in the console and the script carries on as normal.
{% endhint %}

#### Client (cl\_edits.lua)

`info` holds `citizenid`, `isNew`, `gender`, `name`, `position` and `starter`. `where` is `'lobby'` or `'spawn'`.

| Function                        | When                                                     | Return                                    |
| ------------------------------- | -------------------------------------------------------- | ----------------------------------------- |
| `OnLobbyOpen(data)`             | The lineup opens, `data.characters` and `data.slots`     | Nothing                                   |
| `OnLobbyClose()`                | The lineup closes before the spawn                       | Nothing                                   |
| `OnCharacterSelected(info)`     | An existing character was picked                         | Nothing                                   |
| `OnCharacterCreated(info)`      | A new character was created                              | Nothing                                   |
| `OpenAppearance(info, where)`   | The look should open                                     | `true` when you opened your own creator   |
| `OnAppearanceDone(info, where)` | The look menu closed                                     | Nothing                                   |
| `OnBeforeSpawn(info)`           | Right before the spawn                                   | `true` when you spawn the player yourself |
| `OpenSpawnSelector(info)`       | A spawn selector should open                             | `true` when you opened your own           |
| `OnSpawned(info)`               | SOLID Multichar placed the character in the world itself | Nothing                                   |

* **Your own creator:** the script waits until your menu releases the NUI focus
* **Your own spawn or selector:** the screen is faded out and the player is still hidden and frozen, so your code places them, shows them and fades the screen in

{% code title="client/cl\_edits.lua" %}

```lua
function Edits.OnSpawned(info)
    if info.isNew then
        TriggerEvent('my-tutorial:start')
    end
end
```

{% endcode %}

#### Server (sv\_edits.lua)

| Function                                   | When                                     | Return                                             |
| ------------------------------------------ | ---------------------------------------- | -------------------------------------------------- |
| `OnLobbyOpen(src)`                         | A player opens character selection       | Nothing                                            |
| `Slots(src, slots, characters)`            | The slot count is worked out             | The new slot count, never above `Config.Slots.Max` |
| `CanCreate(src, form)`                     | Before a character is created            | `false, 'message'` blocks it and shows the message |
| `OnCharacterCreated(src, citizenid, form)` | After a character was created            | Nothing                                            |
| `StarterItems(src, citizenid, items)`      | Before the starter items are given       | The item list to give                              |
| `OnCharacterLoaded(src, citizenid, isNew)` | A character was logged in                | Nothing                                            |
| `OnEnterCity(src, citizenid, isNew)`       | The player leaves the lobby for the city | Nothing                                            |
| `CanDelete(src, citizenid)`                | Before a player deletes a character      | `false` blocks it                                  |
| `OnCharacterDeleted(src, citizenid)`       | After a delete, also by `/deletechar`    | Nothing                                            |
| `OnLogout(src, citizenid)`                 | `/logout` sends a player back            | Nothing                                            |

`form` holds `firstname`, `lastname`, `nationality`, `birthdate`, `backstory` and `gender`. `items` is a list of `{ item, amount }`.

{% code title="server/sv\_edits.lua" %}

```lua
function Edits.CanCreate(src, form)
    if form.lastname == 'Admin' then
        return false, 'Pick another last name.'
    end
    return true
end

function Edits.StarterItems(src, citizenid, items)
    items[#items + 1] = { item = 'water_bottle', amount = 2 }
    return items
end
```

{% endcode %}
