Skip to content

OnPlayerChooseRegion

Asks which level a player’s game should start on, just before they join.

Comes when a player’s launcher asks, before their game starts, and only on a server with regions, on the main level’s copy of the mode. Answer with AnswerPlayerRegion, now or from a database’s callback, within 2 seconds. After that, or without this callback, they start on the main level.

name is the player’s own word, not proof of an account: use it for where they start, never to log them in. Nothing is known of them yet, so no function that takes a player id applies, and they may never actually join.

function OnPlayerChooseRegion(ask, name, uid)
-- ...
end
Parameter Type
ask number this question, for AnswerPlayerRegion
name string the name they will join under
uid string the id GetPlayerUid will give for them, "" before their first game
function OnPlayerChooseRegion(ask, name, uid)
db:Query("SELECT level FROM players WHERE name = @n", { n = name:lower() }, function(rows, err)
AnswerPlayerRegion(ask, not err and rows[1] and rows[1].level or nil)
end)
end

AnswerPlayerRegion · GetRegions · GetLevel · OnPlayerConnect · the Regions group of the index