PACKAGE: User Filter
Search for and install User Filter
from the Community tab.
DESCRIPTION
Enables verifying a player (their username) is on an allowed list of users. If they are, a pass-event will be fired, and if they are not, a fail-event will be fired.
Note: This package can be used in basic mode.
USAGE
Use of this script requires that you already have a script that can perform an action on. Below follows an example for how to do this, but you can use the script for many other things, such as only opening a chest if the user has a special username.
- Install the
User Filter
package. - Install the official Crayta package
Door
. - Drag a door Mesh into your environment.
- Edit the door Mesh, and add the
doorScript
to your door entity. - Add the
userFilterScript
to your door entity. - In the
userFilterScript
, click+
and setallowedUsernames
to a list of usernames that should be allowed. - In the
userFilterScript
, setonFilteredUserPass
to invoke thedoorScript
of your door entity, and selectdoorScript
in theScript
field. And lastly, selectSetOpening
in theEvent
field. - Edit the
onInteract
field of the door entity itself and setEntity
equal to your door,Script
equal to theuserFilterScript
, andEvent
toFilterPlayer
.
This will enable your players to interact with your door. If they are on the allowed list, the door will open, and if not, nothing will happen.
SETTINGS
-
allowedUsernames
: A list of usernames that will ensure the pass event is fired.
METHODS
-
FilterPlayer(player)
: Checks whether the given player’s username is on the allowed list or not. FiresonFilteredUserPass
if they are, andonFilteredUserFail
if they are not.
EVENTS
-
onFilteredUserPass
: Fired after invokingFilterPlayer(player)
, and the player was on the allowed list. Passesplayer
as the only argument. -
onFilteredUserFail
: Fired after invokingFilterPlayer(player)
, and the player was NOT on the allowed list. Passesplayer
as the only argument.