Jump to content
NumbNutsJunior

[Solved] Side and group switching - Respawn System

Recommended Posts

I am trying to set the players group to a separate group on side civilian when they are "dead" (alive on island) and then if revived have them rejoin their initial group on side east or west, but the initial group always returns grpNull

 

deleteGroupWhenEmpty - Arguments and effects are global (wiki)

 

("initPlayerLocal" state) - - "initGroup" properly returns group at this point

player setVariable ["initGroup", group player]; // Set the player group even when dead

// Make sure group is not deleted when empty
if (isGroupDeletedWhenEmpty (group player)) then {
	(group player) deleteGroupWhenEmpty false;
};

(respawn event handler) - - "initGroup" returns grpNull (same result when 'player' is replaced with _unit or _corpse), as if it did not exist anymore

params[["_unit", objNull], ["_corpse", objNull]];
if ((isNull _unit) || (isNull _corpse)) exitWith {};
 
// Set unit to civilian side
_deadGroup = createGroup [civilian, false];
[_unit] joinSilent _deadGroup;

// ...

// Find inital group
_initGroup = player getVariable["initGroup", grpNull];

// Set unit to initial group
[_unit] joinSilent _initGroup;

 

I simply want to be able to freely return the unit to and from his initial group

Share this post


Link to post
Share on other sites

Deleting group when empty is an option for saving resource but it's not the case by default. So, don't mess with that. Do nothing.

When a unit/player dies, he becomes civilian. So no need to create a group for that. But I guess it's not a real "death" as in SP. You're in MP session.

"dead" but "alive" on Island doesn't mean anything. You have some life states to cope with.

 

So, depending on your scenario, player can be "dead" (definitely till new connection), "incapacitated" (usually waiting for heal), "dead-respawn" waiting for respawn delay, then "healthy" again.

Yes, you can save the initial group with something like:

unitOne setVariable ["initGrp", group unitOne, true]; //(variable is global/public).

Prefer a unit's name like unitOne rather than "player" waiting for effective player somewhere local (player's PC).

And decide when you want the player (alive) leaves his group and returns to his group.

 

 

 

Share this post


Link to post
Share on other sites
27 minutes ago, pierremgi said:

Deleting group when empty is an option for saving resource but it's not the case by default. So, don't mess with that. Do nothing.

When a unit/player dies, he becomes civilian. So no need to create a group for that. But I guess it's not a real "death" as in SP. You're in MP session.

"dead" but "alive" on Island doesn't mean anything. You have some life states to cope with.

 

So, depending on your scenario, player can be "dead" (definitely till new connection), "incapacitated" (usually waiting for heal), "dead-respawn" waiting for respawn delay, then "healthy" again.

Yes, you can save the initial group with something like:

unitOne setVariable ["initGrp", group unitOne, true]; //(variable is global/public).

Prefer a unit's name like unitOne rather than "player" waiting for effective player somewhere local (player's PC).

And decide when you want the player (alive) leaves his group and returns to his group.

 

 

 

 

I have the respawn type set to 'base'

The respawn delay is set to '0'

 

The player instantly respawns on marker, they are held their alive while the match is running so that i can add them back to the mission, if they are revived by another player.

 

The swapping of sides is to mimic the feature of being on civilian while dead. As explained they are not dead. And so they dont interfere with the overall mission with scripts such as countSide where unit is alive and such.

 

So unless i can script set their life state to 'dead-respawn' via script, life states will not help me

 

I appriciate the reply

Share this post


Link to post
Share on other sites

SO, change for a different approach. For example, if players are inside an area around the respawn position, then they are civilian.. until something you need to define, for example out of the area.

 

What you could do:

In init field of all playable units:

if (isServer) then {this setVariable ["initGrp", group this, true]};

 // this way, the initial group is registered at start from server and shared for any player, without messing with JIP while a player is civilian. And you don't need to care for localization of the player.

Place a trigger, repeatable, not server only, any player present

on cond: this && side (thisList select 0) == WEST

on act:
 

0 = [(thisList select 0),thisTrigger] spawn {
  params ["_plyr","_trig"];
  if (local _plyr) then {
    _civGrp = createGroup civilian;
    [_plyr] joinSilent _civGrp;
    waitUntil {sleep 0.5; !(_plyr inArea _trig) };
    [_plyr] joinSilent (_plyr getVariable ["initGrp",grpNull]);
  };
}

You'll have also to check if player was leader before death in order to make it leader again. This can be done by another variable (updated by loop if you need) but not with EH,unfortunately. The MEH entityKilled or entityRespawned don't keep this information.

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

×