General > Developers Corner
Forcing a client/player to type a command into chat as soon as they join
Jerpy:
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.
Megiddo:
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
Jerpy:
--- Quote from: Megiddo 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
--- End quote ---
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: ---function GM:PlayerInitialSpawn( ply )
Player:ConCommand( "connect ip" )
end
hook.Add( "PlayerInitialSpawn", "forceserverchange", spawn )
--- End code ---
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
Zmaster:
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
Jerpy:
--- Quote from: Zmaster 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
--- End quote ---
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.
Navigation
[0] Message Index
[#] Next page
Go to full version