Events and state
Server events
The server events fx-phone fires for other resources, and the transport events it keeps for itself.
fx-phone fires three local server events. Listen with AddEventHandler in a server script. They are not net events: a client cannot trigger them.
| Event | Arguments | When |
|---|---|---|
fx-phone:server:simIssued |
{ iccid, number, identifier, kind, registered } |
A SIM was created: bought in a shop, given as a starter SIM, or made with IssueSim |
fx-phone:server:simBlocked |
{ iccid, number, reason } |
A SIM was blocked, from the admin tablet or with BlockSim |
fx-phone:server:medicalRecordAdded |
identifier, record |
A medical record was added, by a medic on the phone or with AddMedicalRecord |
luaAddEventHandler('fx-phone:server:simIssued', function(sim)
print(('SIM %s issued with number %s'):format(sim.iccid, sim.number))
end)
AddEventHandler('fx-phone:server:medicalRecordAdded', function(identifier, record)
print(identifier, record.kind, record.title)
end)
- In
simIssued,kindis'physical'or'esim', andidentifierisnilfor a prepaid SIM that was issued without an owner. - In
medicalRecordAdded,recordis{ id, kind, title, details, doctor, facility, severity, cost, data, untilAt, at }.
The exports are described in SIM (server) and Health (server).
#Acting before something happens
To stop a message, a call, a transfer or a post before it happens, add a check. See Checks. To see what happened afterwards, use the logs. See Logging.
#Internal events
The net events fx-phone:rpc:req, fx-phone:rpc:res, fx-phone:rpc:part, fx-phone:push and fx-phone:push:client are the transport between the client and the server. Every request on them is rate-limited and validated on the server. Do not trigger them.
fx-phone:admin:open, fx-phone:prop:remove, fx-phone:camera:tune:ask and fx-phone:camera:tune:save are net events the phone's own client sends. They are checked on the server and are not an API.
Call audio has no events of its own: the server puts both parties into a voice channel itself. See Voice.