[Tutorial] - GCPhone - Adding calls and job messages

  1. Add in your data base :
INSERT INTO `items` (`name`, `label`, `limit`) VALUES  
    ('phone', 'Téléphone', 1)
;
INSERT INTO shops (id, name, item, price) VALUES (98, 'TwentyFourSeven', 'phone', 175), (99, 'RobsLiquor', 'phone', 175), (100, 'LTDgasoline', 'phone', 175);
  1. in client/main.lua, search :
Citizen.CreateThread(function()

        while true do
            Citizen.Wait(0)
            if IsControlJustPressed(1, KeyOpenClose) and GetLastInputMethod( 0 ) then
                TooglePhone()
            end
            if menuIsOpen == true then
                for _, value in ipairs(KeyToucheCloseEvent) do
                    if IsControlJustPressed(1, value.code) then
                        SendNUIMessage({keyUp = value.event})
                    end
                end
            end
        end
end)

And replace by :

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(0)
		if IsControlJustPressed(1, KeyOpenClose) and GetLastInputMethod( 0 ) then
			ESX.TriggerServerCallback('gcphone:getItemAmount', function(qtty)
				if qtty > 0 then
					TooglePhone()
				else
					ESX.ShowNotification("Vous n'avez pas de ~r~téléphone~s~")
				end
			end, 'phone')
		end
		if menuIsOpen == true then
			for _, value in ipairs(KeyToucheCloseEvent) do
				if IsControlJustPressed(1, value.code) then
					SendNUIMessage({keyUp = value.event})
				end
			end
		end
	end
end)
  1. On your server/main.lua add :
ESX = nil

TriggerEvent('esx:getSharedObject', function(obj)
    ESX = obj
end)

ESX.RegisterServerCallback('gcphone:getItemAmount', function(source, cb, item)
    local xPlayer = ESX.GetPlayerFromId(source)
    local qtty = xPlayer.getInventoryItem(item).count
    cb(qtty)
end)

On your phone, you have a application named “Dark Chat”.
You need to create a channel in this application (as if you wanted to add a message), and then you just have to send your message

10 Likes

Hi,

The shells must be 1000x500 px, The screen area is center size 800 * 400 (For me you have to count the empty edges).

image

Humm, it’s possible (i thinks), you can edit the js files
=> static/js/app.js
=> static/config/config.json

1 Like
  1. script: no errors just not working. Problem with DB ?
  2. i mean anonymous message to police etc.

EDIT

ad1

INSERT INTO items VALUES ('109', 'phone', 'telephone', '-1', '0', '1')

#1136 - Column count doesn't match value count at row 1

1 Like

Hummm

Test with this :

INSERT INTO `items` (`name`, `label`, `limit`) VALUES  
    ('phone', 'Téléphone', 1)
;

You can try to add a # in front of the number.

1 Like

okay i add it in manual. Its working but didnt get Notification when i dont have phone

Replace

ShowNotification("Vous n'avez pas de ~r~téléphone~s~")

By :

ESX.ShowNotification("Vous n'avez pas de ~r~téléphone~s~")
1 Like

Yes i already did that. Just fargot to edit message. Anyway thank you. Last question. Can i change number for police etc? like when i’ve get message from LSPD i dont want to see “police” just e.g “LSPD”

You can modify the police number on your jobs and in database or others, but really do not have time to explain everything.

My solution is simply to add a condition in the client/client.lua

Replace :

RegisterNetEvent("gcPhone:receiveMessage")
AddEventHandler("gcPhone:receiveMessage", function(message)
    -- SendNUIMessage({event = 'updateMessages', messages = messages})
    SendNUIMessage({event = 'newMessage', message = message})
    if message.owner == 0 then
        local text = '~o~Nouveau message'
        if ShowNumberNotification == true then
            text = '~o~Nouveau message du ~y~'.. message.transmitter
            for _,contact in pairs(contacts) do
                if contact.number == message.transmitter then
                    text = '~o~Nouveau message de ~g~'.. contact.display
                    break
                end
            end
        end
        SetNotificationTextEntry("STRING")
        AddTextComponentString(text)
        DrawNotification(false, false)
        PlaySound(-1, "Menu_Accept", "Phone_SoundSet_Default", 0, 0, 1)
        Citizen.Wait(300)
        PlaySound(-1, "Menu_Accept", "Phone_SoundSet_Default", 0, 0, 1)
        Citizen.Wait(300)
        PlaySound(-1, "Menu_Accept", "Phone_SoundSet_Default", 0, 0, 1)
    end
end)

By this :

RegisterNetEvent("gcPhone:receiveMessage")
AddEventHandler("gcPhone:receiveMessage", function(message)
    -- SendNUIMessage({event = 'updateMessages', messages = messages})
    SendNUIMessage({event = 'newMessage', message = message})
    if message.owner == 0 then
        local text = '~o~Nouveau message'
        if ShowNumberNotification == true then
			if message.transmitter == "police" then
				text = '~o~Nouveau message de la LSPD'
			else
				text = '~o~Nouveau message du ~y~'.. message.transmitter
			end
            for _,contact in pairs(contacts) do
                if contact.number == message.transmitter then
                    text = '~o~Nouveau message de ~g~'.. contact.display
                    break
                end
            end
        end
        SetNotificationTextEntry("STRING")
        AddTextComponentString(text)
        DrawNotification(false, false)
        PlaySound(-1, "Menu_Accept", "Phone_SoundSet_Default", 0, 0, 1)
        Citizen.Wait(300)
        PlaySound(-1, "Menu_Accept", "Phone_SoundSet_Default", 0, 0, 1)
        Citizen.Wait(300)
        PlaySound(-1, "Menu_Accept", "Phone_SoundSet_Default", 0, 0, 1)
    end
end)

Not tested, because i’m at work :smiley:

Still have police in messages

Send pictures and more informations …

I mean this

change police in messages on e.g LSPD

I will check later, it’s a bit more complex than expected :sweat_smile:

Okay no problem :slight_smile: thanks anyway

hi i have a little problem.
i change “useWebRTCVocal”: true, to false but we dont hear anyone what is the problem ?

sry for my bad english :smiley:

Hi,
False = gcphone use gtav channel calls. For me, you must use esx_voice.

ahhh sry… when i call to other player we cant hear any words

How to accept notification in gcphone ? Or i need individual script with that. I mean i need option(eg. Key “E” or “Y”) to accept the distress message (with GPS) sended by civilian

Now it works but in xxxxxxxxxl size* how i can change that?

Hi,
@Trollna100pro In your phone parameters, you have a option for change the phone size.
@Daniel_Bleak Maybe with https://github.com/vodkhard/vdk_call
@tomteipl Do you have esx_voice ? Do you have any others phone ?