!hop/!servers thing

Is there one of these for GMOD 13? (Allowing you to hop from a server to another one) If so where? And if not, where would I begin to start making one?

Use the OnPlayerChat hook to check when a player wants to run the command (return false so the command isn’t added to chat). Add a clientside command to make the local player run “connect <ip>” locally to jump them to the other server.
A simple example:

[lua]hook.Add( “OnPlayerChat”, “JumpToServer”, function( ply, str, team, dead )
if ply:IsPlayer() and str == “!jump” then ply:ConCommand( “connect”, “<ip>” ) return true end
return false
end )

concommand.Add( “serverjump”, function( ply, cmd, args, str ) ply:ConCommand( “connect”, “<ip>” ) end )[/lua]

Okay and would i just put this in lua/autorun?

lua/autorun/client

[editline]1st October 2013[/editline]

Sorry, corrected the code.

So If i had just put this in I type jump nothing happens this is what mine looks like :

hook.Add( “OnPlayerChat”, “JumpToServer”, function( ply, str, team, dead )
if ply:IsPlayer() and str == “!jump” then ply:ConCommand( “connect”, “<192.223.26.62>” ) return true end
return false
end )

concommand.Add( “serverjump”, function( ply, cmd, args, str ) ply:ConCommand( “connect”, “<192.223.26.62>” ) end )

No ‘<’, sorry, I was using them so you knew to change them. It should just be “192.223.26.62”.

Usage: connect <server>
I get this when I type !jump but nothing happens

Ah, try:
[lua]
hook.Add( “OnPlayerChat”, “JumpToServer”, function( ply, str, team, dead )
if ply:IsPlayer() and str == “!jump” then ply:ConCommand( “connect 192.223.26.62” ) return true end
return false
end )

concommand.Add( “serverjump”, function( ply, cmd, args, str ) ply:ConCommand( “connect 192.223.26.62” ) end )[/lua]
I forgot that ply:ConCommand() uses a different format…

You’re not checking who the player that wrote !jump is.

Add this
[LUA]
if ply == LocalPlayer() then
–do serverhop
end
[/LUA]

Won’t matter, will it? As the chat message is suppressed if it is !jump, other clients won’t receive it and run the hook.

Still nothing happens. I just get this in console. Usage: connect <server> and this
[ERROR] lua/autorun/client/servers.lua:1: unexpected symbol near ‘[’

  1. unknown - lua/autorun/client/servers.lua:0

I have absolutely no idea if this will work, but I’m going to sleep because it’s 2:30am and i should be sleep
[LUA]local function HandleServerHop(ply, text)

if string.sub(text, 1, 4) == "!hop" then
	if ply ~= LocalPlayer() then return true end
	ply:ConCommand( "connect 192.223.26.62" )
end

end
hook.Add(“OnPlayerChat”, “ServerHop”, HandleServerHop)[/LUA]

good luck i love you

IT WORKED I LOVE YOU <3 sleep well young prince