Jail control

Control Module - Jail - Adds a way to jail players and temp ban players.

Usage


    -- import the module from the control modules
    local Jail = require 'modules.control.jail' --- @dep modules.control.jail

    -- This will move 'MrBiter' to the jail role and remove all other roles from them
    -- the player name and reason are only so they can be included in the event for user feedback
    Jail.jail_player('MrBiter', 'Cooldude2606', 'Likes biters too much')

    -- This will give 'MrBiter' all his roles back and remove him from jail
    -- again as above the player name is only used in the event for user feedback
    Jail.unjail_player('MrBiter', 'Cooldude2606')

    -- Temp ban works the same as jail but will store the reason and move the players items to spawn
    -- this is meant to be used as a more permiment jail but not as strong as a ban
    Jail.temp_ban_player('MrBiter', 'Cooldude2606', 'Likes biters too much')

Dependencies

expcore.roles
utils.game
utils.global
expcore.common

Events

on_player_jailed When a player is assigned to jail
on_player_unjailed When a player is unassigned from jail
on_player_temp_banned When a player is temp banned
on_player_untemp_banned When a temp ban is removed from a player

Jail

is_jailed(player) Checks if the player is currently in jail
jail_player(player, by_player_name[, reason='Non given.']) Moves a player to jail and removes all other roles
unjail_player(player, by_player_name) Moves a player out of jail and restores all roles previously removed

Temp ban

is_temp_banned(player) Checks if a player is temp banned
temp_ban_player(player, by_player_name[, reason='Non given.']) Temp bans a player by moving them to jail, clearing all other roles, storing the reason, and moving their items to spawn
untemp_ban_player(player, by_player_name) Rrmoves a player from temp ban by clearing the stored reason, removing them from jail, and restoring previous roles

Dependencies

# expcore.roles
# utils.game
# utils.global
# expcore.common

Events

# on_player_jailed

When a player is assigned to jail

Event Parameters:
  • player_index : (number) the index of the player who was jailed
  • by_player_name : (string) the name of the player who jailed the other player
  • reason : (string) the reason that the player was jailed
# on_player_unjailed

When a player is unassigned from jail

Event Parameters:
  • player_index : (number) the index of the player who was unjailed
  • by_player_name : (string) the name of the player who unjailed the other player
# on_player_temp_banned

When a player is temp banned

Event Parameters:
  • player_index : (number) the index of the player who was temp banned
  • by_player_name : (string) the name of the player who temp banned the other player
  • reason : (string) the reason that the player was temp banned
# on_player_untemp_banned

When a temp ban is removed from a player

Event Parameters:
  • player_index : (number) the index of the player who was untemp banned
  • by_player_name : (string) the name of the player who untemp banned the other player

Jail

# is_jailed(player)

Checks if the player is currently in jail

Parameters:
  • player : (LuaPlayer) the player to check if they are in jail
Returns:
  • (boolean) whether the player is currently in jail
# jail_player(player, by_player_name[, reason='Non given.'])

Moves a player to jail and removes all other roles

Parameters:
  • player : (LuaPlayer) the player who will be jailed
  • by_player_name : (string) the name of the player who is doing the jailing
  • reason : (string) the reason that the player is being jailed (default: 'Non given.')
Returns:
  • (boolean) wheather the user was jailed successfully
# unjail_player(player, by_player_name)

Moves a player out of jail and restores all roles previously removed

Parameters:
  • player : (LuaPlayer) the player that will be unjailed
  • by_player_name : (string) the name of the player that is doing the unjail
Returns:
  • (boolean) whether the player was unjailed successfully

Temp ban

# is_temp_banned(player)

Checks if a player is temp banned

Parameters:
  • player : (LuaPlayer) the player to check if they are temp banned
Returns:
  • (boolean) whether the player is temp banned
# temp_ban_player(player, by_player_name[, reason='Non given.'])

Temp bans a player by moving them to jail, clearing all other roles, storing the reason, and moving their items to spawn

Parameters:
  • player : (LuaPlayer) the player that will be temp banned
  • by_player_name : (string) the name of the player who is doing the temp ban
  • reason : (string) the reason that the player is being temp banned (default: 'Non given.')
Returns:
  • (boolean) whether the player was successfully temp banned
# untemp_ban_player(player, by_player_name)

Rrmoves a player from temp ban by clearing the stored reason, removing them from jail, and restoring previous roles

Parameters:
  • player : (LuaPlayer) the player who is being removed from temp ban
  • by_player_name : (string) the name of the player who is doing the untemp ban
Returns:
  • (boolean) whether the player was successfully removed