2026-04-14 17:41:39 +02:00

263 lines
7.8 KiB
Markdown

# Tower Configuration
This page explains all configuration options for the network tower system in codem-phone.
---
## Overview
The tower system simulates realistic mobile network coverage across the map. Players will have varying signal strength depending on their proximity to towers, and certain apps require minimum signal levels to function.
---
## Basic Settings
```lua
TowerConfig.Settings = {
enabled = false,
maxSignalBars = 4,
debug = false,
}
```
| Option | Type | Default | Description |
| --------------- | ------- | ------- | ------------------------------------------------ |
| `enabled` | boolean | `false` | Enable/disable the network tower system |
| `maxSignalBars` | number | `4` | Maximum signal bars a player can have |
| `debug` | boolean | `false` | Shows tower zones visually for testing purposes |
---
## Tower Definitions
Each tower is defined with coordinates, coverage radius, and status.
```lua
TowerConfig.Towers = {
{ coords = vector3(-76.33, -817.14, 326.18), radius = 3500.0, name = "Downtown Tower", enabled = true },
-- Add more towers...
}
```
| Property | Type | Description |
| --------- | ------- | ---------------------------------------- |
| `coords` | vector3 | Tower location coordinates (x, y, z) |
| `radius` | number | Coverage radius in game units |
| `name` | string | Tower name for identification |
| `enabled` | boolean | Whether this tower is active |
### Default Towers
The configuration includes pre-defined towers covering Los Santos:
| Tower Name | Radius | Area |
| ------------------- | ------- | ----------------------- |
| Downtown Tower | 3500.0 | Downtown Los Santos |
| Highway Tower | 2200.0 | Main Highway |
| North Tower | 900.0 | North of the map |
| Paleto Tower | 800.0 | Paleto Bay |
| Grapeseed Tower | 700.0 | Grapeseed |
| Mount Gordo Tower | 680.0 | Mount Gordo |
| Sandy Tower | 750.0 | Sandy Shores |
| Mount Chiliad Tower | 850.0 | Mount Chiliad |
| Prison Tower | 750.0 | Bolingbroke Penitentiary|
---
## Dead Zones
Dead zones are areas with no signal coverage. These can be defined as polygon zones.
```lua
TowerConfig.DeadZones = {
{
name = "Tunnel #1",
type = "poly",
points = {
vector3(-2614.38, 3008.39, 11.69),
vector3(-2606.84, 3103.34, 14.42),
-- More points...
},
minZ = 11.0,
maxZ = 25.0,
enabled = true
}
}
```
| Property | Type | Description |
| --------- | ------- | ---------------------------------------- |
| `name` | string | Zone name for identification |
| `type` | string | Zone type (`poly` for polygon) |
| `points` | table | Array of vector3 points defining the polygon |
| `minZ` | number | Minimum Z height of the zone |
| `maxZ` | number | Maximum Z height of the zone |
| `enabled` | boolean | Whether this dead zone is active |
---
## App Signal Requirements
Define minimum signal bars required for each app to function.
```lua
TowerConfig.AppRequirements = {
twix = 2,
message = 1,
mail = 1,
calls = 1,
videocall = 2,
bank = 2,
billing = 2,
appstore = 2,
appstore_download = 3,
home = 2,
selly = 2,
darkchat = 2,
valet = 2,
thunder = 2,
music = 1,
}
```
| App | Min. Bars | Description |
| ------------------- | --------- | ------------------------------ |
| `twix` | 2 | Social media app |
| `message` | 1 | Text messaging |
| `mail` | 1 | Email |
| `calls` | 1 | Voice calls |
| `videocall` | 2 | Video calls |
| `bank` | 2 | Banking app |
| `billing` | 2 | Billing system |
| `appstore` | 2 | Open App Store |
| `appstore_download` | 3 | Download apps from store |
| `home` | 2 | Home/housing app |
| `selly` | 2 | Marketplace app |
| `darkchat` | 2 | Dark web chat |
| `valet` | 2 | Vehicle valet service |
| `thunder` | 2 | Thunder app |
| `music` | 1 | Music streaming |
---
## Adding Custom Towers
To add a new tower, append to the `TowerConfig.Towers` table:
```lua
{ coords = vector3(X, Y, Z), radius = 500.0, name = "My Custom Tower", enabled = true },
```
**Tips:**
- Larger radius = more coverage area
- Downtown Tower has the largest radius (3500.0) as it covers the main city
- Adjust radius based on area population density
- Enable `debug = true` to visualize tower coverage zones
---
## Adding Dead Zones
To create a dead zone (e.g., tunnels, underground areas):
```lua
{
name = "Underground Parking",
type = "poly",
points = {
vector3(X1, Y1, Z1),
vector3(X2, Y2, Z2),
vector3(X3, Y3, Z3),
-- Add more points to define the polygon shape
},
minZ = 0.0,
maxZ = 10.0,
enabled = true
}
```
---
## Signal Calculation
Signal strength is calculated based on:
1. Distance to nearest enabled tower
2. Whether player is in a dead zone
3. Tower's coverage radius
Players closer to tower centers receive stronger signals (more bars).
---
## Exports
The tower system provides exports for use in other resources.
### GetCurrentSignal
Returns the current signal strength (0 to maxSignalBars).
```lua
local signal = exports['codem-phone']:GetCurrentSignal()
print("Current signal:", signal) -- 0, 1, 2, 3, or 4
```
### CanUseApp
Checks if an app can be used with current signal strength.
```lua
local canUseBank = exports['codem-phone']:CanUseApp('bank')
if canUseBank then
-- Player has enough signal for banking
else
-- Not enough signal
end
```
### GetNearestTower
Returns information about the nearest tower.
```lua
local tower = exports['codem-phone']:GetNearestTower()
if tower then
print("Nearest tower:", tower.name)
print("Tower coords:", tower.coords)
print("Tower radius:", tower.radius)
end
```
### IsInDeadZone
Checks if given coordinates are in a dead zone.
```lua
local playerCoords = GetEntityCoords(PlayerPedId())
local inDeadZone, zoneName = exports['codem-phone']:IsInDeadZone(playerCoords)
if inDeadZone then
print("Player is in dead zone:", zoneName)
end
```
### GetTowerConfig
Returns the entire tower configuration table.
```lua
local config = exports['codem-phone']:GetTowerConfig()
print("Tower system enabled:", config.Settings.enabled)
print("Max signal bars:", config.Settings.maxSignalBars)
print("Total towers:", #config.Towers)
```
### Export Summary
| Export | Parameters | Returns | Description |
| ------ | ---------- | ------- | ----------- |
| `GetCurrentSignal` | none | number | Current signal strength (0-4) |
| `CanUseApp` | appName (string) | boolean | Whether app can be used |
| `GetNearestTower` | none | table/nil | Nearest tower info |
| `IsInDeadZone` | coords (vector3) | boolean, string | Dead zone check |
| `GetTowerConfig` | none | table | Full tower configuration |