Jump to content
Sign in to follow this  
Rough Knight

Assigning units a global name?

Recommended Posts

Hi guys,

I am in the process of making a Co02 mission where I have a limited number of men you can respawn into untill the mission is over.

I am trying to get around the "selectplayer" issues for a dedicated server mission by joining a bunch of AI to a players group as he dies. Then I seem to be able to use the switchplayer function and I can ungroup the players from my "new" playable slot until the player dies again.

This works fine on a local computer but I think because the two playable slots don't have global names I am having problems running this on a server.

With reference to this article from sickboy....

http://community.bistudio.com/wiki/6thSense.eu:EG

I am trying to assign players a global name that can be called when required. I don't follow this part.

Quote[/b] ]

player is a variable, just like any other variable. A variable can contain different values. In this case the variable "player" contains an Object.

The value of the variable "player" is:

Server: a null object

Clients: the object (vehicle) that represents the player on this computer

If there are 3 player slots in game,

player1 I name: p1

player2 I name: p2

player3 I name: p3

then on p3's computer:

player == p3

you can access the other players through the variables: p1 and p2

on p2's computer:

player == p2

and you can access the other players through the variables: p1 and p3

etc. etc.

I tried to add

player1 I name: p1

player2 I name: p2

to the init file but get errors saying it is missing " ; ".

I have a game logic called server on the mission.

I must have mis-read this....but if anyone can point me in the right direction...I would be very greatfull.

Kind regards

Frosty. smile_o.gif

Share this post


Link to post
Share on other sites

Hi mate,

Thanks for the reply.

Quote[/b] ]I'm not entirely sure what you are trying to accomplish, but those that you tried to add I think are examples of what is already globally named, not actual code.

I have made a Co02 mission where one of the first objectives is to make it to a staging base. It is quite likely you will not make it. At the staging base I have 7 other men that become playable by the "enableTeamSwitch" and "addSwitchableUnit" functions.

These 7 men can't be part of any squad as they serve another defence function for a counter attack at that base. If they all die...game over.

So the issue is teamswitching to members that are not part of your squad. I am trying to join them to the dead player and then "grpnull" them once the player is into a playable slot again after death.

Using for example in a trigger.

Condition:

(isPlayer co02_slot1) && ((damage co02_slot1)>0.95)

Activation:

[man3] joinSilent co02_slot1; [man4] joinSilent co02_slot1..etc

then once you are in a playable slot another trigger:

Condition:

(isPlayer man3) or (isPlayer man4)..etc

Activation:

[man3] join grpNull;  [man4] join grpNull..etc

I have then been repeating these triggers for man3, man4 etc to shift the left over AI into the dead players group so that you can teamswitch into another man...then "grpnull" again.

This seems to be working for SP or Co02 where only one player joins the server...but not for a dedicated server.....I guess the "isplayer" function is local..not global.

I am just learning and maybe there is another way to achieve what I am trying to do...but switchplayer is not possible I don't think with the current engine in MP if the AI is not in your group. I think I now have to filter out, which player of the two slots has just died...then join another of the playable slots their global alias ie...p1 or p2 (see my first post)

Trying to use "setplayable" functions etc are not so easy with MP...I have had lots of crashes in my testing due to conflicts with these functions between local and global variables.

Any thoughts or maybe a better way to do this?

Thanks

Frosty

Share this post


Link to post
Share on other sites

I guess what I really need is a script to check which of the player slots is dead, also check what of the variables man1 to man7 is alive and then move the dead player into the next available of man1 to man7. I guess the script would need to make man1-7 playable, then join man1-7 into your group and then ungroup you once you have filled the spot.

I'll have a browse as I have to idea really on how to do it or if its even possible....

I like a challenge though...so any feedback or pointers would be very welcome.

Thanks

Frosty

Share this post


Link to post
Share on other sites

Although you can make use of the 'selectPlayer' method of moving your client connection to another 'playable' character unit during multiplayer on a dedi, unfortunately the current ArmA engine does not move the client connections 'identity'.

(Personally I think the BIS developers should alter this aspect of the client-server architecture.)

The 'identity' stays with the previous character unit.

The only way to achieve what you want to do is to not use the 'selectPlayer' method.

But, to use 'Group Respawn' method.

That is you have your mission setup for group respawn. And, you either have a pre-made group of bodies somewhere on the map for your client connection to spawn into OR you have only the single playable character and have the killed event create a new unit at the same time adding it to the player group. Then let the respawn run it's course and the client connection ALONG with the client identity will all move over to the new unit... It's the only way to thoroughly achieve what you want in the context of ArmA, multiplayer, dedi. missions at the moment.

Do you understand?

Share this post


Link to post
Share on other sites

Hi guys,

edit:

This code doesn't produce errors, but also doesn't allow teamswitch. There was a problem with my if statements I think.

I think my new problem now is my array is not a group. So therefore I can't teamswitch because I am trying to join an array no a group?

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

#begin1

;Add alive playable characters to array "player_array", and remove dead characters from same array.

player_pool = [player1, player2, man1, man2, man3, man4, man5, man6, man7, man8, man9]

player_array = []

if (alive _x) then {player_array = player_array + [_x]} forEach player_pool;

if (not alive _x) then {player_array = player_array - [_x]} forEach player_pool;

;Add alive playable men to your dead unit allowing teamswitch, then remove them from the group once you are playing.

if ((damage _player)>0.95) then {[player_array] joinSilent player};

if (alive player) then {[player_array] join grpnull};

goto begin1;

#finish1

#END

exit

I am trying to achieve what Synide suggested. I wanted to get the playable men into a dynamic array that removes the dead plyabale characters from the array.

When the player dies the player will move into one of the playable slots. Trouble is my script seems bugged. I have tried quite a few things with no success. I keep getting errors as the Mp mission starts.

side_respawn.sqs

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

#begin1

;Add alive playable characters to array "player_array", and remove dead characters from same array.

player_pool = [player1, player2, man1, man2, man3, man4, man5, man6, man7, man8, man9];

player_array = [];

if (alive _x) then {player_array = player_array + [_x]} forEach player_pool;

if (not alive _x) then {player_array = player_array - [_x]} forEach player_pool;

#finish1

#begin2

;Add alive playable men to your dead unit allowing teamswitch, then remove them from the group once you are playing.

if (isPlayer _x) and ((damage _x)>0.95) then [player_array] joinSilent player;

if (isPlayer _x) and ((alive player) then [player_array] join grpnull;

goto begin1;

#finish2

#END

exit

Is my code fundamentaly wrong....or is it just syntax error? If Anyone could give me some pointers I would be very appreciative.

Thanks

Frosty

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  

×