ply:Ban()

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?

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

[/lua]

banReason would be a predefined string.

[lua]
banReason = “My String”
print(banReason)
[/lua]

Meow!
for k,v in pairs(player.GetAll()) do
v:BanEveryoneLolzThisIsJk

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

[lua]
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 )
end
[/lua]

to

[lua]
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
end
[/lua]

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:

[lua]
game.ConsoleCommand( "banid 60 " … ply:SteamID() … "
" )
[/lua]

Using the game.ConsoleCommand function?

You should also call writeid after using banid.

[lua]
game.ConsoleCommand("banid " … mins … " " … steamid … "
")
game.ConsoleCommand("writeid
")
ply:Kick(reason)
[/lua]
I use the above in my admin mod.

[lua]
game.ConsoleCommand(“banid " … mins … " " … steamid … " { kick }”)
game.ConsoleCommand(“writeid”)
[/lua]

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.

This.

There is no ply:Kick() or ply:Ban() in gmod by default as far as I know.
Edit:
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.