SetPlayerLoadingHandover
Gives a player’s loading page data of the mode’s while the level loads - a table, a text, a number or a boolean.
The loading screen is the first thing a player sees, long before the mode can send anything through a page: the level is
still loading and the player’s game is busy with it. This is the one call that reaches the game during the load - it is
sent at once, not at the end of the tick - so a loading page can greet the player by name, show the server’s rules or
tell what the round is, and the player’s game keeps the data for the interface’s loading page until the session ends. Call
it in OnPlayerConnect; a reload runs that again for every player, so the data is sent again.
data is written as JSON by JsonEncode, under the same rules, and is at most 16384 bytes of JSON. The answer is
true when it was handed to the player’s game; false and the reason otherwise: "no such player", "no data" (the
value is nil), "too big", "reserved key" (a table with a __kcdmp key at the top) or what JsonEncode says about
a value it cannot write. What comes back from the player’s game is never part of this: the handover goes one way.
Syntax
Section titled “Syntax”SetPlayerLoadingHandover(pid, data)| Parameter | Type | |
|---|---|---|
pid |
number | the player |
data |
table | string | number | boolean | the value the loading page receives |
Returns
Section titled “Returns”true, or false, reason - the reason as a person reads it ("too big", "no data" …)
Example
Section titled “Example”function OnPlayerConnect(pid) local ok, why = SetPlayerLoadingHandover(pid, { name = GetPlayerName(pid), motd = "Welcome to the Kuttenberg Inn", round = currentRound, }) if not ok then Log("handover for " .. GetPlayerName(pid) .. ": " .. why) endendSee also
Section titled “See also”ClosePlayerLoadingScreen · JsonEncode · OnPlayerConnect · the Web interface group of the index
