> For the complete documentation index, see [llms.txt](https://0grav1ty.gitbook.io/zerogravity/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://0grav1ty.gitbook.io/zerogravity/teleport-menu.md).

# Teleport Menu

<figure><img src="/files/QST7m3U51Ad7Xdre9yB4" alt="" width="375"><figcaption></figcaption></figure>

***

#### 🧾 Overview

**Name:** Advanced Teleportation Script\
**Version:** 1.1\
**Author:** 0Gravity BVVS\
**Framework:** Standalone\
**Compatible with:** ESX / QBCore (customizable)\
**Description:**\
A lightweight but powerful teleportation script that offers an in-game selection menu, admin-only points, cooldown logic, and automatic Discord logging of each teleport action.

***

#### 🚀 Installation

1. Place the script folder inside your server's `resources` directory.
2. In `server.lua`, configure your Discord webhook:

   ```lua
   local discordWebhookURL = "https://discord.com/api/webhooks/..."
   ```
3. Add the resource to your `server.cfg`:

   ```
   ensure teleport-script
   ```

***

#### ⚙️ Features

* `/teleport` command to open a menu or teleport to a location
* Native notification system
* Admin-only teleport points
* Discord webhook integration
* (Optional) Cooldown system structure

***

#### 🧭 Teleport Locations

Teleportation points are defined in `client.lua` as:

```lua
local teleportPoints = {
    {name = "LS Airport", coords = vector3(-1034.6, -2733.6, 20.2), adminOnly = false},
    {name = "Downtown", coords = vector3(215.76, -810.12, 30.73), adminOnly = false},
    {name = "Admin Base", coords = vector3(450.0, -980.0, 30.0), adminOnly = true},
}
```

> You can add or remove locations as needed.\
> Use `adminOnly = true` to restrict access to admins.

***

#### 🔐 Admin Permissions

Inside `client.lua`, the `isPlayerAdmin()` function determines who can access admin-only locations.

```lua
local function isPlayerAdmin()
    return true -- Everyone is considered admin by default
end
```

You can modify this to work with your framework:

* **ESX:**

  ```lua
  return ESX.PlayerData.group == 'admin' or ESX.PlayerData.group == 'superadmin'
  ```
* **QBCore:**

  ```lua
  return PlayerData.permission == "admin"
  ```

***

#### 🖥️ Usage

**Command:**

```
/teleport
```

**Behavior:**

* If no argument is provided: a list of available points is displayed.
* If a number is provided: the player is teleported to the selected destination.\
  Example:

  ```
  /teleport 2
  ```

**Feedback:**\
Players receive a native notification on-screen with teleport status.

***

#### 📊 Discord Logging

Every teleport action triggers a server event:

```lua
TriggerServerEvent('teleport:logEvent', GetPlayerName(PlayerId()), point.name)
```

The server then sends a message to your Discord via webhook:

```
Player **PlayerName** teleported to: **LocationName**
```

This is handled in `server.lua` using `PerformHttpRequest`.

***

#### ⏲️ Cooldown Logic

A cooldown system is prepared using:

```lua
local teleportCooldown = 5
local lastTeleportTime = {}
```

Currently, cooldown is not enforced. You can extend this logic to prevent frequent teleports.

***

#### 🧱 File Structure

```plaintext
teleport-script/
├── client.lua          # Handles teleportation, menu, admin check
├── server.lua          # Sends logs to Discord via webhook
└── fxmanifest.lua      # Resource manifest
```

***

#### 💡 Suggestions for Improvement

* Implement real cooldown enforcement
* Migrate teleport points to `config.lua`
* Add GUI/NUI teleportation interface
* Add sound or animation effects
* Support ox\_lib or qb-menu UI integration
* Add a whitelist system using Discord IDs

***

#### 🧪 Example Workflow

1. Player types `/teleport`
2. Script shows a list of available teleport points
3. Player types `/teleport 1`
4. Player is moved to "LS Airport"
5. Log appears on Discord with player name and location

***

Would you like me to export this as a ready-to-import GitBook `.md` structure or help set up a config file?


---

# 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, and the optional `goal` query parameter:

```
GET https://0grav1ty.gitbook.io/zerogravity/teleport-menu.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
