Facepunch / garrysmod-requests

Feature requests for Garry's Mod
83 stars 24 forks source link

GM:DoPlayerBan and GM:OnPlayerBanned(ply, reason, time_in_seconds) #1280

Open meepen opened 5 years ago

meepen commented 5 years ago

These hooks would allow servers to listen to bans and allow admin mods to override the ban method.

Player:Ban() would call the OnPlayerBanned hook then call DoPlayerBan

If DoPlayerBan returns false-y it would proceed with regular gmod banning system.

This allows admin mods to override the default banning system and allows admin mods to also implement a system that all addons will be able to listen to bans for.

thegrb93 commented 5 years ago

Lets get a hook for every player/entity method while we're at it. No thanks. Instead, have your admin mod or whatever's calling Ban do a hook.Call first.

meepen commented 5 years ago

Yes let's have only admin mods call hooks and not have it as a standard in default Garry's Mod.

Why would you even consider having a hook for every player method? Why are you so against every idea I have?

thegrb93 commented 5 years ago

I don't recall commenting on any of your other requests, but I commented here because it's a pointless one. Admin mods would take over the hook anyway, defeating whatever purpose you wanted to use it for.

meepen commented 5 years ago

Okay, how is this pointless?

This suggestion allows EVERY addon to use the same API for banning, instead of doing stuff like the default TTT code already does, and does not support any other admin mods because of it. [1]

Instead of this code, it could simply call ply:Ban(x) and it would work with every admin mod.

[1] https://github.com/Facepunch/garrysmod/blob/394ae745df8f8f353ea33c8780f012fc000f4f56/garrysmod/gamemodes/terrortown/gamemode/admin.lua#L163

thegrb93 commented 5 years ago

You'd still need to update TTT and every admin mod to use it. You might as well just make a universal global function like CPPI does.

meepen commented 5 years ago

Why would you want to use a function instead of a hook? Admin mods can already do that if they wanted by overriding the Ban function, but they haven't.

thegrb93 commented 5 years ago

The hook would also only be able to take one return so it's just as effective.

thegrb93 commented 5 years ago

That was also my first thought, just override Player.Ban.