playerUtil
An utility module for working with players.
playerUtil.playerGroupRolePromise(2981707497, 1):andThen(function(groupRole)
print(groupRole)
end):catch(function(defaultGroupRole, errorMessage)
warn(tostring(errorMessage))
end)
Types
PlayerGroupRank
interface
PlayerGroupRank {
Default:
0
}
PlayerGroupRole
interface
PlayerGroupRole {
Default:
"Guest"
}
Functions
playerGroupRankPromise
playerUtil.
playerGroupRankPromise
(
playerUserId:
number
,
groupId:
number
) →
Promise
<
number
>
Returns a promise which is resolved with the group rank of the player in the given group. If the group rank couldn't be retrieved, then the promise will reject with [DefaultGroupRank], along with the error message.
playerUtil.playerGroupRankPromise(2981707497, 1):andThen(function(groupRank)
print(groupRank)
end):catch(function(defaultGroupRank, errorMessage)
print(groupRank, tostring(errorMessage))
end)
playerIsFriendsWithPromise
A promisified wrapper over Player:IsFriendsWith.
If the promise rejects, it will reject with (isFriends
as false
), along with the error message.
playerUtil.playerIsFriendsWithPromise(2981707497, 27842645):andThen(function(isFriends)
print(isFriends)
end):catch(function(isFriends, errorMessage)
print(isFriends, tostring(errorMessage))
end)
playerFriendsOnlinePromise
A promisified wrapper over Player:GetFriendsOnline.
If the promise rejects, it will reject with (friends
as an empty array i.e {}
), along with the error message.
playerUtil.playerFriendsOnlinePromise(player, 15):andThen(function(friends)
for _, friend in friends do
print(friend.UserName)
end
end):catch(function(friends, errorMessage)
-- `friends` will be an empty array
print(friends, tostring(errorMessage))
end)
playerGroupRolePromise
playerUtil.
playerGroupRolePromise
(
playerUserId:
number
,
groupId:
number
) →
Promise
<
string
>
Returns a promise which is resolved with the group role of the player in the given group.
If the promise rejects, it will reject with (groupRole
as [DefaultGroupRole]), along with the error message.
playerUtil.playerGroupRolePromise(2981707497, 1):andThen(function(groupRole)
print(groupRole)
end):catch(function(defaultGroupRole, errorMessage)
warn(tostring(errorMessage))
end)
playerIsInGroupPromise
playerUtil.
playerIsInGroupPromise
(
playerUserId:
number
,
groupId:
number
) →
Promise
<
boolean
>
Returns a promise which is resolved with a boolean indicating if the given player is in the given group or not.
If the promise rejects, it will reject with (playerIsInGroup
as false
), along with the error message.
playerUtil.playerIsInGroupPromise(2981707497, 1):andThen(function(playerIsInGroup)
print(playerIsInGroup)
end):catch(function(playerIsInGroup, errorMessage)
-- playerIsInGroupPromise will always be false here
print(playerIsInGroupPromise, tostring(errorMessage))
end)
safeChatStatusPromise
Types
interface
PlayerSafeChatStatus {
On:
"On"
Off:
"Off"
Unknown:
"Unknown"
}
Returns a promise which is resolved with the safe chat status of the given player.
If the promise rejects, it will reject with (safeChatStatus
as playerUtil.PlayerSafeChatStatus.Unknown
), along with the error message.
playerUtil.safeChatStatusPromise(player):andThen(function(safeChatStatus)
print(safeChatStatus == playerUtil.PlayerSafeChatStatus.On)
end)