🚖Ai Taxi Pro

Imagine, you are playing on your favorite server, and you are somewhere in the nowhere, and you have only 2 options: 1. steal a car and 2. spawn a car. Now there is a third option: Call a Taxi!

FiveM Forum Post: https://forum.cfx.re/t/ai-taxi-pro-2-0-the-ultimate-taxi-experience/5069213

YouTube Video: https://www.youtube.com/watch?v=ZrSd-FBjFrM

Download: https://garmingo.com/games/tebex/4268959

About the config.json

{
    /* -- Verification -- */
    "TransactionID": "TransactionID",
    /* -- Verification -- */

    /* -- Payment -- */
    "UseAccount": false,
    "Account": "bank",
    "CheckMoneyBeforeRide": false,
    "BasePrice": 2.50,
    "PricePerDistance": 2.25, /* Price per 1 mile or 1 kilometer - unit can be set below */
    "UseMiles": false, /* By default km is used as distance measurement unit. If you want to use miles set it to true */
    /* -- Payment -- */

    /* -- Taximeter -- */
    "EnableTaximeter": true,
    /* -- Taximeter -- */

    /* -- Command -- */
    "EnableCommand": true,
    "Command": "taxi",
    /* -- Command -- */

    /* -- Early Stopping -- */
    "EnableEarlyStopping": true,
    "EarlyStoppingHotkey": 47,
    /* -- Early Stopping -- */

    /* -- Main Driving Style --*/
    "FirstDrivingStyleName": "slower",
    "DrivingStyle": 786603,
    "DrivingSpeed": 30,
    /* -- Main Driving Style --*/

    /* -- Second Driving Style -- */
    "SecondDrivingStyleName": "faster",
    "EnableSecondDrivingStyle": false,
    "SecondDrivingStyle": 1074528805,
    "SecondDrivingSpeed": 80,
    /* -- Second Driving Style -- */

    /* -- Initial drive to player -- */
    "MinSpawnDistance": 10,
    "MaxSpawnDistance": 75,
    "HaltDistance": 15,
    /* -- Initial drive to player -- */

    /* -- Models -- */
    "Ped": "a_m_m_bevhills_02",
    "Vehicle": "taxi",
    /* -- Models -- */

    /* -- Advanced -- */
    /* WARNING: Only change if you know what you are doing!!! */
    "DisableNetworkedEntities": false
    /* -- Advanced -- */

}

Verification

  • TransactionID: A unique identifier for each transaction. This field is used for tracking and verification purposes. Learn more

Payment

  • UseAccount: Determines whether to use a linked account for payments. Set to false for cash payments, true to use an account.

  • Account: Specifies the type of account to use for payments, e.g., "bank". Make sure the value match the value within the database.

  • CheckMoneyBeforeRide: If set to true, the system checks if the passenger has enough money before starting the ride.

  • BasePrice: The starting price for a ride, regardless of distance

  • PricePerDistance: The price charged per unit of distance (either mile or kilometer).

  • UseMiles: Set to true to use miles as the distance measurement unit. Defaults to kilometers if false.

Taximeter

  • EnableTaximeter: Set to true to enable the taximeter during rides.

Command

  • EnableCommand: If true, allows the use of the command set below to start the job.

  • Command: The specific command to be used, e.g., "taxi" would mean /taxi ingame.

Early Stopping

  • EnableEarlyStopping: Allows the ride to be stopped early if set to true.

  • EarlyStoppingHotkey: The keyboard key assigned for early stopping functionality. Example value: 47*

Main Driving Style

For custom driving styles, we suggest using the Driving Style Calculator by Vespura (a FiveM Developer) -> https://vespura.com/fivem/drivingstyle/

  • FirstDrivingStyleName: A descriptive name for the primary driving style, e.g., "slower".

  • DrivingStyle: Numerical code representing the primary driving style. (Output of the Driving Style Calculator)

  • DrivingSpeed: The speed limit for the primary driving style.

Second Driving Style

  • SecondDrivingStyleName: Name for the secondary driving style, e.g., "faster".

  • EnableSecondDrivingStyle: Enables a second driving style when set to true.

  • SecondDrivingStyle: Numerical code for the secondary driving style. (Output of the Driving Style Calculator)

  • SecondDrivingSpeed: Speed limit for the secondary driving style.

Initial Drive to Player

  • MinSpawnDistance: The minimum distance from the player where the taxi spawns.

  • MaxSpawnDistance: The maximum distance for taxi spawning.

  • HaltDistance: The distance from the player where the taxi will stop. E

Models

  • Ped: Specifies the model for the pedestrian, e.g., "a_m_m_bevhills_02".**

  • Vehicle: Designates the vehicle model to be used, e.g., "taxi".

Advanced

  • DisableNetworkedEntities: If set to true, it disables networked entities. This is an advanced setting and should be changed only if you have the necessary technical knowledge.

*For all FiveM Hotkeys check: https://docs.fivem.net/docs/game-references/controls/

**For all FiveM Peds check: https://docs.fivem.net/docs/game-references/ped-models/

Resizing Taximeter

To resize the Taximeter display in the Ai Taxi Pro, follow these steps:

  1. Navigate to the 'Ai Taxi Pro' folder on your computer or server.

  2. Inside this folder, locate and open the 'nui' folder.

  3. In the 'nui' folder, find the file named 'index.html'.

  4. Open the 'index.html' file with your preferred code editor.

  5. Look for the following line of code, which should be around line 21:

scale: 75%;
  1. To adjust the size of the Taximeter, change the percentage value in this line. For example, to make it larger, you might change it to scale: 90%;. To make it smaller, you could use scale: 60%;.

  2. Save your changes to the 'index.html' file.

After these adjustments, the Taximeter in your Ai Taxi Pro will be resized according to the new scale percentage you set.

Phone Implementation

The guide below shows how to connect AiTaxiPro with GCPhone, other phone scripts are supported but the implementation may be different.

Please note that we are using gcphone version 1.5.2 and the implementation could be different in older versions.

Open the config.json file of your gcphone installation and search for the following line:

config.json
"serviceCall": [{

If you already have a taxi service change its event to "Taxi:CallTaxi" it should look like this:

config.json
"eventName": "Taxi:CallTaxi",

If you do not have a taxi service yet create one by adding the following lines of code to your serviceCall list:

config.json
{
      "display": "Taxi",
      "icon": "/html/static/img/icons_app/taxi.png",
      "subMenu": [{
          "title": "Call a taxi",
          "eventName": "Taxi:CallTaxi",
          "type": {
            "number": "taxi"
          }
        },
        {
          "title": "Cancel your taxi",
          "eventName": "Taxi:CancelTaxi",
          "type": {
            "number": "taxi"
          }
        }
      ]
    }

Please note that you have to add the image to your icons_app folder yourself.

Your finished services list should look something like this:

config.json
  "serviceCall": [{
      "display": "Police",
      "icon": "/html/static/img/icons_app/policia.png",
      "subMenu": [{
          "title": "Send a message",
          "eventName": "esx_addons_gcphone:call",
          "type": {
            "number": "police"
          }
        },
        {
          "title": "Call emergency number",
          "eventName": "gcphone:autoCallNumber",
          "type": {
            "number": "911"
          }
        }
      ]
    },
    {
      "display": "Ambulance",
      "backgroundColor": "red",
      "icon": "/html/static/img/icons_app/lsfd.png",
      "subMenu": [{
        "title": "Send a message",
        "eventName": "esx_addons_gcphone:call",
        "type": {
          "number": "ambulance"
        }
      }]
    },
    {
      "display": "Taxi",
      "icon": "/html/static/img/icons_app/taxi.png",
      "subMenu": [{
          "title": "Call a taxi",
          "eventName": "Taxi:CallTaxi",
          "type": {
            "number": "taxi"
          }
        },
        {
          "title": "Cancel your taxi",
          "eventName": "Taxi:CancelTaxi",
          "type": {
            "number": "taxi"
          }
        }
      ]
    }
  ],

Now we have to edit another file inside our gcphone installation. Please open the following file: "client/client.lua" and search for the following line:

client.lua
RegisterNUICallback('callEvent', function(data, cb)

The function below this line should look like this:

client.lua
RegisterNUICallback('callEvent', function(data, cb)
  local eventName = data.eventName or ''
  if string.match(eventName, 'gcphone') then
    if data.data ~= nil then 
      TriggerEvent(data.eventName, data.data)
    else
      TriggerEvent(data.eventName)
    end
  else 
    print('Event not allowed')
  end
  cb()
end)
RegisterNUICallback('useMouse', function(um, cb)
  useMouse = um
end)
RegisterNUICallback('deleteALL', function(data, cb)
  TriggerServerEvent('gcPhone:deleteALL')
  cb()
end)

Now replace this function with this one:

client.lua
RegisterNUICallback('callEvent', function(data, cb)
  local eventName = data.eventName or ''
  if string.match(eventName, 'gcphone') or string.match(eventName, 'Taxi') then
    if data.data ~= nil then 
      TriggerEvent(data.eventName, data.data)
    else
      TriggerEvent(data.eventName)
    end
  else 
    print('Event not allowed')
  end
  cb()
end)
RegisterNUICallback('useMouse', function(um, cb)
  useMouse = um
end)
RegisterNUICallback('deleteALL', function(data, cb)
  TriggerServerEvent('gcPhone:deleteALL')
  cb()
end)

It looks very similar and the only thing that changed is that not only gcphones own events, but now also the Taxi events are allowed.

Key System implementation

Please note that the implementation for car key systems is only included in Ai Taxi Pro version 1.6 or newer.

Please note that this is a client side event. If your car key system needs server side implementation you will have to implement the bridge yourself.

Ai Taxi Pro has an event called AiTaxiPro:CarSpawned that is triggered whenever a taxi is being spawned for the player.

Parameters

  1. Vehicle Handle

    Can be used to retrieve the vehicle object or for native calls

  2. License Plate

    Can be used as identifier for some key resources

Example implementation

C# Example
EventHandlers["AiTaxiPro:CarSpawned"] += new Action<int, string>(TargetFunction);

private void TargetFunction(int handle, string plate)
{
    myKeyScript.unlockCar(handle);
}
Lua Example
AddEventHandler("AiTaxiPro:CarSpawned", function(handle, plate)
    myKeyScript.unlockCar(handle)
end)
JS Example
on('AiTaxiPro:CarSpawned', (handle, plate) => {
    myKeyScript.unlockCar(handle);
});

Billing events

Please note that the implementation for billing events is only included in Ai Taxi Pro version 1.8 or newer.

Please note that the success parameter is only available in Ai Taxi Pro version 1.11 or newer and also the event is also not triggered on successful events in older versions.

Please note that this is a server side event only in versions below 1.11. Also the client side event will not have the first parameter

Ai Taxi Pro has an event called AiTaxiPro:Billing that is triggered whenever a player pays his taxi bill.

Parameters

  1. Player Handle

    Can be used to retrieve the player object or for native calls

  2. Amount

    The amount the player paid

  3. Success If the payment was successful or not

Example Implementation

C# Example
EventHandlers["AiTaxiPro:Billing"] += new Action<int, int, bool>(TargetFunction);

private void TargetFunction(int handle, int amount, bool success)
{
    if (success) {
        myScript.coolFunction(handle, amount);
    }
}
Lua Example
AddEventHandler("AiTaxiPro:Billing", function(handle, amount, success)
    myScript.coolFunction(handle, amount)
end)
JS Example
on('AiTaxiPro:Billing', (handle, amount, success) => {
    if (success) {
        myScript.coolFunction(handle, amount);
    }
});

Cleanup Event

Please note that the implementation for car cleanup eventss is only included in Ai Taxi Pro version 2.3 or newer.

Please note that this is a client side event. If your car key system needs server side implementation you will have to implement the bridge yourself.

Ai Taxi Pro has an event called AiTaxiPro:CarCleanup that is triggered whenever a taxi is no longer needed for the player.

Parameters

  1. Vehicle Handle

    Can be used to retrieve the vehicle object or for native calls

  2. License Plate

    Can be used as identifier for some key resources

Example implementation

C# Example
EventHandlers["AiTaxiPro:CarCleanup"] += new Action<int, string>(TargetFunction);

private void TargetFunction(int handle, string plate)
{
    myScript.deleteCar(handle);
}
Lua Example
AddEventHandler("AiTaxiPro:CarCleanup", function(handle, plate)
    myScript.deleteCar(handle)
end)
JS Example
on('AiTaxiPro:CarCleanup', (handle, plate) => {
    myScript.deleteCar(handle);
});

Last updated