Skip to main content

OfflineSaveSlots

This item only works when running on the server. Server

A player's save slots opened without that player, and the obligation to close them again.

Wraps a borrowed PlayerDataStoreHandle and a HasSaveSlotsDataStore built over it, so admin tooling can act on someone who is not in this server. Destroying this releases the session -- see PlayerDataStoreHandle for why that matters, and SaveSlotService.PromiseOfflineSaveSlots for how one is opened.

WARNING

Opening this steals the player's session lock, which kicks them from wherever they were playing. It is for admin tooling acting on an absent player; never open one for a player who is in this server -- use their bound HasSaveSlots instead, or you will be writing to a second, stale copy of their data.

The value objects backing the slot state are detached rather than replicated: there is no player to replicate to, and the slot roster stays unparented for the same reason.

local offline = saveSlotService:PromiseOfflineSaveSlots(userId):Yield()
local slots = offline:GetSlotsDataStore()
print(slots:GetSlotList())
offline:Destroy()

Functions​

new​

OfflineSaveSlots.new() → OfflineSaveSlots

Types

​

interface OfflineSaveSlotsOptions {
SharedDataStoreService: any--

SaveSlotSharedDataStoreService

MaxSlotCount: number
CodeGenerator: SaveSlotCodeUtils.CodeGenerator?
UserId: number?
UserName: string?
}

Builds the slot system over a borrowed datastore handle. Takes ownership of the handle: destroying this destroys it.

isOfflineSaveSlots​

OfflineSaveSlots.isOfflineSaveSlots(value: any) → boolean

Returns whether the value is an OfflineSaveSlots.

PromiseSlotsLoaded​

OfflineSaveSlots.PromiseSlotsLoaded(self: OfflineSaveSlots) → Promise

Resolves once the slots have loaded from the datastore.

GetSlotsDataStore​

OfflineSaveSlots.GetSlotsDataStore(self: OfflineSaveSlots) → HasSaveSlotsDataStore

Returns the slot system, a HasSaveSlotsDataStore. Valid until this is destroyed.

Destroy​

OfflineSaveSlots.Destroy(self: OfflineSaveSlots) → ()

Tears the slot system down and releases the borrowed session, which saves and unlocks it so the player can rejoin. Destroying twice is safe.

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "Builds the slot system over a borrowed datastore handle. Takes ownership of the handle: destroying\nthis destroys it.",
            "params": [
                {
                    "name": "handle",
                    "desc": "",
                    "lua_type": "PlayerDataStoreHandle"
                },
                {
                    "name": "options",
                    "desc": "",
                    "lua_type": "OfflineSaveSlotsOptions"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "OfflineSaveSlots"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 77,
                "path": "src/saveslot/src/Server/OfflineSaveSlots.lua"
            }
        },
        {
            "name": "isOfflineSaveSlots",
            "desc": "Returns whether the value is an OfflineSaveSlots.",
            "params": [
                {
                    "name": "value",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 120,
                "path": "src/saveslot/src/Server/OfflineSaveSlots.lua"
            }
        },
        {
            "name": "PromiseSlotsLoaded",
            "desc": "Resolves once the slots have loaded from the datastore.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "OfflineSaveSlots"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 129,
                "path": "src/saveslot/src/Server/OfflineSaveSlots.lua"
            }
        },
        {
            "name": "GetSlotsDataStore",
            "desc": "Returns the slot system, a [HasSaveSlotsDataStore]. Valid until this is destroyed.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "OfflineSaveSlots"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "HasSaveSlotsDataStore"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 138,
                "path": "src/saveslot/src/Server/OfflineSaveSlots.lua"
            }
        },
        {
            "name": "Destroy",
            "desc": "Tears the slot system down and releases the borrowed session, which saves and unlocks it so the\nplayer can rejoin. Destroying twice is safe.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "OfflineSaveSlots"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 150,
                "path": "src/saveslot/src/Server/OfflineSaveSlots.lua"
            }
        }
    ],
    "properties": [],
    "types": [
        {
            "name": "OfflineSaveSlotsOptions",
            "desc": "",
            "fields": [
                {
                    "name": "SharedDataStoreService",
                    "lua_type": "any",
                    "desc": "SaveSlotSharedDataStoreService"
                },
                {
                    "name": "MaxSlotCount",
                    "lua_type": "number",
                    "desc": ""
                },
                {
                    "name": "CodeGenerator",
                    "lua_type": "SaveSlotCodeUtils.CodeGenerator?",
                    "desc": ""
                },
                {
                    "name": "UserId",
                    "lua_type": "number?",
                    "desc": ""
                },
                {
                    "name": "UserName",
                    "lua_type": "string?",
                    "desc": ""
                }
            ],
            "source": {
                "line": 48,
                "path": "src/saveslot/src/Server/OfflineSaveSlots.lua"
            }
        }
    ],
    "name": "OfflineSaveSlots",
    "desc": "A player's save slots opened without that player, and the obligation to close them again.\n\nWraps a borrowed [PlayerDataStoreHandle] and a [HasSaveSlotsDataStore] built over it, so admin\ntooling can act on someone who is not in this server. Destroying this releases the session -- see\n[PlayerDataStoreHandle] for why that matters, and [SaveSlotService.PromiseOfflineSaveSlots] for\nhow one is opened.\n\n:::warning\nOpening this **steals the player's session lock**, which kicks them from wherever they were\nplaying. It is for admin tooling acting on an absent player; never open one for a player who is\nin this server -- use their bound [HasSaveSlots] instead, or you will be writing to a second,\nstale copy of their data.\n:::\n\nThe value objects backing the slot state are detached rather than replicated: there is no player\nto replicate to, and the slot roster stays unparented for the same reason.\n\n```lua\nlocal offline = saveSlotService:PromiseOfflineSaveSlots(userId):Yield()\nlocal slots = offline:GetSlotsDataStore()\nprint(slots:GetSlotList())\noffline:Destroy()\n```",
    "realm": [
        "Server"
    ],
    "source": {
        "line": 30,
        "path": "src/saveslot/src/Server/OfflineSaveSlots.lua"
    }
}