Ok so my solution to this problem is
That is my client side after in some data.current.value
local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
if closestPlayer ~= -1 and closestDistance < 3 then
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'set_vehicle_owner_sell_amount',
{
title = _U('invoice_amount')
},
function(data2, menu2)
local amount = tonumber(data2.value) --data2.current.value ?
if amount == nil then
ESX.ShowNotification(_U('invalid_amount'))
else
menu2.close()
local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
local targetSrc = GetPlayerServerId(closestPlayer)
if closestPlayer == -1 or closestDistance > 3.0 then
ESX.ShowNotification(_U('no_players'))
else
TriggerServerEvent('esx_vehicleshop:payforcar', amount, targetSrc)
end
end
end, function(data2, menu2)
menu2.close()
end)
else
ESX.ShowNotification(_U('no_players'))
end
That is my client side i mean other event for a second player
RegisterNetEvent(‘esx_vehicleshop:OpenBillRequest’)
AddEventHandler(‘esx_vehicleshop:OpenBillRequest’, function(amount,billingPlayer)
local elements = {
{label = 'Accept', value = 'accept'},
{label = 'Decline', value = 'decline'}
}
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'GarageBilling',
{
title = "Bill from"..billingPlayer..": "..amount.."$",
align = 'center',
elements = elements
},
function(data, menu)
if data.current.value == 'accept' then
TriggerServerEvent('esx_vehicleshop:payementproceced', amount)
ESX.ShowNotification("You paied a "..amount.."$ bill")
elseif data.current.value == 'decline' then
menu.close()
end
menu.close()
end, function(data, menu)
menu.close()
end)
end)
And server side
RegisterNetEvent(‘esx_vehicleshop:payforcar’)
AddEventHandler(‘esx_vehicleshop:payforcar’, function (amount, targetSrc)
local billingPlayer = source
local billedPlayer = targetSrc
local amount = amount
--Open the menu for the player who needs to pay the bill
TriggerClientEvent('esx_vehicleshop:OpenBillRequest',targetSrc, amount, billingPlayer)
end)
RegisterNetEvent(‘esx_vehicleshop:payementproceced’)
AddEventHandler(‘esx_vehicleshop:payementproceced’,function (amount)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
xPlayer.removeMoney(amount)
end)
That is my i know that you need to work a bit with a noticifactions if player decline or accept the bill but for now you need to do this on your own. I might edit this later