Ban script not working?

Here is my script:

[lua]
function BanRDMFag( pl, cmd, args )
if pl.AbleToBan and args and args != “” then
if table.HasValue( AbleToBeBanned, args[1] ) then
RunConsoleCommand( “banid”, 5, args[1] )
if timer.IsTimer( “KeepFromBanningLater” ) then timer.Destroy( “KeepFromBanningLater” ) end
for k, v in pairs( AbleToBeBanned ) do
if v == args[1] then
table.remove( AbleToBeBanned, k )
end
end
else
pl:PrintMessage( HUD_PRINTCONSOLE, “WTF ARE YOU DOING ASSHOLE?!?!” )
end
else
pl:PrintMessage( HUD_PRINTCONSOLE, “Error, the RDM fag will unfortunately not be banned :(” )
end
end
concommand.Add( “_banhim”, BanRDMFag )
[/lua]

Everything is defined, as I am testing it on my dedicated server, but for some reason it just WILL NOT ban the RDMing player.

If you need to know, this is how this function is called on the client:

[lua]
RunConsoleCommand( “_banhim”, RDMer:UniqueID() )
[/lua]

Like I said, everything is defined and it all works until it gets to the first code I posted, and I get no LUA errors on client OR server side. Is it my RunConsoleCommand Syntax?

[editline]12:13AM[/editline]

The first script is server-side, I forgot to mention.

RunConsoleCommand is not a valid serverside command. What you’re looking for is http://wiki.garrysmod.com/?title=Game.ConsoleCommand

Well, was apparently.

Oh? I thought it was shared… Oh well, I’ll try that out.

[editline]01:00AM[/editline]

game.ConsoleCommand did not work either. It does nothing :confused:

[editline]01:02AM[/editline]

Or wait, can I specify args such as game.ConsoleCommand( “banid”, 5, args[1] ) ?

OR should it be game.ConsoleCommand( "banid 5 " … args[1] ) ?

Nothing’s working, and it’s pissing me off. I always have problems with Console Command >:(

UniqueID ~= User ID. You’ll have to use http://wiki.garrysmod.com/?title=Player.UserID, eg.

[lua]RunConsoleCommand("_banhim", ply:UserID())[/lua]

Oh, and:



lua_run RunConsoleCommand("say", "Hello!")
> RunConsoleCommand("say", "Hello!")...
Console: "Hello!"

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

God dammit this is pissing me off, it’s still not working; I changed it to this:

Server: (Changed line 4 in first code)
[lua]
RunConsoleCommand( “banid”, tostring( 5 ), tostring( args[1] ) )
[/lua]

Client:
[lua]
RunConsoleCommand( “_banhim”, RDMer:UserID() )
[/lua]

[lua]
RunConsoleCommand( “banid”, “5”, args[1] )
RunConsoleCommand( “kickid”, args[1] )
[/lua]

Use game.ConsoleCommand…

Any specific reasons to use that instead of RunConsoleCommand?

I tried game.ConsoleCommand, I tried RunConsoleCommand, NOTHING IS WORKING.

@iRzilla Doesn’t banid also kick the player as well? If so, then the second thing wouldn’t be needed…

Just wondering, what’s wrong with Player:Ban( Integer minutes, String reason ) ?

[editline]09:55PM[/editline]

And I think RunConsoleCommand should work serverside. It’s being used to run kickid and banid from the scoreboard serverside:

http://luabin.foszor.com/code/lua/autorun/server/admin_functions.lua

:Ban hasn’t worked for me in forever.

What you have to do from what I last remember was.

:Ban
:Kick

Because from what I recall it won’t kick them. I sure this is correct.

That is correct. I tried banning myself and it didn’t kick me, but it added me to the banned_user.cfg file.

Okay so it still is that way.

EDIT: I remember looking at ass mod in june and saw ban and kick in a function. So if what I’m thinking is true it should help you with your problem CT.

Use what I wrote it works fine.

Add some prints in.

For what reason? Nowhere in his code is he using “return” or “break” and there are no lua errors. So it’s executing the full code.

The only problem was that he wasn’t kicking the players upon banning them.

Wrong.


> if _G.RunConsoleCommand then Msg ( "Entoros was wrong
" ) else Msg ( "Entoros was right
" ) end...
Entoros was wrong