Zum Hauptinhalt springen

πŸš– Ai Taxi Pro

Imagine you're playing on your favorite server, stranded in the middle of nowhere, with only two options: 1. Steal a car or 2. Spawn a car. Now, there's a third option: Call a Taxi!

About the config.json​

View config.json

{
"Licsense": "Enter your License",
"UseAccount": false,
"Account": "bank",
"CheckMoneyBeforeRide": false,
"BasePrice": 2.50,
"PricePerDistance": 2.25,
"UseMiles": false,
"EnableTaximeter": true,
"EnableCommand": true,
"Command": "taxi",
"EnableEarlyStopping": true,
"EarlyStoppingHotkey": 47,
"FirstDrivingStyleName": "slower",
"DrivingStyle": 786603,
"DrivingSpeed": 30,
"SecondDrivingStyleName": "faster",
"EnableSecondDrivingStyle": false,
"SecondDrivingStyle": 1074528805,
"SecondDrivingSpeed": 80,
"MinSpawnDistance": 10,
"MaxSpawnDistance": 75,
"HaltDistance": 15,
"Ped": "a_m_m_bevhills_02",
"Vehicle": "taxi",
"DisableNetworkedEntities": false
}

Verification​

  • License: 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". Ensure the value matches 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 in-game.

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.

  • 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.

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: FiveM Controls

For all FiveM Peds check: FiveM 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 differ.

Please note that we are using GCPhone version 1.5.2 and the implementation could differ in older versions.

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

"serviceCall": [{

If you already have a taxi service, change its event to "Taxi:CallTaxi" so it looks like this:

"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:

{
"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:

"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:

RegisterNUICallback('callEvent', function(data, cb)

The function below this line should look like this:

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:

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 an 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 events 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 an 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);
});