RegisterServerEvent("crew:onPlayerLoaded")
AddEventHandler("crew:onPlayerLoaded",function(a)
local b=tonumber(a)
local c=getPlayerID(b)
getOrGeneratePhoneNumber(b,c,function(d)
TriggerClientEvent("crew:updatePhone",b,d,getContacts(c),getMessages(c))
sendHistoriqueCall(b,d)
end)
getUserTwitterAccount(b,c)
end)
function getNumberPhone(a)
local b=MySQL.Sync.fetchScalar("SELECT users.phone_number FROM users WHERE users.identifier = @identifier",{["@identifier"]=a})
if b~=nil then
return b
end;
return nil
end
MySQL.ready(function ()
MySQL.Async.execute('DELETE FROM phone_messages WHERE transmitter = \'police\'')
MySQL.Async.execute('DELETE FROM phone_messages WHERE transmitter = \'ambulance\'')
MySQL.Async.execute('DELETE FROM phone_messages WHERE transmitter = \'news\'')
end)
--- Phone Number Style Config.lua FourDigit = true then generate 4 number else generate ####### number
function getPhoneRandomNumber()
if Config.FourDigit then
local numBase = math.random(1000,9999)
num = string.format("%04d", numBase )
else
local numBase = math.random(1000000,9999999)
num = string.format("%07d", numBase)
end
return num
end