Hello. How can I make phone as a item to buy and then use it with that item in inventory .
client.lua
ESX.TriggerServerCallback(‘phone:getItemAmount’, function(qtty)
if qtty > 0 then
–openphone–
end
end, ‘phone’)
server.lua
ESX.RegisterServerCallback(‘phone:getItemAmount’, function(source, cb, item)
local xPlayer = ESX.GetPlayerFromId(source)
local qtty = xPlayer.getInventoryItem(item).count
print("phone qtty: " … qtty)
cb(qtty)
end)
Error parsing script server/server.lua in resource gcphone: server/server.lua:25: unexpected symbol near ‘<\226>’
Failed to load script server/server.lua.
or
‘)’ expected near ‘<\226>’
or
Error loading script server/server.lua in resource gcphone: server/server.lua:17: attempt to index a nil value (global ‘ESX’)
stack traceback:
cfx> server/server.lua:17: in main chunk
Can u send it correctly or its only my error
Hi all.
Is it possible to create an app like “bank” but for the police.
Like and app icon in the phone home when we could call or message the police.
I know we can call the police from favoris in the phone but from the home would be much better
I have the gcphone and i were wondering what dimensions the screen itself shall be at 100%, i tried getting a custom ¨phone¨ template but its to big and its taking time to get it exact with the top bar aswell, help appreciated
How to Send an anonymous message ?
- 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
Hi,
The shells must be 1000x500 px, The screen area is center size 800 * 400 (For me you have to count the empty edges).
Humm, it’s possible (i thinks), you can edit the js files
=> static/js/app.js
=> static/config/config.json
- script: no errors just not working. Problem with DB ?
- 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
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.
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~")
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
Still have police in messages
Send pictures and more informations …
I will check later, it’s a bit more complex than expected
Okay no problem thanks anyway