OnPlayerJoinRequest
May this player join? Asked before they are anyone on the server.
Comes after the server’s own checks, for every join - first when the player’s launcher looks at the server (join.launcher is
true: their game has not started, and a refusal is a box in the launcher), then when their game joins (false). A trip between the
levels of this server is not asked again.
Return true to let them in, or false and the message they read to refuse; return nothing to answer later with AnswerPlayerJoin -
from a web request’s or a database’s callback - within 15 seconds, after which the join is refused (a whitelist that cannot check
stays shut). An error in the callback refuses the join too.
Nothing is known of the player yet: no function that takes a player id applies, and they may never actually join. join.name is their
own word, not proof of an account.
| Field | What it is |
|---|---|
name |
the name they join under |
uid |
the id GetPlayerUid will give for them, "" when their game sent none |
discord |
their Discord user id, checked - see GetPlayerDiscordId; nil when they have none here |
discordName |
their Discord user name at their sign-in, nil without discord |
discordProblem |
why a Discord account they sent did not hold, for the log (nil when it did, or none came) |
steamId |
their SteamID64 as their game said it (unverified), nil when none |
address |
the IP address they connect from |
launcher |
true at the launcher’s ask, false at the game’s join |
Syntax
Section titled “Syntax”function OnPlayerJoinRequest(ask, join) -- ...end| Parameter | Type | |
|---|---|---|
ask |
number | this question, for AnswerPlayerJoin |
join |
table | who is asking - the fields below |
Example
Section titled “Example”local allowed = { ["123456789012345678"] = true } -- Discord ids
function OnGameModeInit() UseDiscordIdentity(true)end
function OnPlayerJoinRequest(ask, join) if join.discord == nil then return false, "Sign in with Discord in the KCD:MP launcher's Options, then join again." end if not allowed[join.discord] then return false, "You are not on this server's list." end return trueendSee also
Section titled “See also”AnswerPlayerJoin · UseDiscordIdentity · GetDiscordMemberRoles · OnPlayerConnect · the Joins and Discord group of the index
