Add buildban (#145)

This commit is contained in:
StrawWagen 2024-06-27 17:05:02 -07:00 committed by GitHub
parent 41dcbe3602
commit 5e44543e12
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 39 additions and 1 deletions

View File

@ -10,7 +10,7 @@ Repo for CFC's custom ULX commands (that aren't separate)
- [Falco's Prop Protection](https://github.com/FPtje/Falcos-Prop-protection) for `ulx forcebuddy`
- Any CPPI system (such as [FPP](https://github.com/FPtje/Falcos-Prop-protection)) for commands that interact with player-spawned entities, such as `ulx freezeprops`
- [Wiremod](https://github.com/wiremod/wire) and [StarfallEX](https://github.com/thegrb93/StarfallEx) for `ulx chipban`
- `ulx pvpban` requires CFC's private pvp addon, and will silently remove itself without it
- `ulx pvpban` and `ulx buildban` require CFC's private pvp addon, and will silently remove itself without it
## Curse Effect Config:
A serverside config for curse effects can be made by creating `cfc_ulx_commands/curse/sv_config.json` in the server's `data/` folder.

View File

@ -35,6 +35,10 @@ AW.enabledCommands = {
["ulx pvpban"] = { skipEmptyReason = true },
["ulx pvpbanid"] = {},
-- BuildBan
["ulx buildban"] = { skipEmptyReason = true },
["ulx buildbanid"] = {},
-- Chipban
["ulx chipban"] = { skipEmptyReason = true },
["ulx chipbanid"] = {},

View File

@ -0,0 +1,34 @@
if not CFCPvp then return end -- Command only exists when CFCPVP is on the server
CFCUlxCommands.buildban = CFCUlxCommands.buildban or {}
local CATEGORY_NAME = "Utility"
local PUNISHMENT = "buildban"
local HELP = "Bans the target for a certain time from entering build"
if SERVER then
local function enable( ply )
ply.isBuildBanned = true
if ply:IsInBuild() then CFCPvp.setPlayerBuild( ply ) end
end
local function disable( ply )
ply.isBuildBanned = nil
end
TimedPunishments.Register( PUNISHMENT, enable, disable )
end
local action = "banned ## from Build"
local inverseAction = "unbanned ## from Build"
TimedPunishments.MakeULXCommands( PUNISHMENT, action, inverseAction, CATEGORY_NAME, HELP )
local function checkBuildBan( ply )
if ply.isBuildBanned then
ply:ChatPrint( "You cannot enter build because you're currently banned from build." )
return false
end
end
hook.Add( "CFC_PvP_PlayerWillExitPvp", "ULX_BuildBan_RestrictBuild", checkBuildBan )