Jump to content
Sign in to follow this  
lwlooz

"Teamswitch" Scripting in Multiplayer

Recommended Posts

Hello,

When they put up the selectPlayer command on the BIKI back in 2006 I was very excited considering the revolution in Multiplayer mission design this would have brought about.

Now unfortunately that doesn't work either in ArmA nor in Arma2 in Multiplayer on a Dedicated server when you use it for the original purpose of "teamswitching" into a AI unit of a different team [Remote AI in MP].

What I am wondering tho and what I am asking here is , if anyone has been able to get the following commands out of the Teamswitch Suite to work, namely:

I have tried to use this commands on a Multiplayer Dedicated Server(1.03) , but I could not observe any visible results. I did try it with respawn=side as well.

So , if anyone has a working example of getting those to work I would appreciate it , otherwise I am going to mark them down as broken for Multiplayer(Dedicated).

Share this post


Link to post
Share on other sites

No idea how it works, but keep in mind that TeamSwitch in MP breaks briefings.

Share this post


Link to post
Share on other sites

Well setPlayable have to work I think, otherwise how could anyone play multiplayer? ;)

Share this post


Link to post
Share on other sites

Heya!

I've had a little bit experience with it in MP, and my only real grudges with it is that if you return the player who is in a new body, to a group where he is not leader, AI will take over control of the player body :O.

Here's a prototype; http://dev-heaven.net/boards/12/topics/show/1229

Little low on time but interesting topic!

Share this post


Link to post
Share on other sites

I've been able to get it working in Arma and Arma II. Generally, the unit needs to be local to the computer you're using for the switch (which means, as far as I've been able to test, you need to create the group on the client's computer and create units within it). It's possible you could create units on the server, move them to a group local to the player's computer, and then switch, but I haven't tried it. I have had rare CTD's (I think it's when the code tries to switch to a unit in a vehicle that has died within the frame that you're switching), but these commands used correctly are generally pretty stable. You also need to execute the commands on the local computer.

In arma I, the player identity is not transferred to the new entity, so while the player retains his name in chat, the unit has the original identity ("David Armstrong" or similar).

In Arma II, the identity is transferred to the new unit, which means the correct name shows up, but never leaves the old unit. So if a player switches between units within his group, if he waits a few seconds for the game to transfer identities, eventually they will all have his name.

This additionally creates problems with MP vehicle control: If you are the tank commander, switch to the gunner, and back to the commander (and your identity is transferred to the gunner), the gunner won't fire when you order him to, because the game _thinks he's a human_, and won't send the fire command. (I have a workaround that overrides the commander fire/switch weapon action and sends a manual fire command, which works for all weapons except guided missiles...)

Anyway, here's the code snippet I've been using. I use it in MP for direct teamswitch (T/Y/U) and group respawn. As stated before, the group is created on the client's machine, and all units are createUnit'ed on there. (Another simplification is that only AI units are within each player's group, so there's no danger of players switching into each other by mistake. This could complicate a coop mission with many players per group). I remember an old post where sickboy (I think) said bad things happened if you used non-local units or groups, so I try to stick by that.

//get player's group
_group = _this select 0;
_units = _this select 1;
_nextunitID = _this select 2;
_oldplayer = _this select 3;

_unit = _units select _nextunitID;

if (!alive _unit) exitwith {};

addSwitchableunit _unit;
selectplayer _unit;
vehicle _unit switchcamera "Internal";
removeSwitchableunit (_oldplayer);
(group _unit) selectleader _unit;

From what I can understand, if you want to 'steal' remote AI for the purpose of teamswitching, you'll need to somehow make them local to the client computer first. Probably creating a local group and moving the unit over would work well enough. Good luck!

Edited by The_Captain

Share this post


Link to post
Share on other sites

Fully working example here : http://dev-heaven.net/projects/list_files/whis-maas

EDIT : I think I'll need a bit more precision here : this mission above use teamSwitch to emulate a full class respawn : upon death, a respawn screen is presented that lists possible classes for player to respawn into.

When selecting one and clicking OK, the game creates a unit of the selected class and transfers the player into that unit, using teamSwitch. I used a modified version of the script Sickboy linked above for the teamSwitch stuff : http://dev-heaven.net/repositories/entry/whis-maas/CTB_Windy_Mountain_b01.Chernarus/switchCharacter.sqf

As it has been modified a bit widly, it may be a lil bit unreadable as is :)

Edited by whisper

Share this post


Link to post
Share on other sites

Hello,

Thank you for your replies.

As you mentioned selectPlayer has all these various problems in Multiplayer , which leads me to believe that

it isn't really MP compatible yet.

I was just wondering if the other 2 commands I mentioned had to be used in some sort weird combination of some type of respawn

and server settings and during full moon to get them to behave like in Singleplayer (addSwitchableUnit,removeSwitchableUnit).

I would be interested what those two commands do in this common code snippet of yours:

[b]addSwitchableUnit _newUnit;[/b]
selectPlayer _newUnit;
[...]
[b]removeSwitchableUnit _newUnit;[/b]

When I remove both of them, I don't observe any different behaviour.

Furthermore in a different Test with respawn=side , those commands neither seem to add nor remove units to the switchableUnits array and are not visible in the "TeamSwitch-Dialog" , when I use them on both playable/non-playable remote/local units.

This leads me to believe the MP capability of those isn't implemented yet as well , but perhaps as I said , I am doing something wrong.

What I would be mostly interested in tho is the setPlayable-command.

Unless anyone gets that to work somehow, I would like to bring the malfunction of this one to BIS's attention as that is clearly a command that was supposed to work on MP (I suppose they never got around to actually working on that).

The purpose of this all is that since OFP I would like to create dynamic missions with dynamic playable slots in MP.

None of the work-arounds that exist are satisfactory in that regard , especially if you consider that on a static mission you can just JIP into and outo slots as you want without any problems.

Share this post


Link to post
Share on other sites

Team switch does not break briefings if you make them compatible with team switch. I've already posted an example on the Zeus thread. You simply have to create the tasks and notes and keep them updated for all units for all clients, rather than just create them for all players.

Share this post


Link to post
Share on other sites

If you need a workaround that means something's broken. :) Good fix you made though, useful for game types. heh

Share this post


Link to post
Share on other sites

When I remove both of them, I don't observe any different behaviour.

Concur. They are there because they were there in original Sickboy's script, my own tests never used them and it was working (with few group/identity things that made me switch to Sickboy's technique, but I don't think these 2 commands are having any effect in MP)

These 2 commands are, from their description, only usefull to add the units in the SP Team Switch menu. They are not meant to be used in MP

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×