Note : Add line in qb-phone/main/server.lua
qb-phone:server:sendNewEventMail in this event
TriggerClientEvent('qb-phone:client:NewMailNotify', Player.PlayerData.source, mailData)
Like This
local Player = QBCore.Functions.GetPlayerByCitizenId(citizenid)
if mailData.button == nil then
MySQL.insert('INSERT INTO player_mails (`citizenid`, `sender`, `subject`, `message`, `mailid`, `read`) VALUES (?, ?, ?, ?, ?, ?)', { citizenid, mailData.sender, mailData.subject, mailData.message, GenerateMailId(), 0 })
else
MySQL.insert('INSERT INTO player_mails (`citizenid`, `sender`, `subject`, `message`, `mailid`, `read`, `button`) VALUES (?, ?, ?, ?, ?, ?, ?)', { citizenid, mailData.sender, mailData.subject, mailData.message, GenerateMailId(), 0, json.encode(mailData.button) })
end
TriggerClientEvent('qb-phone:client:NewMailNotify', Player.PlayerData.source, mailData)
SetTimeout(200, function()
local mails = MySQL.query.await('SELECT * FROM player_mails WHERE citizenid = ? ORDER BY `date` ASC', { citizenid })
if mails[1] ~= nil then
for k, _ in pairs(mails) do
if mails[k].button ~= nil then
mails[k].button = json.decode(mails[k].button)
end
end
end
TriggerClientEvent('qb-phone:client:UpdateMails', Player.PlayerData.source, mails)
end)
end)

