Introduction
Hello I’m dand! You might of seen me on the dev forum before but if you don’t know I’m a 2 year lua programmer who specialises in Backend and some Gui’s.
PunishService I made in my free time just to make it easier to discipline players and log their history.
What is PunishService?
Punish service is just a module that has methods like :Ban
:TempBan
:Kick
:Warn
and logs these in a datastore.
Most of it is just easy datastore saving and loading whether a player is banned or not but I’ve tried to make it the most efficient wayI could think of which also having functionality. This includes the use of JSONEncode and JSONDecode to easily save tables to the datastore.
It also comes with a Config module with settings that are easily changeable and accessable.
Setup
Setting up the module is pretty easy, just require the module and Invoke the Setup
method and then you can use the module.
MAKE SURE TO ONLY CALL SETUP
IN ONE SCRIPT AND NOT MULTIPLE
local PunishService = require(game.ServerStorage.Modules.PunishService)
PunishService:Setup()
-- later on
PunishService:Kick(player.UserId, 'hacking')
Configuration
Inside the module is a module named Config that contains the settings for PunishService
Blacklist and Whitelist information can be found below.
KickMessage - The message that appears at the bottom of the kick message. Can be used to encourage appeals or to poke fun at the player.
WarnKick - How many warnings until you are kicked.
WarnTempBan - How many warnings until you are temporarily banned for a day.
WarnBan - How many warnings until you are banned.
Expect more configurations soon
API
Warn
Property | Type | Default | Description |
---|---|---|---|
Reason | string | nil | The reason associated with the warning. |
Issue | number | tick() | The time the warning was given. |
Author | string | string | The name of the issuer |
Gives the player a warning and notifies the client
You set the amount of warnings until a punishment in the Config script.
When a player reaches that amount of warnings it will be kicked/banned depending on the amount.
Warnings get logged.
Methods
Warn: Warns a player
GetWarn: Gets a warn with the given id
GetAllWarns: Returns an array of all the player’s warnings
ClearWarns: Removes all warnings from a player
RemoveWarn: Removes a warn with the id given
Returns: Warn Object
Example:
PunishStore:Warn(player.UserId, 'Spamming chat', 'Admin')
Kick
Just a simple kick. Very similar to player:Kick()
, can only work when player is in game.
Methods
Kick: Kicks the given player.
Returns: nil
Example:
PunishService:Kick(player.UserId, 'Being annoying')
Ban
Property | Type | Default | Description |
---|---|---|---|
Reason | string | nil | The reason for the ban (displayed in kick message) |
Issue | number | time | The time the ban was issued. |
Author | string | ‘N/A’ | The name of the Issuer. |
Length | number | 0 | The length of the ban (Only used with TempBans) |
Bans the player from the game
Bans get logged.
Methods
Ban: Bans the player forever until they are unbanned
TempBan: Bans the player for a given amount of time
Unban: Unbans the given player.
IsBanned: Returns a bool on whether the player is banned or not.
Returns: Ban Object
Example:
if Exploiting:IsBad() then
PunishService:Ban(player.UserId, 'Exploiting', 'Admin')
else
PunishService:TempBan(player.UserId, 86400, 'Exploiting', 'Admin')
end
Blacklists and Whitelists
A blacklist cannot be called by a function but is stored in a table in the Config module.
Blacklists can only be changed in studio and don’t require DataStores, so if you wanna permanently ban someone this would be a good place to store them.
Methods
IsBlacklisted: Returns a tuple: a bool and a string.
IsWhitelisted: Returns a boolean.
Other
Setup
Starts the module, ONLY CALL THIS ONCE
GetLog
Returns a dictionary on the given player’s ban and warnings.
Remove
Completely removes a player’s data from the datastore.
For security reasons.
Conclusion
Thanks for using PunishStore and feel free to give feedback below!
Dandcx