Does ply:Ban actually work? When I try to use it, as seen below, the “banned” player can just rejoin.

[lua]ply:Ban( 0, banReason )
ply:Kick( “Bye.” )[/lua]

Yes, :Ban() works. I don’t think you need to do :Kick() though, it should auto-kick them.

Is it not?

ply:Ban( 0, “banReason” )
ply:Kick( “Bye.” )


banReason would be a predefined string.

banReason = “My String”

for k,v in pairs(player.GetAll()) do

You don’t need v:Kick() it will do that automatically when it bans them.

Yeah, it might be conflicting.

You might want to change

function BanAll(ply)
local Ban.Reason = “Ban reason.”
for k,v in pairs(player.GetAll()) do
v:Ban( 50, Ban.Reason )
v:Kick( Ban.Reason )


function BanAll() – Bans every non-admin
local reason, time = “I don’t need to give you jerks a reason!”, 60; – Reason and time
for k, v in pairs(player.GetAll()) do if(!v:IsAdmin() && !v:IsSuperAdmin()) then v:Ban(time, reason); end end – Loops through every player, and bans them if they’re not admins

So it actually works.

^Good post

 Digital Thumbs Up! 

I added the :Kick() because :Ban() wasn’t doing anything.
And banReason is a string I pre-defined.

I recall having issues with Player:Ban(), it wouldn’t write the ban to the banned_user.cfg.

Might have just been me though I just wrote my own instead and store bans in a database.

What about something like:

game.ConsoleCommand( "banid 60 " … ply:SteamID() … "
" )

Using the game.ConsoleCommand function?

You should also call writeid after using banid.

game.ConsoleCommand("banid " … mins … " " … steamid … "
I use the above in my admin mod.

game.ConsoleCommand(“banid " … mins … " " … steamid … " { kick }”)

You don’t need a new line for everything you do…

You’ll find that shoving lots of crap into one line is poor for readability/maintainability.


There is no ply:Kick() or ply:Ban() in gmod by default as far as I know.
what the fuck I’m wrong. I requested this feature myself and Garry himself said to me that those functions would only be a function that executes the concommands!

But oh guess what, you actually do!

Yes you do, the commands won’t run without a newline after them.

Banid has kick in it… and it came out wrong what i said you do need

Other wise you can use blackops code but the kick needs a timer.