State Bags & Events

5M Phone uses FiveM Synchronized State Bags on player entities for zero-latency UI reflection and client state monitoring.


Synchronized State Bags

Available on LocalPlayer.state (client) and Player(source).state (server):

State BagTypeDescription
phoneOpenbooleanTrue when the full phone screen is open
phoneNumberstringEquipped SIM phone number (e.g. 5551234567)
phoneNamestringDisplay name of the handset
flashlightbooleanTorch on/off state
phoneLandscapebooleanWhether phone is rotated in landscape
phoneVariationnumberCase/model variation index
speakerphonebooleanCall speakerphone toggle
mutedCallbooleanCall microphone mute toggle
onCallWithnumberServer source ID of other person on call
callAnsweredbooleanTrue once active call is picked up
instapicIsLivebooleanTrue when broadcasting live on Insta

Example State Bag Listener

Lua
AddStateBagChangeHandler('phoneOpen', nil, function(bagName, key, value, _unused, replicated)
    local ply = GetPlayerFromStateBagName(bagName)
    if ply and ply == PlayerId() then
        if value then
            -- Play custom phone holding animation
        else
            -- Stop animation
        end
    end
end)

Client Network Events

Lua
RegisterNetEvent('5m_phone:phoneToggled', function(open) end)
RegisterNetEvent('5m_phone:numberChanged', function(newNumber) end)
RegisterNetEvent('5m_phone:setOnScreen', function(onScreen) end)
RegisterNetEvent('5m_phone:settingsUpdated', function(newSettings) end)
RegisterNetEvent('5m_phone:phoneDied', function() end)
RegisterNetEvent('5m_phone:birdy:newPost', function(post) end)
RegisterNetEvent('5m_phone:instapic:newPost', function(post) end)
RegisterNetEvent('5m_phone:messages:messageSent', function(data) end)
RegisterNetEvent('5m_phone:darkchat:newMessage', function(data) end)
RegisterNetEvent('5m_phone:callAnswered', function(data) end)
RegisterNetEvent('5m_phone:callEnded', function(data) end)

Server Network Events

Lua
RegisterNetEvent('5m_phone:numberChanged', function(source, newNumber) end)
RegisterNetEvent('5m_phone:factoryReset', function(source, phoneNumber) end)
RegisterNetEvent('5m_phone:messages:messageSent', function(data) end)
RegisterNetEvent('5m_phone:newCall', function(data) end)
RegisterNetEvent('5m_phone:callAnswered', function(data) end)
RegisterNetEvent('5m_phone:callEnded', function(data) end)
RegisterNetEvent('5m_phone:birdy:newPost', function(post) end)
RegisterNetEvent('5m_phone:instapic:newPost', function(post) end)
RegisterNetEvent('5m_phone:darkchat:newMessage', function(data) end)
RegisterNetEvent('5m_phone:mail:mailSent', function(data) end)
RegisterNetEvent('5m_phone:onAddTransaction', function(data) end)