Buy phone

funny!!! i was just asking

1 Like

You can accomplish this in just two steps:
1- Put the phone in the DataBase as an item.
2- In the resource of the mobile phone check when the player press the key to open the mobile phone and check in the DataBase if it has this ITEM.

Hope this helps

This is the example I sent up.

if IsControlJustReleased(0, Keys['F1']) then
				ESX.TriggerServerCallback('esx_phone:getItemAmount', function(qtty)
					if not ESX.UI.Menu.IsOpen('phone', GetCurrentResourceName(), 'main') and qtty > 0 then
						ESX.UI.Menu.CloseAll()
						ESX.UI.Menu.Open('phone', GetCurrentResourceName(), 'main')
					else
						ESX.ShowNotification("Vous n'avez pas de téléphone.")
					end
				end, 'phone')
			end
ESX.RegisterServerCallback('esx_phone:getItemAmount', function(source, cb, item)
    local xPlayer = ESX.GetPlayerFromId(source)
    local qtty = xPlayer.getInventoryItem(item).count
	print("phone qtty: " .. qtty)
    cb(qtty)
end)

Remember, this is just an example, and it will only work with ESX, but you can adapt to anything else!

5 Likes

so i could do the same with esx_phone3 aswell?

yes the example work for that phone!

tyvm have a nice day

1 Like

where do i put the code cant get it to work

When I don’t have the phone i still do receive the text messages any way to disable that to?

Do it before every message is received

So how can I create the ability, that someone can check if the target has the phone.
The blocade of receiving messages destroy changes such as the billing. I also would like to add the information that the contact is out of range.

For the call

RegisterNetEvent('esx_phone:incomingCall')
AddEventHandler('esx_phone:incomingCall', function(target, channel, number)
  ESX.TriggerServerCallback('esx_phone:getItemAmount', function(qtty)
    if qtty > 0 then
      if not OnCall then

        ESX.UI.Menu.Open('phone', GetCurrentResourceName(), 'main')

        SendNUIMessage({
          incomingCall = true,
          target       = target,
          channel      = channel,
          number       = number,
        })

      end
    end
  end, 'phone')
end)

@JaroSound Make the same for the message event

This event:

RegisterNetEvent('esx_phone:onMessage')
AddEventHandler('esx_phone:onMessage', function(phoneNumber, message, position, anon, job, dispatchRequestId, idnum)

Wat?

If I do it this way then when someone calls the target does not get a notification but the caller is charged billing until he uses the phone again. That’s why I would like to do it my way but I do not know how.

Sorry my bad English.

where should i do this in what File?

How do i do this with gcphone?

2 Likes

Hello … I appreciate your help, it is very useful, but when I put the code it works but the animation of the phone is locked to ped, someone knows how to solve? Thank you very much at all

Trying to get this working with gcphone but no luck.

Help me pls =(

Error running system event handling function for resource esx_phone3: citizen:/scripting/lua/scheduler.lua:41: Failed to execute thread: @esx_phone3/server/main.lua:313: attempt to index a nil value (field ‘?’)
stack traceback:
@esx_phone3/server/main.lua:313: in upvalue ‘handler’
citizen:/scripting/lua/scheduler.lua:219: in function citizen:/scripting/lua/scheduler.lua:218
stack traceback:
[C]: in function ‘error’
citizen:/scripting/lua/scheduler.lua:41: in field ‘CreateThreadNow’
citizen:/scripting/lua/scheduler.lua:218: in function citizen:/scripting/lua/scheduler.lua:182
Sending heartbeat to live-internal.fivem.net:30110

I have been trying to fix this for days, the ped use the phone more does not return the normal position, remains with the animation, the purchase this normal just does not remove it from the ear more … lol

I whould really love this to built in the gcphone.
Can anyone help me with that.

I’m have no clue where to place the code.

https://github.com/Kreddyy/esx_phonestore?files=1 ^^

Cant use

Here :smiley: :buy GCPhone

1 Like