Help with ULX type ban.

Here is what I got:



function GM:PlayerDisconnected( ply )
	PrintMessage( HUD_PRINTTALK, ply:GetName() .. " has left the server.")
	
	local reason = "AVOIDING DEATH, 10 minute Ban."
	local plyer = ply:Nick()
	local command = "ulx ban " ..plyer.. " 10 " ..reason
	
	if ply:Team()== TEAM_DEATH then
		game.ConsoleCommand(command)
	end
end



Error, bad server command ulx ban Swifty 10 AVOIDING DEATH, 10 minute Ban.

I think I need to get quotes around the player name and reason but I am not sure how. Or I may be taking a really bad approach I am not sure, either way time to go to bed, not making progress anymore!

Any help would be appreciated!

Are you going to ban someone for disconnecting?..bit weird. Well basically, since the player has disconnected you might have to use ulx banid instead of ulx ban and instead of local plyer = ply:Nick() use local plyer = ply:SteamID()

[lua]
function GM:PlayerDisconnected( ply )
PrintMessage( HUD_PRINTTALK, ply:GetName() … " has left the server.")

local reason = "AVOIDING DEATH, 10 minute Ban."
local plyer = ply:SteamID()
local command = "ulx banid " ..plyer.. " 10 " ..reason

if ply:Team()== TEAM_DEATH then
	game.ConsoleCommand(command)
end

end
[/lua]

Untested, may not work. Report back to me if it doesn’t. :slight_smile:

Haha I know it’s a bit strange but when no admins are on we have lots of people avoiding playing as Death. I will test it when I get back I got a few errands to run.

Thanks for the help, can’t wait to test.

Also how would I get the reason to be in quotes? Or should I just stick with a 1 word ban :stuck_out_tongue:

““text”” should work, or ’ “text” ’

Still doesn’t work I tried a few things. Here is the current code:



function GM:PlayerDisconnected( ply )
	PrintMessage( HUD_PRINTTALK, ply:GetName() .. " has left the server.")
	
	local reason = '"AVOIDING DEATH, 10 minute Ban."'
	local plyer = ply:SteamID()
	local command = "ulx banid " ..plyer.. " 10 " ..reason
	
	if ply:Team()== TEAM_DEATH then
		RunConsoleCommand(command)
	end
end


Error:
RunConsoleCommand: Command has invalid characters! (ulx banid STEAM_0:1:141XXXX 10 “AVOIDING DEATH, 10 minute Ban.” (’ '))

Its strange when I take this out of the error and put it in the console it works perfectly fine.
ulx banid STEAM_0:1:141XXXX 10 “AVOIDING DEATH, 10 minute Ban.”

EDIT
Thanks busasn I had them like this before " ‘text’ " =X

[editline]7th September 2013[/editline]

Fixed it ended up doing like badking did with TTT. Thanks for the help everyone!