# Security Integration

{% hint style="danger" %}
To ensure the security and integrity of server events within TCVS, a unique security code for each server event must be included as the first parameter when triggering any of TCVS' server events. This measure is designed to authenticate the source of the event call, reducing the risk of unauthorized access and manipulation.
{% endhint %}

### Obtaining The Security Code

You can obtain the necessary security code for an event by utilizing the following code snippet. This example demonstrates how to retrieve the security code for the <mark style="color:yellow;">`:server:impoundCheck`</mark> event, but it can be adapted for any TCVS server event by replacing the event suffix with the one relevant to your needs.

{% hint style="info" %} <mark style="color:orange;">**CLIENT-SIDED**</mark>

<pre class="language-lua"><code class="lang-lua"><strong>local security = GetEventCode(GetCurrentResourceName(), GetEventPrefix(GetCurrentResourceName()) .. ":server:impoundCheck")
</strong><strong>local eventPrefix = GetEventPrefix(GetCurrentResourceName())
</strong></code></pre>

{% endhint %}

### Using the Security Code

Once you have obtained the security code, include it as the first parameter when triggering the server event. Here’s how you can do it for the `:server:impoundCheck` event.

{% hint style="info" %} <mark style="color:orange;">**CLIENT-SIDED**</mark>

<pre class="language-lua"><code class="lang-lua"><strong>TriggerServerEvent(eventPrefix .. ":server:impoundCheck", security)
</strong></code></pre>

{% endhint %}

### Server To Server Event Execution

When triggering events from server to server, it's important to note that the security exports designed for client-server communication do not apply. Since these security measures are specifically registered through the client, server-to-server event triggering bypasses the need for a security code.

For server-sided event execution, instead of generating a security code, you should directly use the number `1` as the first parameter. This approach simplifies the process while maintaining the structured call pattern for events.

{% hint style="info" %} <mark style="color:orange;">**SERVER-SIDED**</mark>

<pre class="language-lua"><code class="lang-lua"><strong>TriggerEvent(Security.EventPrefix .. ":server:impoundCheck", 1)
</strong></code></pre>

{% endhint %}


---

# Agent Instructions: 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://docs.cisoko.net/the-complete-vehicle-system/security-integration.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.
