Jump to content
Sign in to follow this  
twiggy158

How Do You Respawn Units Once A Side is Dead?

Recommended Posts

I've been trying to find a way to respawn players once a side is killed, but not before the entire side is dead, for a PvP. Say if Blufor kills all of Opfor, I want it to respawn all players back into their starting locations. I can't find anything about getting the respawns to trigger only if an entire side is dead. Here is the script so far:

// Declare Variables
private ["_playerList", "_playerCount", "_westPlayers", "_eastPlayers"];
_playerList = playableUnits;
_playerCount = count _playerList;
_westPlayers = west countSide _playerList;
_eastPlayers = east countSide _playerList;


// Display total amount of players in game. As well as on each side.
if (_playerCount > 0) then {
gamelogic1 globalChat format["%1 player(s) in this match", _playerCount];
sleep 1;
gamelogic1 globalChat format["%1 player(s) are BLUFOR", _westPlayers];
sleep 1;
gamelogic1 globalChat format["%1 player(s) are OPFOR", _eastPlayers];
};

// Check if West score is higher than East Players. If not, check if East score is higher than West Players
while{true}do
{
if ( ({(side _x) == east} count allUnits) == 0 ) then {
   gamelogic1 globalChat "BLUFOR wins the round!";
   sleep 5;
   gamelogic1 globalChat "Respawning players...";
   sleep 3;
   {if (side _x == west) then {_x setDamage 1};} foreach allunits;
   westFlag addAction ["Ready","Scripts\spawnBarrier.sqf"];
   eastFlag addAction ["Ready","Scripts\spawnBarrier.sqf"];
   } else {
       if ( ({(side _x) == west} count allUnits) == 0 ) then {
           gamelogic1 globalChat "OPFOR wins the round!";
           sleep 5;
           gamelogic1 globalChat "Respawning players...";
           sleep 3;
           {if (side _x == east) then {_x setDamage 1};} foreach allunits;
           westFlag addAction ["Ready","Scripts\spawnBarrier.sqf"];
           eastFlag addAction ["Ready","Scripts\spawnBarrier.sqf"];
           };
};
};  

Right after where it kills the units is where I would want the players to respawn at their original starting locations. I'm still fairly new at scripting in ArmA so for all I know this script is horribly done for what I want it to do.

Just to clarify what I mean by respawning once a side is dead; once the round begins, you basically have one life that round, when you die, you turn into a seagull or whatever, but once either your team wins or loses by killing or losing all the players on the team then you respawn into a new round.

Thank you guys in advance.

Edited by TwiGGy158

Share this post


Link to post
Share on other sites

Name the players

Save number of players into a variable

Insert a marker at their start location.

Insert a marker on lonely island

Use an eventhandler to capture "killed" when player is killed

then revive the player, and put him on the lonely island, by refering your marker.

Count the number of playler variable down by one.

disable all user input locally on that player.

Find and activate a spectator script

repeat for each kill.

When your variable reaches 0, move the players to their start location

Stop the spectator script.

Enable their userinput

done.

But I think you might be asking for too much :)

Share this post


Link to post
Share on other sites

Hah yeah probably. I will give that a go and see how it works. Thanks for the help.

Share this post


Link to post
Share on other sites

How do I tell the script to revive the units elsewhere? This is my biggest problem with what I'm trying to do because I can't find anywhere how to respawn / revive though a command in a script.

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  

×