mirror of
https://github.com/CFC-Servers/cfc_ulx_commands.git
synced 2025-03-04 03:13:28 -05:00
Fix timed punishment startup (#135)
* Don't start punishments until player is fully loaded * Store punishments before enabling them * Remove unknown punishments * Improve clarity * Use PlayerFullLoad * Note dependencies
This commit is contained in:
parent
007d2624e8
commit
fe62eafc2f
10
README.md
10
README.md
@ -2,6 +2,16 @@
|
||||
Repo for CFC's custom ULX commands (that aren't separate)
|
||||
|
||||
|
||||
## Dependencies:
|
||||
- [ulx](https://github.com/TeamUlysses/ulx) and [ulib](https://github.com/TeamUlysses/ulib), obviously
|
||||
- [gm_logger](https://github.com/CFC-Servers/gm_logger) for timed punishments
|
||||
- [gm_playerload](https://github.com/CFC-Servers/gm_playerload) for timed punishments
|
||||
- [cfc_notifications](https://github.com/CFC-Servers/cfc_notifications) for `ulx tpa`
|
||||
- [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
|
||||
|
||||
## 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.
|
||||
Default/example settings can be found [here](/lua/cfc_ulx_commands/curse/sv_config_default.json).
|
||||
|
@ -76,22 +76,25 @@ function TP.SendPunishments( ply )
|
||||
net.Send( ply )
|
||||
end
|
||||
|
||||
hook.Add( "PlayerInitialSpawn", "CFC_TimedPunishments_Check", function( ply )
|
||||
-- Requires CFC's gm_playerload
|
||||
hook.Add( "PlayerFullLoad", "CFC_TimedPunishments_Check", function( ply )
|
||||
local steamID64 = ply:SteamID64()
|
||||
local punishments = Data:getActivePunishments( steamID64 )
|
||||
if not punishments then return end
|
||||
|
||||
for punishment in pairs( punishments ) do
|
||||
local basePunishment = Punishments[punishment]
|
||||
if basePunishment then
|
||||
basePunishment.enable( ply )
|
||||
ply.TimedPunishments = punishments
|
||||
|
||||
-- Run punishment enable functions
|
||||
for punishmentName in pairs( punishments ) do
|
||||
local punishment = Punishments[punishmentName]
|
||||
if punishment then
|
||||
punishment.enable( ply )
|
||||
else
|
||||
ErrorNoHaltWithStack( "Unknown punishment type: " .. punishment )
|
||||
ErrorNoHaltWithStack( "Unknown punishment type: " .. punishmentName )
|
||||
punishments[punishmentName] = nil -- Remove unknown punishment (note that pairs() still works when removing values)
|
||||
end
|
||||
end
|
||||
|
||||
ply.TimedPunishments = punishments
|
||||
|
||||
TP.SendPunishments( ply )
|
||||
end )
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user