Force player to change team

shewowkees

L1: Registered
Jun 7, 2016
9
4
Hello everybody, i'm new here and your site is very well made, i'm glad i found it. :)
I wanted to know wether or not it was possible to force player to change team at some point during the game?
I want to do make a map like muselk's medics vs engineers. So far i suceeded at restricting waepons, sentries and classes.
But i'm struggling with the issue i mentionned earlier. Is it even possible without using server plugins?
I hope you can help me. :)
 

EmNudge

L4: Comfortable Member
Sep 23, 2015
184
60
it really depends on how you're implementing this.
Would you be switching everybody to one team? That's not a gamemode, that just placing everybody on one team.
Are you trying to even out the teams in a very specific manner?

Ignoring this, I would not recommend rebuilding a sourcemod gamemode in hammer. Medics will be able to pick up ammo and there isn't much of a way to restrict that.
 

shewowkees

L1: Registered
Jun 7, 2016
9
4
Ideally, once an engineer (red) dies he'd join the blu team. So it has to be done player by player.
It's just that currently there are like five servers running this mode and these are always full. I think i'd be great if there was an alternative to play this gamemode since the mod ran by these servers isn't public yet.
since medics are melee only, they can't screw things up using ammo .
What i can do however is that after prep time, i allow red players to spawn only in a trigger hurt with a message saying that they now must join blu if they want to be able to play but that'd be a bit clunky wouldn't it?
Also, does the game_text display the message for every player on this server? Is there a way to send the message only in a zone or only to specific players?
 

norfolk

aa
Jan 18, 2014
209
362
Do you mind linking a prefab of the restricting weapons, classes, and sentries? That is something I have been mildly interested in doing for a while.
 

Werewolf

Probably not a real Werewolf
aa
Apr 12, 2011
873
309
I wanted to know wether or not it was possible to force player to change team at some point during the game?
I want to do make a map like muselk's medics vs engineers.
That's a game mode, not a map. I believe Muselk has said in videos that its a custom plugin built by his friend Tava.

Is it possible to swap players within a map, but it has limitations.

You need a point_clientcommand, 2x filter_activator_tfteam (one for red, one for blue), and as many trigger_multiple brushes as you need. In this example I have named my point_clientcommand as "ClientCommand" so I can sent it inputs.

In short, you create a trigger_multiple brush and give it the following outputs:
  • OnStartTouch > ClientCommand > Command > jointeam blue > 0.00
  • OnStartTouch > ClientCommand > Command > joinclass random > 0.10
This makes the player execute the join team command, then a moment later pick a random class when they touch the trigger_multiple brush. Naturally replace the 'jointeam blue' with 'jointeam red' if you want them to join the red team instead of blue. You don't have to include the command to specify which class they join and you can replace the 'random' with the name of the class you want to force. If you don't include it, the player is taken to the class selection screen to pick which class they want.

A precaution you'll want to take is filtering the trigger_multiples to the opposite team it will make the player join. In other words, if the brush will make the player join the red team, filter it for blue team members only. This way if a red player enters the brush, they won't be forced to join red (despite already being on red) and won't have a random class forced on them. And of course as we are using trigger_multiple brushes, you can have them enabled all the time or toggle when they are enabled or disabled via inputs.

Now about that limitation. This will only work if the server hosting the map has the sv_allow_point_servercommand set to "always", which many servers do not have enabled by default. If they don't have it enabled, this will not work.
 

Izotope

Sourcerer
aa
May 13, 2013
698
764
Now about that limitation. This will only work if the server hosting the map has the sv_allow_point_servercommand set to "always", which many servers do not have enabled by default. If they don't have it enabled, this will not work.
This CVar does not apply to the client command entity.
 

shewowkees

L1: Registered
Jun 7, 2016
9
4
Woah thanks dude !
The restriction is quite annoying but what you told me will just make all of this lots easier. I won't even have to send a message to the players to tell them to change class, all this will be done automatically. I think that using all that, i can make medic vs engi maps that don't even need the host server to run any mods !
Since the few servers that run this map are full, promoting these vanilla maps will allow a fast widespread of this fun gamemode. I hope it'll all work, thanks a lot ! :)

Norfolk terrier, i will post two prefabs after that:

The one that doesn't need server commands:
It's a trick using the info_player_teamspawn's flags to sent undesired classes to an area that tells them to switch classes as it kills them. Then the only way for them to survive is to pick the appropriate class.

The weapon restrict method is way more clean, it just kills all the entities corresponding to the undesired waepons.


The one that uses server commands:
It will use werewolf's methods to handle all this in a much cleaner way but as he said, it'll need sv_allow_point_servercommand to be set to allways.

EDIT:
Izotope, i hadn't seen your answer, can you be more specific? will clientcommands (or whatever is it's name) allways run? if not, what restriction to this are there?
 

Izotope

Sourcerer
aa
May 13, 2013
698
764
Izotope, i hadn't seen your answer, can you be more specific? will clientcommands (or whatever is it's name) allways run? if not, what restriction to this are there?
point_clientcommand is not restricted by the sv_allow_point_servercommand CVar, meaning the commands you send to this entity won't be blocked.
Ergo, you don't need to worry about servers without this cvar.
 

shewowkees

L1: Registered
Jun 7, 2016
9
4
Thanks dude, so making map in this gamemode doesn't need a server mod at all :) I'll make an example map thanks everyone anyway ! :D
PS: Norfolk terrier, i managed to do what i said yesterday however i can't do it anymore, i don't know the reason. Anyway the weapon restriction is easily findable on google and the sentry restriction is done through playing around with func_nobuild :)
 

zahndah

professional letter
aa
Jul 4, 2015
721
642
Im pretty sure you cant forcejoin players on to 'full' teams, so the server would either need the disable team balance command enabled, or the sv_allow_point_servercommand Cvar enabled and you use a point_servercommand to disable the team balance thing.
 

shewowkees

L1: Registered
Jun 7, 2016
9
4
Yeah but my goal is to make this mode available without using the server mod which is exclusively available on muselk's server (and i think it's a shame).
So i spend the whole day on this and i suceeded. I had a lot of trouble with the eureka wrench but i found a workaround so right now here's how it works;

the server needs to have this specific cvars;

mp_respawnwavetime 0
mp_teams_unbalance_limit 0
mp_autoteambalance 0

The red engies spawn. Three of them go blue. All blue players automatically switch to medic. Non-3rd slot weapons are deleted for medic. No engineer can place sentries. When an engineer dies, he goes to team blue and becomes a medic.

I implemented that successfully i just need to test it now since i can't really know if it works with only one player. I'll make a tutorial about it right away :)