Team Selection

Does anyone know a better way of letting a player select their team then using Derma triggered console commands?

I don’t like the fact that a player can run that console command at any time. :confused:

for example:

[lua]
Button1.DoClick = function()
RunConsoleCommand( “GoTeam1” )
end
[/lua]

Help is appreciated. Thanks. :3

I think if you make the console command on a server side file (init.lua for example), then players can’t actually see that console command but can still run

If you have another computer with gmod in your house then test it on a LAN server, or if you have your own server host it there, because either way, if you run the gamemode from your computer you will be able to see console commands but they will look no different to the client sided ones
(If that makes sense :P)

I think you would see this trough a RCon like HLSW too? Isn’t it?

I don’t know, I’ve never hosted a listen server myself so I wouldn’t know

You just need to make checks, check whether or not the time is right for a player to change his team. You can’t stop them from calling your function to change their team, but you can stop the function if the time isn’t right for their team to be changed.

Example:
[lua]
function JoinTeamOne( pl, cmd, arg)
if ( pl:Alive() ) then
//Put the code to make the player join team one here. If your player passes the first check and isn’t dead let him change teams.
end
end
concommand.Add( “JoinTeamOne”, JoinTeamOne )
[/lua]