# Server-Side Exports

## Ban Export

```lua
exports["anticheat-name"]:fg_BanPlayer(
    playerSource --[[ integer ]],
    violation --[[ string ]],
    send_to_logs --[[ boolean ]]
)
```

`Parameters:`

{% code lineNumbers="true" %}

```
playerSource: The player handle
violation: The reason for what player will get ban
send_to_logs: whether to send ban log on Webhook Ban Logs
```

{% endcode %}

### Example Code

```lua
RegisterNetEvent("clientban")
AddEventHandler("clientban", function(violation)
    exports["anticheat-name"]:fg_BanPlayer(source, violation, true)
end)
```

## Unban Export

<pre class="language-lua"><code class="lang-lua"><strong>local result --[[ object ]] =
</strong><strong>    exports["anticheat-name"]:UnbanId(
</strong>        BanId --[[ integer ]]
    )
</code></pre>

`Parameters:`

{% code lineNumbers="true" %}

```
BanId: The Ban Id to unban
```

{% endcode %}

`Returns:`

{% code overflow="wrap" %}

```
object that contains name from ban object OR false if ban Id does not exists.
```

{% endcode %}

## Get Ban Info Id Export

<pre class="language-lua"><code class="lang-lua"><strong>local result --[[ object ]] =
</strong><strong>    exports["anticheat-name"]:GetBanInfoId(
</strong>        BanId --[[ integer ]]
    )
</code></pre>

`Parameters:`

{% code lineNumbers="true" %}

```
BanId: The Ban Id to get info
```

{% endcode %}

`Returns:`

```
ban object OR false if ban Id does not exists.
```

## Set Temp Permission Export

```lua
local result --[[ boolean ]], errorText --[[ string ]] =
    exports["anticheat-name"]:SetTempPermission(
        playerSource --[[ integer ]],
        category --[[ string ]],
        permission --[[ string ]],
        allow --[[ boolean ]],
        ignoreStaticPermission --[[ boolean ]]
    )
```

{% hint style="info" %}
Static Permission - means permissions that are already signed to the player in ACE System or Alternative Permissions
{% endhint %}

{% hint style="warning" %}
Temp Permission won't be sent to player if he is not fully loaded and fiveguard didn't fully load on his client-side
{% endhint %}

{% hint style="info" %}
All possible categories and permissions [#all-possible-permissions](https://docs.fiveguard.net/permission-system/ace-permissions#all-possible-permissions "mention")
{% endhint %}

`Parameters:`

{% code overflow="wrap" lineNumbers="true" %}

```
playerSource: The player handle
category: Permission Category (example: Client or AdminMenu)
permission: Permission (example: AdminMenuAccess for AdminMenu or BypassSuperJump for Client)
allow: true or false | default: false
ignoreStaticPermission: ignores static permission (setting it on true will ignore permissions already made in ace or alternative permissions)
```

{% endcode %}

`Returns:`

{% code overflow="wrap" %}

```
true if permission was set successfuly and errorText as nil, if not then false and errrorText will contain the error message
```

{% endcode %}

## record Player Screen Export

```lua
exports["anticheat-name"]:recordPlayerScreen(
        playerSource --[[ integer ]],
        time --[[ integer ]],
        handler --[[ func ]],
        custom_url -- [[ string ]]
    )
```

`Parameters:`

{% code overflow="wrap" lineNumbers="true" %}

```
playerSource: The player handle
time: How long will video take (in milliseconds)
handler: function and it will return url in first parameter
custom_url: url where video will be sent (leave empty if fiveguard should use Screenshot Storage Webhook)
```

{% endcode %}

`Returns:`

{% code overflow="wrap" %}

```
url in handler first parameter
error in handler second parameter (nil if there is no error)
```

{% endcode %}

### Example Code

```lua
RegisterCommnad("player_record", function(source, args, rawCommand)
    exports["anticheat-name"]:recordPlayerScreen(args[1], 3000, function(url, err)
        if err then
            return print("failed to take video: "..err)
        end
        print("recorded video: "..url)
    end)
end, true)
```

## screenshot Player Export

```lua
exports["anticheat-name"]:screenshotPlayer(
        playerSource --[[ integer ]],
        handler --[[ func ]],
        custom_url -- [[ string ]]
    )
```

`Parameters:`

{% code overflow="wrap" lineNumbers="true" %}

```
playerSource: The player handle
handler: function and it will return url in first parameter
custom_url: url where screenshot will be sent (leave empty if fiveguard should use Screenshot Storage Webhook)
```

{% endcode %}

`Returns:`

{% code overflow="wrap" %}

```
url in handler first parameter
error in handler second parameter (nil if there is no error)
```

{% endcode %}

## Refresh Player Permissions Export

```lua
exports["anticheat-name"]:RefreshPlayerPermissions(
        playerSource --[[ integer ]]
    )
```

`Parameters:`

{% code overflow="wrap" lineNumbers="true" %}

```
playerSource: The player handle
```

{% endcode %}

`Returns:`

{% code overflow="wrap" %}

```
void
```

{% endcode %}

## Register Safe Event (Safe Events System)

<pre class="language-lua"><code class="lang-lua"><strong>local retval --[[ boolean ]], errorText --[[ string ]] =
</strong><strong>    exports["anticheat-name"]:RegisterSafeEvent(
</strong>        EventName --[[ string ]],
        config --[[ object ]],
        cross_scripts --[[ boolean ]]
    )
</code></pre>

`Parameters:`

{% code overflow="wrap" lineNumbers="true" %}

```
EventName: the event name that should be protected by Safe-Events System
config: the config to specify if Safe-Events System should ban (and log) or just log { log = true, ban = true }
cross_scripts: if true then all resources can use specific event through ExecuteServerEvent export
```

{% endcode %}

`Returns:`

{% code overflow="wrap" %}

```
true if event has been registered successfuly and errorText as nil, if not then false and errorText will contain the error message
```

{% endcode %}

## Verify Token (Safe Events System)

```lua
local result --[[ boolean ]] = 
    exports["anticheat-name"]:VerifyToken(
        playerSource --[[ integer ]]
    )
```

`Parameters:`

{% code lineNumbers="true" %}

```
playerSource: The player handle
```

{% endcode %}

`Returns:`

```
true if player sent good token to server
```

### Example Of Code

```lua
--[[
local allEvents = {
    ["taxi:pay"] = false
}
local fiveguard_resource = ""
AddEventHandler("fg:ExportsLoaded", function(fiveguard_res, res)....
]]
-- Code for registering Safe Event

RegisterNetEvent("taxi:pay")
AddEventHandler("taxi:pay", function(money)
    local source = source
    if not exports[fiveguard_resource]:VerifyToken(source) then return end
    -- rest of instructions
end)
```
