# API Functions

{% hint style="warning" %}
Example code currently not implemented.
{% endhint %}

## Service

{% tabs %}
{% tab title="Info" %}

```lua
require(API.Functions.Service):ForceCheckIn(Target, Type, overrideGamepass, Num)
```

Tries checking Target into a room. Ignores game pass requirements of the room type.

Arguments:

**Player** `Target`

**String, Room Type** `Type`

**Bool, optional** `overrideGamepass`when set to true, game pass requirements of the room type are ignored.

**Room Number, optional** `Num`

Returns:

`Table` of format `{true, Instance Room}` or `{false, string errorCode}`

Room is a folder containing all information about the given room. See Database section for more information.
{% endtab %}

{% tab title="Error Codes" %}
`alreadyCheckedIn`

Given when the Player `Target` is already checked in.

`noRoomAvailable`

Given when no room is available.

`noGamepass`

Given when the required game pass is not owned by Player `Target`.

`insufficientArgs`

Given when the function is called with insufficient arguments.
{% endtab %}

{% tab title="Example" %}

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Info" %}
`require(API.Functions.Service):ForceCheckOut(Target)`

Tries checking out Player `Target`

Arguments:

Player `Target`

Returns:

Bool `Success`
{% endtab %}

{% tab title="Example" %}

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Info" %}

```lua
API.Functions.Service.CheckedIn.Event
```

BindableEvent fired when a player is checked in

Arguments:

Player `Target` that was checked in

Player or String `Employee`

Room `Room`

{% hint style="danger" %}
When the player is checked out by the server (for example using ForceCheckOut or on leave), Employee is set to the string 'Server'\
When a player checks out using the self check out, Employee is set to the string 'Self'
{% endhint %}
{% endtab %}

{% tab title="Example" %}

```lua
API.Functions.Service.CheckedIn.Event:Connect(function(Target, Employee, Room)
    if typeof(Employee) == "Player" then
        print(Target.Name + " was checked in by " + Employee.Name)
        print("They now have room " + Room.Number.Value)
    end
end)
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Info" %}

```lua
API.Functions.Service.CheckedOut.Event
```

BindableEvent fired when a player is checked out

Arguments:

Player `Target` that was checked out

Player or String `Employee`

Room `Room` that the player was checked into

{% hint style="danger" %}
When the player is checked out by the server (for example using ForceCheckOut or on leave), Employee is set to the string 'Server'\
When a player checks out using the self check out, Employee is set to the string 'Self'
{% endhint %}
{% endtab %}

{% tab title="Example" %}

```lua
API.Functions.Service.CheckedOut.Event:Connect(function(Target, Employee, Room)
    if typeof(Employee) == "Player" then
        print(Target.Name + " was checked out by " + Employee.Name)
    end
end)
```

{% endtab %}
{% endtabs %}

## Doors

{% tabs %}
{% tab title="Info" %}
`require(API.Services.Doors):OpenPlyr(Player, Door)`

Sends a request to open a door on behalf of Player `Player`. It will close after the Timer for the specified door has elapsed.

Arguments:

Player `Player`

Instance `Door` model found in CheckMeIn.Doors.Rooms or CheckMeIn.Doors.Custom

Note that the door will only open if `Player` has permission to open it.
{% endtab %}

{% tab title="Example" %}

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Info" %}
`require(API.Services.Doors):Open(Door)`

Opens the specified door. It will close after the Timer for the specified door has elapsed.

Arguments:

Instance `Door` model found in CheckMeIn.Doors.Rooms or CheckMeIn.Doors.Custom
{% endtab %}

{% tab title="Example" %}

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Info" %}
`require(API.Services.Doors):ToggleDnD(Room, newValue)`

Sets the Do not Disturb value for room `Room` to `newValue`.

Arguments:

Instance `Room`

Bool `newValue`
{% endtab %}

{% tab title="Example" %}

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Info" %}
`require(API.Services.Doors):TogglePM(Room, newValue)`

Sets the Private Mode value for room `Room` to `newValue`.

Arguments:

Instance `Room`

Bool `newValue`
{% endtab %}

{% tab title="Example" %}

{% endtab %}
{% endtabs %}

## Room Database

{% hint style="info" %}
In this section, Instance `Room` is referring to the database entry of a room. To learn more about this, refer to the Database page.
{% endhint %}

{% content-ref url="database" %}
[database](https://api.checkmein.cloud/checkmein-4.0/database)
{% endcontent-ref %}

{% tabs %}
{% tab title="Info" %}
`require(API.Services.Database):GetPlayerRoom(Player)`

Finds the room of Player `Player`.

Arguments:

Player `Player`

Returns:

Instance `Room` or `false` if Player is not checked in

Room is a folder containing all information about the given room. See Database section for more information.
{% endtab %}

{% tab title="Example" %}

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Info" %}
`require(API.Services.Database):IsRoommate(Player, Room)`

Checks whether Player `Player` is a roommate of Instance `Room`.

Arguments:

Player `Player`

Instance `Room`

Room is a folder containing all information about the given room. See Database section for more information.

Returns:

Bool `isRoommate`
{% endtab %}

{% tab title="Example" %}

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Info" %}
`require(API.Services.Database):GetAvailableRooms()`

Gets a list of available rooms

Returns:

Table containing a `Room` instance for every available room

Room is a folder containing all information about the given room. See Database section for more information.
{% endtab %}

{% tab title="Example" %}

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Info" %}
`require(API.Services.Database):GetDatabaseEntry(roomDoor)`

Finds the database entry (`Room`) from a room door model

Arguments:

Instance `roomDoor` this has to be a room door model, located in the Rooms folder.

Returns:

Instance `Room` or `false` if the specified room door is not valid.

Room is a folder containing all information about the given room. See Database section for more information.
{% endtab %}

{% tab title="Example" %}

{% endtab %}
{% endtabs %}

## Points System

{% tabs %}
{% tab title="Info" %}
`require(API.Services.Points):AwardPoints(Player, dontRunFunction)`

Awards `Reward` points to Player `Player`. `Reward` can be found in the Enterprise options ModuleScript. If `dontRunFunction` is `true`, the `Function` in the Enterprise options ModuleScript will not be fired afterwards.

Arguments:

Player `Player`

Bool `dontRunFunction` optional
{% endtab %}

{% tab title="Example" %}

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Info" %}

```lua
require(API.Services.Points):GetPoints(Player)
```

Gets the current point value of Player `Player`.
{% endtab %}

{% tab title="Example" %}

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Info" %}
`require(API.Services.Points):SetPoints(Player, Amount, dontRunFunction)`

Sets Player `Player`'s points value to `Amount`. If `dontRunFunction` is `true`, the `Function` in the Enterprise options ModuleScript will not be fired afterwards.

Arguments:

Player `Player`

Bool `dontRunFunction` optional
{% endtab %}

{% tab title="Example" %}

{% endtab %}
{% endtabs %}

## Tutorial State

{% tabs %}
{% tab title="Info" %}
`require(API.Services.Points):SetTutorialState(Player, newValue)`

Sets the tutorial state of Player `Player` to `newValue.`

Arguments:

Player `Player`

Bool `newValue`
{% endtab %}

{% tab title="Example" %}

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Info" %}
`require(API.Services.Points):GetTutorialState(Player)`

Returns the tutorial state of Player `Player`.

Arguments:

Player `Player`

Returns:

Bool `completedTutorial`
{% endtab %}

{% tab title="Example" %}

{% endtab %}
{% endtabs %}

## GroupService Cache

CheckMeIn 4.0 uses http requests to get up-to-date player ranks. These results are then cached by the system to limit the amount of http requests used.&#x20;

{% hint style="info" %}
Cache entries for individual players are removed automatically when they leave the game.
{% endhint %}

{% tabs %}
{% tab title="Info" %}
`require(API.Services.Cache):ClearCache()`

Removes cached calls that returned `false`, meaning players who were not authorized will be checked again after this function runs.

{% hint style="info" %}
ClearCache() is automatically called by the system every 5 minutes.
{% endhint %}
{% endtab %}

{% tab title="Example" %}

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Info" %}
`require(API.Services.Cache):DeleteCache()`

Removes all cached calls, meaning that all players will be checked again, even if they were authorized before.
{% endtab %}

{% tab title="Example" %}

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Info" %}
`require(API.Services.Cache):IsReceptionist(Player)`

Checks whether Player `Player` has receptionist permissions, as set in your `Options` ModuleScript.

Arguments:

Player `Player`

Returns:

Bool `isReceptionist`
{% endtab %}

{% tab title="Example" %}

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Info" %}
`require(API.Services.Cache):IsStaff(Player)`

Checks whether Player `Player` has staff permissions, as set in your `Options` ModuleScript.

Arguments:

Player `Player`

Returns:

Bool `isStaff`
{% endtab %}

{% tab title="Example" %}

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Info" %}
`require(API.Services.Cache):IsAuthorized(Player, customPermissions)`

Checks whether Player `Player` is authorized based on the supplied `customPermissions`. This function can be used to get up-to-date ranks from players. The result will automatically be cached by CheckMeIn.

Arguments:

Player `Player`

Dictionary`customPermissions` see custom permissions tab

Returns:

Bool `isAuthorized`
{% endtab %}

{% tab title="Custom Permissions" %}

```lua
--Custom Permissions syntax
customPermissions = {}
customPermissions.UserIds = {} -- You can enter a list of authorized user ids here.
customPermissions.Group = 1234 -- Group ID
customPermissions.Minimum = 1 -- Minimum rank that gets authorized
customPermissions.RankTable = {1, 2, ..., 255} -- Table of ranks that are authorized
--Please note that you can only use RankTable OR Minimum, not both.
```

{% endtab %}

{% tab title="Example" %}

{% endtab %}
{% endtabs %}
