concommand and arg issue

I am making a simple ban command for a project. However it’s turning out to be “not so simple”.


concommand.Add("banplayer", function( ply, cmd, args, str )

	local banTableData = string.Explode( " ", str )
	local player_id = banTableData[1]
	local banTime = banTableData[2]
	local banReason = banTableData[3]

	PrintTable(banTableData)

	print (banReason)

end)

Also, ignore my prints, I was just looking in console at what it was returning. Which is how I found the issue.

What I’m trying to achieve here, is when someone types “banplayer steamid bantime banreason”
it will do a ban (I can do the ban action part), however, if I were to just use
args[1] etc, this breaks the SteamID up to the first colon

Example: args[1] returns STEAM_0
If I do it as breaking the table down into a string with explode, it works fine, however, since my explode def is a space, it now takes the ban reason, and breaks it down. So now I can only have a “one word ban reason”.
Obviously enclosing the ban reason in quotations does nothing, because the explode is on the space.

Any ideas, or an easier way to do this?

Thanks in advance.

args isn’t a string. args is a table with each argument already provided. To get the full ban reason, loop through all remaining args and piece the string together.

Yeah I know an arg isn’t a string, doing args[1] was my first method until I found out about the STEAM_0 issue and stripping everything after the first colon.
Then I went the explode route and it worked except for the ban reason.

So how would I go about doing a loop for anything past the bantime and is my current method “proper” for getting the steamid.

I guess after the first item in the table being converted as a string banTableData[1], I wouldn’t need that anymore, and I could just pass the remaining arguments?

[editline]8th August 2015[/editline]

Other thing, if I do a print (args) to see how that pulls up. The result is this: