Service

The service module is one of the most important dependencies in the SimpleAdmin system. It hosts a lot of the primitive functions that SimpleAdmin uses to run. Below you can view a list of functions and properties in the service dependency.

This is a metatable. If you try to index something that isn't already in the table, it will invoke and return the value ofgame:GetService(key).

Properties

Property

Description

<table> Instances

Instances that have been created by SimpleAdmin

<table> Permissions

Loaded with all permission data

<table> AdminLevels

Used for easily retrieving permission level by it's respective title.

<table> PlayerWrappers

Cached player wrappers so that we save memory and for comparisons.

Service.Split

<array> Service.Split(<string> String, <string> Deliminator)

Splits String into an array by Deliminator and returns it.

Service.GetLevelTitle

<string> Service.GetLevelTitle(<Int> Level)

Takes the provided Level and returns the matching title from Service.AdminLevels.

Service.New

<Instance> Service.New(<String> Class, <Dictionary> Properties)

Creates a new instance and appends the provided properties.

Service.GenerateGuid

<String> Service.GenerateGuid()

Directly invokes HttpService.GenerateGUID

Service.CopyTable

<Table> Service.CopyTable(<Table> Tbl)

Creates an exact copy of Tbl while voiding the previous reference.

Service.StartsWith

<Boolean> Service.StartsWith(<String> String, <String> Compare)

Returns whether or not String starts with Compare.

Service.FindPlayer

<Instance> Service.FindPlayer(<String> Name)

Finds the first player who's name starts with Name.

Service.FindTeam

<Instance> Service.FindTeam(<String> Name)

Finds the first team who's name starts with Name.

Service.TableFind

<Variant> Service.TableFind(<Table> Tbl, <String | Function> Compare)

If Compare is not a function, table.find will be directly invoked and returned. If Compare is a function, it will be called with each index in the table passed until Compare returns true.

Service.GetLength

<Integer> Service.GetLength(<Table> Table)

Iterates through Table and increments an integer on each iteration. Returns the incremented integer. Allows you to get the length of a dictionary.

Service.GetPlayers

<Table> Service.GetPlayers(<Table> Exclude, <Boolean> Wrapper)

Invokes Players.GetPlayers, removes any players present in Exclude , and applies their wrapper if Wrapper is true.

Service.PlayerWrapper

<Table> Service.PlayerWrapper(<Instance> Player)

Returns Player's corresponding wrapper. The wrapper is documented here.

Service.BanUser

<void> Service.BanUser(<Integer> UserId, <String> Reason, <String> Moderator)

Bans UserId from the game with Reason.

Service.SetPermissionLevel

<void> Service.SetPermissionLevel(<Instance> Player, <Integer> Level, <Boolean> Save)

Sets Player's permission level to Level and saves only if Save is true.

Service.IsValidSoundId

<Boolean> Service.IsValidSoundId(<Integer> SoundId)

Returns whether or not SoundId is a valid Roblox sound asset.

Service.FilterText

<String> Service.FilterText(<String> Text, <Integer> From, <Integer> To)

Filters Text from From to To.

Service.GetGlobalPermissionLevel

<Integer> Service.GetGlobalPermissionLevel(<Instance> Player)

Retrieves Player's permission level directly from the DataStore regardless of cached value.

Service.GetPermissionLevel

<Integer> Service.GetPermissionLevel(<Instance> Player)

Retrieves Player's cached permission level. If there is no cached value present, GetGlobalPermissionLevel will be invoked and it will be grabbed from the DataStore.

Service.ResolveToUserId

<Table> Service.ResolveToUserId(<String | Integer> Query)

-- Examples:
local PlayerData = Service.ResolveToUserId(1)
print(PlayerData.Username, PlayerData.UserId) -- ROBLOX, 1

local PlayerData = Service.ResolveToUserId("ROBLOX")
print(PlayerData.Username, PlayerData.UserId) -- ROBLOX, 1

Takes a UserId or Username and will attempt to grab the player's username and userid from it.

Last updated

Was this helpful?