[Tutorial] - GCPhone - Adding calls and job messages

I would really appreciate help with this. I would pay someone to get this working for us. It’s a fantastic script, adds a lot to RP.

EDIT: If anyone is interested DM me.

1 Like

I cant get it to work when I try to call Mechanic?
anyone have the same problem?

Hi, i just followed your steps, getting this error when trying.

Error loading script server/server.lua in resource gcphone: server/server.lua:687: attempt to index a nil value (global ‘ESX’)
stack traceback:
server/server.lua:687: in main chunk
Failed to load script server/server.lua.

how can i change the phone number from 000.1232 to 4 digits number?

Hey, i think i got the same problem but, what should it be instead?

is this script 100% correct?
I’ve followed the step by step but i cannot open my phone. There is no errors that are thrown or anything like that - the F1 just simply doesn’t work. If i uncomment that code it works.
I tried looking at how you ESX.RegisterServerCallback('esx_gcphone:getItemAmount) but you are calling it as: TriggerServerCallback('gcphone:getItemAmount). i tried chaning the esx_gcphone to gcphone:getItemAmount but it still fails to pull out the phone or even execute as far as i’m concerned because i tested it both with ESX.ShowNotification and print(). Any advice?

Edit function getPhoneRandomNumber in gcphone/server/server.lua:9.

function getPhoneRandomNumber()
  return string.format("%04d",  math.random(0,9999))
end

so like this?
local numBase0 = math.random(100,999)
local numBase1 = math.random(0,9999)
local num = string.format("%04d", numBase0, numBase1 )
return num
end

— Exemple pour les numero du style 06XXXXXXXX
– function getPhoneRandomNumber()
– return ‘0’ … math.random(600000000,699999999)

what corrected version? i have blank screen to…

yep, everything works, calling and stuff but police, ems, mechanic cant receive my emergency calls. Both scripts are before any job related stuff, dont know where the problem is. Anyone else with this? Thanks in advance

So got everything working, however the GPS doesn’t work. Added the addon pack so it should work. When we press right on the arrows, it comes up with ‘Send GPS Coordinates’ then when we click it nothing happens. Also not correctly giving coordinates to Ambulance/Police either.

Hi,
Without your files it’s complicated to help you.

Tutorial :

/!\ If you want use gcphone with mysql-async 2.x, download this version https://github.com/brouznouf/fivem-mysql-async/tree/2.0

/!\ If you want use gcphone with mysql-async 3.0, check here https://github.com/HalCroves/gcphone/tree/mysql-async-3.x


  1. Download the gcphone and esx_addons_gcphone

  2. Put the downloaded files on your ftp.

    • server-data/resources/
    • gcphone => in “server-data/resources/”
    • esx_addons_gcphone => in “server-data/resources/[ESX]”
  3. In, your server.cfg, put before the jobs addons :

    • start gcphone
    • start esx_addons_gcphone

Like this :

# you probably don't want to change these!
# only change them if you're using a server with multiple network interfaces

####################### PORT DU SERVEUR
endpoint_add_tcp "0.0.0.0:30120"
endpoint_add_udp "0.0.0.0:30120"

####################### CONFIG ES
set es_enableCustomData 1

####################### BASE DE DONNEES
set mysql_connection_string "server=localhost;database=essentialmode;userid=root;password=Saxophone21121993+"

####################### ES Base
start mysql-async
start essentialmode
start esplugin_mysql
start es_admin2 

####################### BASIC
start instance
start es_extended
start esx_voice
start esx_addons_gcphone
start gcphone

###### Jobs ######
start esx_service
start esx_mecanojob
start esx_lscustom
start esx_truckerjob
  1. Configure the voice, in gcphone/html/static/config/config.json.
    • Basic use "useWebRTCVocal": false, unless you have a custom RTC server.
	"//": "useWebRTCVocal: false => Appels avec channels de GTA",
	"//": "useWebRTCVocal: true  => Appels avec WebRTC",
	"useWebRTCVocal": false,
	"RTCConfig": {
		"iceServers": [{
		"urls": ["turn:gannon.ovh"],
		"username": "jojo",
		"credential": "pass"
		}]
	},
  1. Change the default zoom (not tested)

In gcphone/html/static/config/config.json, add this : "zoom" : "60%",

Or in your html/static/js/app.js search zoom: window.localStorage.gc_zoom || "100%", and replace by zoom: window.localStorage.gc_zoom || "60%",

Now, clear your server cache and maybe your FiveM cache.


For use distress signal (esx_ambulancejob), you need to edit the client.main :
Replace :

function SendDistressSignal()
	local playerPed = PlayerPedId()
	local coords	= GetEntityCoords(playerPed)

	ESX.ShowNotification(_U('distress_sent'))
	TriggerServerEvent('esx_phone:send', 'ambulance', _U('distress_message'), false, {
		x = coords.x,
		y = coords.y,
		z = coords.z
	})
end

By this :

function SendDistressSignal()
	local playerPed = PlayerPedId()
	PedPosition		= GetEntityCoords(playerPed)
	
	local PlayerCoords = { x = PedPosition.x, y = PedPosition.y, z = PedPosition.z }

	ESX.ShowNotification(_U('distress_sent'))

    TriggerServerEvent('esx_addons_gcphone:startCall', 'ambulance', _U('distress_message'), PlayerCoords, {

		PlayerCoords = { x = PedPosition.x, y = PedPosition.y, z = PedPosition.z },
	})
end

For add custom message on phone :

			"display": "Police",
			"icon": "/html/static/img/icons_app/bank.png",
			"subMenu": [
				{
					"title": "Envoyer un message",
					"eventName": "esx_addons_gcphone:call",
					"type": {
						"number": "police"
					}
				},
				{
					"title": "Appeler le standard",
					"eventName": "gcphone:autoCallNumber",
					"type": {
						"number": "911"
					}
				},
				{
					"title": "Signaler un vol",
					"eventName": "esx_addons_gcphone:call",
					"type": {
						"number": "police",
						"message": "Vol en cours, merci de venir au plus vite !"
					}
				},
				{
					"title": "Signaler une agression",
					"eventName": "esx_addons_gcphone:call",
					"type": {
						"number": "police",
						"message": "Victime d'agression"
					}
				}
			]

If you have a whitescreen GC phone this is why (Zap Hosting):

  • DO NOT RUN the SQL file.
  • Load SQL File -> Run Query (Play button in Heidi)

Other White Screen :

Problem 1

The problem happened to be that gcphone was in ESX folder with esx_addons_gcphone. Moved gcphone to main resources folder and everything works fine.

Problem 2

You need to start gcphone and esx_addons_gcphone BEFORE all addons jobs :
gcphone => in “server-data/resources/”
esx_addons_gcphone => in “server-data/resources/[ESX]”

start gcphone

###### Jobs ######
start esx_service
start esx_mecanojob
start esx_lscustom
start esx_truckerjob
1 Like

@Fourthbeam for the coordinates, check this pull requests : https://github.com/BTNGaming/btn_gcphone/pull/11

1 Like

Alright couldu maybe take a look at it, and see if u notice something wrong? I followed the guide and stil l get this error

Error loading script server/server.lua in resource gcphone: server/server.lua:11: attempt to index a nil value (global ‘ESX’)
stack traceback:
server/server.lua:11: in main chunk
Failed to load script server/server.lua.gcphone.zip (1.6 MB)

You have duplicates. And you have not taken the proposed tutorial. Clean up your files and resume the tutorial

What do u mean by duplicates? :confused:

Look :

Use a clean version of this file to start on a good basis. Similarly for the client files.

Did not notice that mb, couldu take a look at this one over here i followed the exact tutorial still it gives me the same error, replaced it with new files and, i cleared the cache and restarted the server! I am not getting it. :confused: gcphone.zip (1.6 MB)

what exactly do i need to do, i’m looking at that pull request ? sorry, im not a coder, this is pretty mindblowing. Still no notifications for emergency calls @HalCroves