Here's the snippet. It's very simple, it just fetches info about the client and if you want to use this little snippet, just make sure that your values for SUB_PASSPORT STEAM_APP_ID and STEAM_DLC_ID1 are set properly.
// We do all of this on ye olde client object
client
// We store everything in an associated list for easy access later
var/tmp
credentials[] = list(
"byond_member" = FALSE,
"byond_subscriber" = FALSE,
"steam_name" = FALSE,
"steam_id" = FALSE,
"steam_passport" = FALSE,
"steam_dlc_1" = FALSE
)
proc
// We can call this proc to do a full authentication of permission levels
Authenticate()
return BYONDAuthentication() | SteamAuthentication()
// Let's say we want to give BYOND Members and Hub Subscribers the same authentication level
BYONDAuthentication()
credentials["byond_member"] = IsByondMember()
credentials["byond_subscriber"] = CheckPassport(SUB_PASSPORT)
// Either a valid membership or subscription will be considered authenticated
return credentials["byond_member"] || credentials["byond_subscriber"]
// Here we can grab and store values for our various Steam info
SteamAuthentication()
credentials["steam_name"] = GetAPI("steam", "name")
credentials["steam_id"] = GetAPI("steam", "id")
credentials["steam_passport"] = CheckPassport("steam:[STEAM_APP_ID]")
credentials["steam_dlc_1"] = CheckPassport("steam:[STEAM_DLC_ID1]")
// If they don't have their Steam Passport, we consider them not authenticated
return credentials["steam_passport"]
Easy as that. So let's say you have a part of your game that you only want accessible to hub subscribers:
client/New()
..()
Authenticate()
turf/subscriber_gate
Enter(atom/movable/am)
if(istype(am, /mob))
var/mob/m = am
return m.client?.credentials["byond_subscriber"]
// To change this to only allow Steam users, just change the index key!
And there we go. It's as easy as checking this list whenever you need to double check permissions, or update the credentials.