User Filter (Basic Mode)

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.

  1. Install the User Filter package.
  2. Install the official Crayta package Door.
  3. Drag a door Mesh into your environment.
  4. Edit the door Mesh, and add the doorScript to your door entity.doorscript-simple
  5. Add the userFilterScript to your door entity.
  6. In the userFilterScript, click + and set allowedUsernames to a list of usernames that should be allowed.
  7. In the userFilterScript, set onFilteredUserPass to invoke the doorScript of your door entity, and select doorScript in the Script field. And lastly, select SetOpening in the Event field.
  8. Edit the onInteract field of the door entity itself and set Entity equal to your door, Script equal to the userFilterScript, and Event to FilterPlayer.

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. Fires onFilteredUserPass if they are, and onFilteredUserFail if they are not.

EVENTS

  • onFilteredUserPass: Fired after invoking FilterPlayer(player), and the player was on the allowed list. Passes player as the only argument.
  • onFilteredUserFail: Fired after invoking FilterPlayer(player), and the player was NOT on the allowed list. Passes player as the only argument.