- 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);
- 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)
- 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