Custom commands

I currently own two servers and I have tried adding a command so when I type It takes me from my TTT server to my death run and the other way round.

My current lua for this


function join_dr( ply )
	ply:SendLua( 'RunConsoleCommand( "connect" ,"193.0.159.202:27465" )' )
end


hook.Add( "PlayerSay", "Commands", Commands )

function Commands( ply, text, public )
	elseif( string.sub( text, 1, 4) == "!ttt" ) then
		print("used !dr")
		join_dr( ply )
	end
end

Can anyone help me out? Because it works sometimes when i try it but it says something about this not being a correct ip but when i try and type it in manually to console it works.

I have out this file in lua/autorun

Use the print function to find out where the function is stopped, I am sure that with the logic you that something is wrong.

How can i get the print?

Easy!



function join_dr( ply )
print("1")
	ply:SendLua( 'RunConsoleCommand( "connect" ,"193.0.159.202:27465" )' )
print("2")
end


hook.Add( "PlayerSay", "Commands", Commands )

function Commands( ply, text, public )
	elseif( string.sub( text, 1, 4) == "!ttt" ) then
		print("used !dr")
		join_dr( ply )
print("3")
	end
end


And then in the console to see the outgoing messages.

What about the else if with no opening if? It has nothing to make it do the else.


function join_dr( ply )
	ply:SendLua( 'RunConsoleCommand( "connect" ,"193.0.159.202:27465" )' )
end


hook.Add( "PlayerSay", "Commands", Commands )

function Commands( ply, text, public )
	elseif( string.sub( text, 1, 4) == "!ttt" ) then --- This should be if not elseif
		print("used !dr")
		join_dr( ply )
	end
end