esx_taxijob
Set up esx_taxijob for ESX Legacy. NPC taxi missions, payout split, billing, config keys with defaults, server events, callbacks and fixes for common issues.
esx_taxijob adds a taxi job: drivers spawn a cab at the depot, bill player passengers from an F6 menu, and run NPC fares that pick up a pedestrian and drive them to a random destination for a payout. It is the simplest official job addon and a good template for your own delivery-style jobs.
Overview
| Resource | esx_taxijob (version 1.0) |
| Side | client + server |
| Job name | taxi (grades recrue, novice, experimente, uber, boss) |
| Society | society_taxi, registered as a public society |
| Dependencies (fxmanifest) | esx_lib, es_extended |
| Also required at runtime | oxmysql, esx_society, esx_addonaccount, esx_addoninventory, esx_datastore, esx_billing |
| Optional | esx_service when Config.MaxInService is not -1 |
| OneSync | Required. Vehicles are spawned server-side with ESX.OneSync.SpawnVehicle. |
Depot markers
| Zone | Purpose |
|---|---|
TaxiActions | Stock deposit and withdraw, and the boss menu for the boss grade. |
Cloakroom | Switch between work and civilian clothes (from job_grades skins). |
VehicleSpawner | Take out a cab. |
VehicleSpawnPoint | Where the cab appears. |
VehicleDeleter | Return the cab. |
Installation
Import the SQL
Run esx_taxijob.sql. It creates the society_taxi account, datastore and inventory, and the taxi job with five grades and uniforms. Skip this if your database came from the ESX txAdmin recipe, which already contains these rows.
Start it
ensure esx_society
ensure esx_billing
ensure esx_taxijobConfiguration
| Key | Default | Description |
|---|---|---|
Config.DrawDistance | 10.0 | Distance at which markers are drawn. |
Config.NPCJobEarnings | { min = 300, max = 600 } | Random total per NPC fare. Doubled for grade 3 and higher. |
Config.MinimumDistance | 3000 | Minimum distance between pickup and drop-off, in GTA units. The server rejects shorter missions. |
Config.MaxInService | -1 | Service limit through esx_service. -1 disables it. |
Config.EnablePlayerManagement | true | Enables the boss menu and the F6 mobile menu. |
Config.EnableSocietyOwnedVehicles | false | Take cabs from the esx_society vehicle garage instead of spawning Config.AuthorizedVehicles. |
Config.Locale | GetConvar('esx:locale', 'en') | Language. |
Config.OxInventory | ESX.GetConfig().OxInventory | Read from es_extended. |
Config.AuthorizedVehicles | { { model = 'taxi', title = 'Taxi', icon = 'fas fa-car' } } | Cabs offered at the spawner. Grades below 3 must drive one of these for NPC fares. |
Config.Zones | see table above | Pos, Size, Color, Type and Rotate per marker. VehicleSpawnPoint also has a Heading. |
Config.JobLocations | list of vector3 | Possible NPC drop-off points. The server only accepts destinations within 5 units of one of them. |
-- Offer a second cab model
Config.AuthorizedVehicles = {
{ model = 'taxi', title = 'Taxi', icon = 'fas fa-car' },
{ model = 'stretch', title = 'Limousine', icon = 'fas fa-car' },
}How NPC fares work
- Open F6 and choose Start NPC job while driving an authorized cab (or any car at grade 3+).
- The client finds a pedestrian, and when they get in, sends
esx_taxijob:startMissionwith the pickup and destination. - The server stores the mission only if the destination is one of
Config.JobLocations, the player is within 80 units of the pickup, and the trip is at leastConfig.MinimumDistancelong. - At the destination the client sends
esx_taxijob:success. The server pays only if the player is within 18 units of the stored drop-off, still in an authorized vehicle, and at least 10 seconds have passed since the last payout.
With the society_taxi account available the payout is split: 30% to the driver as cash and 70% to the society. Without it, the driver gets the full amount.
Commands and keybinds
| Command | Default key | Description |
|---|---|---|
taximenu | F6 | Opens the mobile taxi menu: bill the closest player, start or stop NPC fares. |
Depot markers use the E key (control 38).
Server events
| Event | Arguments | Server checks |
|---|---|---|
esx_taxijob:startMission | pickupCoords, dropoffCoords | Taxi job, authorized vehicle, valid drop-off, distance rules. |
esx_taxijob:success | none | Active mission, near drop-off, authorized vehicle, 10 second cooldown. |
esx_taxijob:getStockItem | itemName, count | Taxi job, within 8 units of TaxiActions. |
esx_taxijob:putStockItems | itemName, count | Taxi job, within 8 units of TaxiActions. |
esx_taxijob:success pays money, so it is the event an exploiter would spam. The mission state lives on the server, and the payout requires a stored mission, so calling it without a real fare only logs a warning.
Server callbacks
| Callback | Arguments | Returns |
|---|---|---|
esx_taxijob:SpawnVehicle | model, props | true if a cab was spawned. Requires the taxi job, the player within 15 units of VehicleSpawner, and a clear spawn point. |
esx_taxijob:getStockItems | none | Items in society_taxi. |
esx_taxijob:getPlayerInventory | none | { items = ... } of the caller. |
Integration tips
- Player fares from the F6 menu are sent through
esx_billing:sendBilltosociety_taxi, so the society receives the money once the passenger pays. - To adjust the 30/70 split, edit the
esx_taxijob:successhandler inserver/main.lua. There is no config key for it. - Add more drop-off points by appending
vector3positions toConfig.JobLocations. Keep them on roads so the AI passenger can walk away.
Common issues
- Cab does not spawn. The spawn point is blocked by another vehicle, OneSync is off, or the player is not near the spawner.
- "Must be in a taxi" for a car that looks like a taxi. Only exact models from
Config.AuthorizedVehiclescount for grades 0 to 2. - Fare never pays. The destination must be within 18 units when you arrive. Stopping far from the marker or switching vehicles cancels the payout.
Related
Frequently asked questions
Independent documentation
Last updated on
esx_status
esx_status stores and syncs player needs like hunger, thirst and drunk in ESX Legacy. Covers the server-authoritative model, config, events and examples.
esx_vehicleshop
esx_vehicleshop adds the Premium Deluxe Motorsport dealership to ESX Legacy, with direct sales or a car dealer job, rentals and reselling. Setup and API.