Codineer Docs
Search…
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!

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
1
"serviceCall": [{
Copied!
If you already have a taxi service change its event to "Taxi:CallTaxi" it should look like this:
config.json
1
"eventName": "Taxi:CallTaxi",
Copied!
If you do not have a taxi service yet create one by adding the following lines of code to your serviceCall list:
config.json
1
{
2
"display": "Taxi",
3
"icon": "/html/static/img/icons_app/taxi.png",
4
"subMenu": [{
5
"title": "Call a taxi",
6
"eventName": "Taxi:CallTaxi",
7
"type": {
8
"number": "taxi"
9
}
10
},
11
{
12
"title": "Cancel your taxi",
13
"eventName": "Taxi:CancelTaxi",
14
"type": {
15
"number": "taxi"
16
}
17
}
18
]
19
}
Copied!
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
1
"serviceCall": [{
2
"display": "Police",
3
"icon": "/html/static/img/icons_app/policia.png",
4
"subMenu": [{
5
"title": "Send a message",
6
"eventName": "esx_addons_gcphone:call",
7
"type": {
8
"number": "police"
9
}
10
},
11
{
12
"title": "Call emergency number",
13
"eventName": "gcphone:autoCallNumber",
14
"type": {
15
"number": "911"
16
}
17
}
18
]
19
},
20
{
21
"display": "Ambulance",
22
"backgroundColor": "red",
23
"icon": "/html/static/img/icons_app/lsfd.png",
24
"subMenu": [{
25
"title": "Send a message",
26
"eventName": "esx_addons_gcphone:call",
27
"type": {
28
"number": "ambulance"
29
}
30
}]
31
},
32
{
33
"display": "Taxi",
34
"icon": "/html/static/img/icons_app/taxi.png",
35
"subMenu": [{
36
"title": "Call a taxi",
37
"eventName": "Taxi:CallTaxi",
38
"type": {
39
"number": "taxi"
40
}
41
},
42
{
43
"title": "Cancel your taxi",
44
"eventName": "Taxi:CancelTaxi",
45
"type": {
46
"number": "taxi"
47
}
48
}
49
]
50
}
51
],
Copied!
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
1
RegisterNUICallback('callEvent', function(data, cb)
Copied!
The function below this line should look like this:
client.lua
1
RegisterNUICallback('callEvent', function(data, cb)
2
local eventName = data.eventName or ''
3
if string.match(eventName, 'gcphone') then
4
if data.data ~= nil then
5
TriggerEvent(data.eventName, data.data)
6
else
7
TriggerEvent(data.eventName)
8
end
9
else
10
print('Event not allowed')
11
end
12
cb()
13
end)
14
RegisterNUICallback('useMouse', function(um, cb)
15
useMouse = um
16
end)
17
RegisterNUICallback('deleteALL', function(data, cb)
18
TriggerServerEvent('gcPhone:deleteALL')
19
cb()
20
end)
Copied!
Now replace this function with this one:
client.lua
1
RegisterNUICallback('callEvent', function(data, cb)
2
local eventName = data.eventName or ''
3
if string.match(eventName, 'gcphone') or string.match(eventName, 'Taxi') then
4
if data.data ~= nil then
5
TriggerEvent(data.eventName, data.data)
6
else
7
TriggerEvent(data.eventName)
8
end
9
else
10
print('Event not allowed')
11
end
12
cb()
13
end)
14
RegisterNUICallback('useMouse', function(um, cb)
15
useMouse = um
16
end)
17
RegisterNUICallback('deleteALL', function(data, cb)
18
TriggerServerEvent('gcPhone:deleteALL')
19
cb()
20
end)
Copied!
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. 1.
    Vehicle Handle
    Can be used to retrieve the vehicle object or for native calls
  2. 2.
    License Plate
    Can be used as identifier for some key resources

Example implementation

C# Example
1
EventHandlers["AiTaxiPro:CarSpawned"] += new Action<int, string>(TargetFunction);
2
3
private void TargetFunction(int handle, string plate)
4
{
5
myKeyScript.unlockCar(handle);
6
}
Copied!
Lua Example
1
AddEventHandler("AiTaxiPro:CarSpawned", function(handle, plate)
2
myKeyScript.unlockCar(handle)
3
end)
Copied!
JS Example
1
on('AiTaxiPro:CarSpawned', (handle, plate) => {
2
myKeyScript.unlockCar(handle);
3
});
Copied!

Billing events

Please note that the implementation for billing events is only included in Ai Taxi Pro version 1.8 or newer. Please also note that the event will only be triggered for successful payments.
Please note that this is a server side event. If your system needs client side implementation you will have to implement the bridge yourself.
Ai Taxi Pro has an event called AiTaxiPro:Billing that is triggered whenever a player pays his taxi bill.

Parameters

  1. 1.
    Player Handle
    Can be used to retrieve the player object or for native calls
  2. 2.
    Amount
    The amount the player paid

Example Implementation

C# Example
1
EventHandlers["AiTaxiPro:Billing"] += new Action<int, int>(TargetFunction);
2
3
private void TargetFunction(int handle, int amount)
4
{
5
myScript.coolFunction(handle, amount);
6
}
Copied!
Lua Example
1
AddEventHandler("AiTaxiPro:Billing", function(handle, amount)
2
myScript.coolFunction(handle, amount)
3
end)
Copied!
JS Example
1
on('AiTaxiPro:Billing', (handle, amount) => {
2
myScript.coolFunction(handle, amount);
3
});
Copied!