Tutorial For GCPhone with call and job message...other

phone
esx_phone
gcphone
call

#164
  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('esx_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


#165

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


#166

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


#167
  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


#168

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.


#169

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


#170

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~")

#171

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”


#172

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:


#173

Still have police in messages


#174

Send pictures and more informations …


#175

I mean this

change police in messages on e.g LSPD


#176

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


#177

Okay no problem :slight_smile: thanks anyway


#178

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:


#179

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


#180

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


#181

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


#183

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


#184

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 ?