ULX

Author Topic: Forcing a client/player to type a command into chat as soon as they join  (Read 4608 times)

0 Members and 2 Guests are viewing this topic.

Offline Jerpy

  • Newbie
  • *
  • Posts: 21
  • Karma: 2
Now there is a couple reasons behind this. It's a strange way to handle it, but it's really my only idea that could work.

Explanation:
I am changing server hosts, and when this happens as we all know; IP's change. So my thought was, how would I get players to join the new servers from the old while they're still operational?

Solution:
With our current server hopper menu, I can make both of the servers on there connected only to our new ones, and if it was a player attempting to connect on our old servers, a hop menu would appear as soon as they join, due to them forced to type !hop into chat. They would then select one of our newer servers to connect to, if they are still attempting to join our old ones.

Notes:
There is not a console command to open this specific hop menu, so the only way to open it is via saying !hop into chat.

How?:
Well, thats what I don't know. I don't know where to start when forcing a player to type hop into chat, so thats where I need the help. I would have no idea how to force the hop menu script to open the menu itself on join, so again - went to a simple solution, making them type it into chat.
Hope you guys are able to help, or have other solutions. Thanks.
« Last Edit: January 29, 2015, 03:18:38 PM by Jerpy »

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Forcing a client/player to type a command into chat as soon as they join
« Reply #1 on: January 29, 2015, 03:34:47 PM »
Why force them to say something in chat, rather than execute "connect <my new ip>"? You do this with this function: http://wiki.garrysmod.com/page/Player/ConCommand
Experiencing God's grace one day at a time.

Offline Jerpy

  • Newbie
  • *
  • Posts: 21
  • Karma: 2
Re: Forcing a client/player to type a command into chat as soon as they join
« Reply #2 on: January 29, 2015, 03:48:49 PM »
Why force them to say something in chat, rather than execute "connect <my new ip>"? You do this with this function: http://wiki.garrysmod.com/page/Player/ConCommand

I was considering that one, but we have more than one server so it'd be slightly inconvenient to anyone that didn't want to play for example, ttt but wanted to join our prophunt server.

Edit: now that I realize it, that was a stupid response I had. I can just have a different script run for each server, connecting to the new server of that game type. I knew of this function, but would this script be correct?

Code: [Select]
function GM:PlayerInitialSpawn( ply )
Player:ConCommand( "connect ip" )
end

hook.Add( "PlayerInitialSpawn", "forceserverchange", spawn )

Or did simplify it too much? I feel like that's correct.
of course changing ip with my server ip

update: nope that didn't work, so im doing it wrong. tried a different things and its still incorrect
« Last Edit: January 29, 2015, 05:30:51 PM by Jerpy »

Offline Zmaster

  • Full Member
  • ***
  • Posts: 235
  • Karma: 25
Re: Forcing a client/player to type a command into chat as soon as they join
« Reply #3 on: January 29, 2015, 05:37:44 PM »
Don't put GM: in the function name if you're just gonna make a hook
Also, the function you referenced in the hook isn't the same as the name of the hook you made

Also, it's ply:ConCommand( "connect ip" )
You named the variable ply not Player

Offline Jerpy

  • Newbie
  • *
  • Posts: 21
  • Karma: 2
Re: Forcing a client/player to type a command into chat as soon as they join
« Reply #4 on: January 29, 2015, 05:46:16 PM »
Don't put GM: in the function name if you're just gonna make a hook
Also, the function you referenced in the hook isn't the same as the name of the hook you made

Also, it's ply:ConCommand( "connect ip" )
You named the variable ply not Player

Yes, I realized the error in the whole "Player" "ply" I fixed that earlier, and that still didnt work. I also redid the function as stated in your second sentence, and that fix did nothing. I removed the GM and all, and I'm still not getting this right.

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: Forcing a client/player to type a command into chat as soon as they join
« Reply #5 on: January 29, 2015, 07:20:33 PM »
Retaining to your issue, connect is a fcvar_server_can_execute command, which is blocked for whatever dumb security reason. I think there is a way to remove fcvar_server_can_execute but idk how.
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline Jerpy

  • Newbie
  • *
  • Posts: 21
  • Karma: 2
Re: Forcing a client/player to type a command into chat as soon as they join
« Reply #6 on: January 29, 2015, 07:41:49 PM »
Retaining to your issue, connect is a fcvar_server_can_execute command, which is blocked for whatever dumb security reason. I think there is a way to remove fcvar_server_can_execute but idk how.

Yeah, I saw that in a different thread. The way around it is to instead use "ply:SendLua"
so for example:
Code: [Select]
ply:SendLua("LocalPlayer():ConCommand('connect ip')")

An Error Has Occurred!

array_keys(): Argument #1 ($array) must be of type array, null given