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!
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.
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.- 1.Vehicle HandleCan be used to retrieve the vehicle object or for native calls
- 2.License PlateCan be used as identifier for some key resources
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);
});
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.- 1.Player HandleCan be used to retrieve the player object or for native calls
- 2.AmountThe amount the player paid
- 3.Success If the payment was successful or not
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);
}
});
Last modified 1mo ago