Garry's Mod /do command?

Hi! I’d like to learn LUA! But that’s not a problem, I can attempt to learn.

But I’ve been trying to make a command. /do.
It’s used on SAMP roleplay servers to describe a roleplay item, e.g: “/do My M4A1 rifle would be painted in a desert camouflage.”

The command is just a rip off of /me just in a different context. I’d like it to print out to the chat, allowing other people to see it, like me. Like this: “<User Input> (( ply name ))”, example: “The camera would be set to HDR mode. (( Cody Castle ))”. Would the below code work? I tested it on single player and nothing happens. I would just like help:) Thanks!


hook.Add( "PlayerSay", "doCommand", function( ply, text, input )
	text = string.lower( text ) 
	if ( text == "/do" ) then
		return ""
end )

function checkForCommand(ply,text,tc,dead)
	local firstChar = string.sub( text, 1,1 )
	if(firstChar=="!" or firstChar=="/")then
    		chat.AddText( Color( 100, 100, 255 ), "** "..string.sub(text,5).." **")
    		return true

Here ya go, i loved having this command in samp and mta lol :smiley: Have fun! :slight_smile:

Thank you so much! :smiley:

No problem! ^^