Reports control

Control Module - Reports - Adds a way to report players and store report messages.

Usage


    -- import the module from the control modules
    local Reports = require 'modules.control.reports' --- @dep modules.control.reports

    -- This will place a report on "MrBiter" (must be a valid player) the report will have been made
    -- by "Cooldude2606" (must be the player name) with the reason 'Liking biters too much' this can be
    -- seen by using Reports.get_report.
    Reports.report_player('MrBiter', 'Cooldude2606', 'Liking biters too much') -- true

    -- The other get methods can be used to get all the reports on a player or to test if a player is reported.
    Reports.get_report('MrBiter', 'Cooldude2606') -- 'Liking biters too much'

    -- This will remove the warning on 'MrBiter' (must be a valid player) which was made by 'Cooldude2606'.
    Reports.remove_report('MrBiter', 'Cooldude2606') -- true

    -- This will remove all the report that have been made against 'MrBiter'. Note that the remove event will
    -- be triggered once per report issused.
    Reports.remove_all('MrBiter') -- true

Dependencies

utils.game
utils.global

Events

on_player_reported When a player is reported
on_report_removed When a report is removed from a player

Getters

get_reports(player) Gets a list of all reports that a player has against them
get_report(player, by_player_name) Gets a single report against a player given the name of the player who made the report
is_reported(player[, by_player_name]) Checks if a player is reported, option to get if reported by a certain player
count_reports(player[, custom_count]) Counts the number of reports that a player has aganist them

Setters

report_player(player, by_player_name[, reason='Non given.']) Adds a report to a player, each player can only report another player once
remove_report(player, reported_by_name, removed_by_name) Removes a report from a player
remove_all(player, removed_by_name) Removes all reports from a player

Dependencies

# utils.game
# utils.global

Events

# on_player_reported

When a player is reported

Event Parameters:
  • player_index : (number) the player index of the player who got reported
  • by_player_name : (string) the name of the player who made the report
  • reason : (string) the reason given for the report
# on_report_removed

When a report is removed from a player

Event Parameters:
  • player_index : (number) the player index of the player who has the report removed
  • reported_by_name : (string) the name of the player who made the removed report
  • removed_by_name : (string) the name of the player who removed the report
  • batch_count : (number) the number of reports removed in this batch, always one when not a batch
  • batch : (number) the index of this event in a batch, always one when not a batch

Getters

# get_reports(player)

Gets a list of all reports that a player has against them

Parameters:
  • player : (LuaPlayer) the player to get the report for
Returns:
  • (table) a list of all reports, key is by player name, value is reason
# get_report(player, by_player_name)

Gets a single report against a player given the name of the player who made the report

Parameters:
  • player : (LuaPlayer) the player to get the report for
  • by_player_name : (string) the name of the player who made the report
Returns:
  • (string or nil) string is the reason that the player was reported, if the player is not reported
# is_reported(player[, by_player_name])

Checks if a player is reported, option to get if reported by a certain player

Parameters:
  • player : (LuaPlayer) the player to check if reported
  • by_player_name : (string) when given will check if reported by this player (optional)
Returns:
  • (boolean) if the player has been reported
# count_reports(player[, custom_count])

Counts the number of reports that a player has aganist them

Parameters:
  • player : (LuaPlayer) the player to count the reports for
  • custom_count : (function) when given this function will be used to count the reports (optional)
Returns:
  • (number) the number of reports that the user has

Setters

# report_player(player, by_player_name[, reason='Non given.'])

Adds a report to a player, each player can only report another player once

Parameters:
  • player : (LuaPlayer) the player to add the report to
  • by_player_name : (string) the name of the player that is making the report
  • reason : (string) the reason that the player is being reported (default: 'Non given.')
Returns:
  • (boolean) whether the report was added successfully
# remove_report(player, reported_by_name, removed_by_name)

Removes a report from a player

Parameters:
  • player : (LuaPlayer) the player to remove the report from
  • reported_by_name : (string) the name of the player that made the report
  • removed_by_name : (string) the name of the player who removed the report
Returns:
  • (boolean) whether the report was removed successfully
# remove_all(player, removed_by_name)

Removes all reports from a player

Parameters:
  • player : (LuaPlayer) the player to remove the reports from
  • removed_by_name : (string) the name of the player who removed the report
Returns:
  • (boolean) whether the reports were removed successfully