> 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?
