> For the complete documentation index, see [llms.txt](https://guthen.gitbook.io/guthscp/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://guthen.gitbook.io/guthscp/developpers/creating-a-workaround.md).

# Creating a workaround

{% hint style="info" %}
This tutorial assumes you are familiar with coding in Garry's Mod and creating addons.
{% endhint %}

***

## What is a workaround?

A workaround is a system which can be toggled on & off (in the `Base`'s page menu). Its purpose is mainly to allow users to choose to fix issues & conflicts with external addons. A workaround can be targeted for a specific realm (server, client or both) in order to fix all eventual issues.

All workarounds (except during hot reload) are initialized during the `GM:InitPostEntity` hook, assuming that during this time, all fixable hooks should be defined.

#### Examples

See these two examples from the base:

* [`cptbase_shouldcollide.lua`](https://github.com/Guthen/guthscpbase/blob/master/lua/guthscp/modules/base/workarounds/cptbase_shouldcollide.lua)
* [`playable_piano_playeruse.lua`](https://github.com/Guthen/guthscpbase/blob/master/lua/guthscp/modules/base/workarounds/playable_piano_playeruse.lua)

***

## Setting up the file structure

There are multiple ways of setting up the file structure to define the workarounds:

* creating the Lua file in `lua/autorun/`
* creating the Lua file in `lua/guthscp/base/workarounds/`
* **creating the Lua file in a folder of your module and add it to your** `requires` *(recommended)*

{% hint style="warning" %}
The workaround must be defined as shared (both for server & client)
{% endhint %}

***

## Defining the workaround

Open your script and start by creating a `WORKAROUND` local table which you register as follow:

```lua
local WORKAROUND = {}

guthscp.workaround.register( "my_workaround_id", WORKAROUND )
```

The `WORKAROUND` table is what defines your workaround, it will contains properties like the name, the targeted realm & methods that you will define. You also have to **specify the identifier of your workaround** yourself in the registering function call: **choose a unique & recognizable name** so it doesn't conflict with any other workarounds.

Now, you should fill the required properties:

```lua
local WORKAROUND = {
    name = "My Server-Side Workaround",
    realm = guthscp.REALMS.SERVER,
}
```

This is the bare minimum to make a workaround register in the system and to see it in the `guthscpbase` menu. Of course, edit them as you'll like.

{% hint style="info" %}
For more information about the **workaround** class, read this [page](/guthscp/classes/workaround.md).
{% endhint %}

***

## Adding logic

{% hint style="warning" %}
TODO
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://guthen.gitbook.io/guthscp/developpers/creating-a-workaround.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
