> 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/classes/workaround.md).

# Workaround

Allows users to fix external bugs and conflicts

**Code:** [*guthscp.workaround.meta*](https://github.com/Guthen/guthscpbase/blob/master/lua/guthscp/keter/workaround/meta.lua)

**Realm:** <img src="https://975014697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZXSL4k4DnVhJ9UWciTTm%2Fuploads%2Fw23hGHIIzuzjREdszv2f%2Frealm%20shared.png?alt=media" alt="" data-size="line"> Shared

***

## Description

{% hint style="info" %}
For more information about **creating a workaround**, read this [tutorial](/guthscp/developpers/creating-a-workaround.md).
{% endhint %}

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

***

## Properties

**`string`** `name`

&#x20;   Name of the workaround, used in the menu

***

**`guthscp.REALMS`** `realm`

&#x20;   Realm of the workaround, this define in which realm (server, client or both) the workaround should behave (allowing to call `WORKAROUND:on_enabled` and `WORKAROUND:on_disabled` accordingly). For example, if you want to fix a server-side hook, you should define the workaround on the server realm.

***

**`(internal)`** **`string`** `id`

&#x20;   Identifier of the workaround, used for registering in the system.

{% hint style="warning" %}
This variable should NOT be edited manually, this is automatically set to the identifier you gave in the `guthscp.workaround.register` call.
{% endhint %}

***

**`(internal)`** **`bool`** `_is_enabled`

&#x20;   Is the workaround currently enabled? Set by `WORKAROUND:set_enabled`.

***

**`(internal)`** **`bool`** `_is_active`

&#x20;   Is the workaround able to be enabled? Set to the result of `WORKAROUND:init` method when called by the workaround system.

***

## Methods

<img src="https://975014697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZXSL4k4DnVhJ9UWciTTm%2Fuploads%2Fw23hGHIIzuzjREdszv2f%2Frealm%20shared.png?alt=media" alt="" data-size="line"> `(overridable)` **`bool`** `init()`

&#x20;   Returns whenever the workaround should be active. This can informs that the workaround can't function due to a lack of a certain hook or dependency.

&#x20;   Called either during the `GM:InitPostEntity` hook or during hot reload.

***

<img src="https://975014697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZXSL4k4DnVhJ9UWciTTm%2Fuploads%2Fw23hGHIIzuzjREdszv2f%2Frealm%20shared.png?alt=media" alt="" data-size="line"> `(overridable)` **`void`** `on_enabled()`

&#x20;   Called when the workaround is enabled on the targeted realm.

***

<img src="https://975014697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZXSL4k4DnVhJ9UWciTTm%2Fuploads%2Fw23hGHIIzuzjREdszv2f%2Frealm%20shared.png?alt=media" alt="" data-size="line"> `(overridable)` **`void`** `on_disabled()`

&#x20;   Called when the workaround is disabled on the targeted realm.

***

<img src="https://975014697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZXSL4k4DnVhJ9UWciTTm%2Fuploads%2Fw23hGHIIzuzjREdszv2f%2Frealm%20shared.png?alt=media" alt="" data-size="line"> **`bool`** `register_hook( any slot, string name, any id )`

&#x20;   Registers the current callback of the specified hook at given slot. Returns whether the hook has been found.

***

<img src="https://975014697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZXSL4k4DnVhJ9UWciTTm%2Fuploads%2Fw23hGHIIzuzjREdszv2f%2Frealm%20shared.png?alt=media" alt="" data-size="line"> **`bool`** `find_hook( any slot, string name, function<bool>( string, function ) condition )`

&#x20;   Finds a hook matching the callback condition and register it at given slot. Useful for finding hooks with randomized identifiers. Returns whether the hook has been found.

***

<img src="https://975014697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZXSL4k4DnVhJ9UWciTTm%2Fuploads%2Fw23hGHIIzuzjREdszv2f%2Frealm%20shared.png?alt=media" alt="" data-size="line"> **`bool`** `override_hook( any slot, function callback )`

&#x20;   Overrides the game hook's callback from `slot`. Doesn't modify the internal registery.

***

<img src="https://975014697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZXSL4k4DnVhJ9UWciTTm%2Fuploads%2Fw23hGHIIzuzjREdszv2f%2Frealm%20shared.png?alt=media" alt="" data-size="line"> **`bool`** `remove_hook( any slot )`

&#x20;   Deletes the game hook's callback from `slot`. Doesn't modify the internal registery.

***

<img src="https://975014697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZXSL4k4DnVhJ9UWciTTm%2Fuploads%2Fw23hGHIIzuzjREdszv2f%2Frealm%20shared.png?alt=media" alt="" data-size="line"> **`bool`** `restore_hook( any slot )`

&#x20;   Restores the game hook's callback at given slot to registered callback. Doesn't modify the internal registery.

***

<img src="https://975014697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZXSL4k4DnVhJ9UWciTTm%2Fuploads%2Fw23hGHIIzuzjREdszv2f%2Frealm%20shared.png?alt=media" alt="" data-size="line"> **`bool`** `is_enabled()` `const`

&#x20;   Returns whenever the workaround is enabled.

***

<img src="https://975014697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZXSL4k4DnVhJ9UWciTTm%2Fuploads%2Fw23hGHIIzuzjREdszv2f%2Frealm%20shared.png?alt=media" alt="" data-size="line"> **`bool`** `is_active()` `const`

&#x20;   Returns whenever the workaround is active.

***

<img src="https://975014697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZXSL4k4DnVhJ9UWciTTm%2Fuploads%2Fw23hGHIIzuzjREdszv2f%2Frealm%20shared.png?alt=media" alt="" data-size="line"> **`void`** `set_enabled( bool is_enabled )`

&#x20;   Changes current state. Do nothing if in-active or if `is_enabled` matchs workaround's state. Calls `WORKAROUND:on_enabled` or `WORKAROUND:on_disabled` (depending on `is_enabled`) if the call's realm is matching targeted realm. Do not synchronizes or saves by itself.

***

<img src="https://975014697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZXSL4k4DnVhJ9UWciTTm%2Fuploads%2Fw23hGHIIzuzjREdszv2f%2Frealm%20shared.png?alt=media" alt="" data-size="line"> **`void`** `sync( Player ply = nil )`

&#x20;   Synchronizes the workaround either to server (client-side), to `ply` or to all clients.

***
