Skip to content

GetPlayerDiscovery

The record of what the player discovered, ready to save.

A table with the level it is of, a block for every kind the server holds - places, reading, ui - and capable, the list of kinds the player’s game can read and write (empty until its first report). A kind with nothing reported or set - or one forgotten (ForgetPlayerDiscovery) - is absent, so test for it: if record.places then. A block is { format, data, bytes, updated }: data is the base64 text to save, format the version of its layout (1 today; save it with the data), bytes the size of what the text holds and updated when the record of that kind last changed, in seconds since 1970. The reading block is global: it is there whatever the level.

A player who exists always has a record, empty if nothing was reported or set yet; read it again after the player’s game has reported (OnPlayerDiscoveryChange, IsPlayerDiscoveryKnown) and not before.

GetPlayerDiscovery(pid [, level])
Parameter Type
pid number the player
level string | nil the level to read (the server’s level when left out); reading answers whatever the level (optional)

table | nil - the record; nil when there is no such player

local record = GetPlayerDiscovery(pid)
if record and record.places then
db:Execute("UPDATE maps SET places = @d WHERE player_id = @p", { d = record.places.data, p = accountId })
end

SetPlayerDiscovery · OnPlayerDiscoveryChange · IsPlayerDiscoveryKnown · the Discovery - the map and the places a player found group of the index