Jump to content
marty6

Need help on scripting

Recommended Posts

Hi

 

I'm new to Arma 3.  I'm having a problem in making players in multilplayer as respawn points.  So, when somebody dies, I would like for players to be able to respawn on another player on their side while keeping their loadouts.    Does anyone know how to do this?  I watched quite a few videos and read a bunch on several forums, but could not find the answer.

 

Any help is appreciated!

Share this post


Link to post
Share on other sites

Hey man! 

Pretty sure this is the function you need.

 

[<target>,<position>] call BIS_fnc_addRespawnPosition; 


<target> can be namespace, side, object or group.
<position> can be a position, an object or a marker name (as string).

In your case you want <target> to be the side and <position> to be an object (the player you want to respawn on).

So... 
 

[WEST, yourSoldierVarName] call BIS_fnc_addRespawnPosition;


Or if you want the leader of a particular group...
 

[WEST, leader (yourGroupVarName)] call BIS_fnc_addRespawnPosition;





 

  • Like 1

Share this post


Link to post
Share on other sites

As for keeping loadouts this is the way I normally handle that...

In a text editor, create a file called onPlayerKilled.sqf
... and a file called onPlayerRespawn.sqf

Place both files into your mission directory.


In onPlayerKilled.sqf paste in... 

player setVariable["Saved_Loadout",getUnitLoadout player];


In onPlayerRespawn.sqf paste in... 

removeAllWeapons player;
removeGoggles player;
removeHeadgear player;
removeVest player;
removeUniform player;
removeAllAssignedItems player;
clearAllItemsFromBackpack player;
removeBackpack player;
player setUnitLoadout(player getVariable["Saved_Loadout",[]]);


This will be kind of buggy if you're using the in built Arma 3 revive though because when you go down you go into an ambient animation without your primary weapon, therefore when you die you technically don't have a primary weapon. When you respawn you'll respawn without it.

If you want players to respawn with a preset loadout though, then rather than onPlayerKilled.sqf you can paste the same code into a file called initPlayerLocal.sqf. This will just save the loadout when you initially join the game rather than each time you get killed.

  • Like 1

Share this post


Link to post
Share on other sites

billyeatworld,

 

Thank you very much for the replies.  If I have a respawn point at the main base as well as player respawns, how do I get the players to choose their respawn.  I think I'm missing something.  When I got back into the 'created' mp mission that I did, we could only respawn back at base, but not on each other during the mission.

Share this post


Link to post
Share on other sites

I'll have to check them when I get back from work.  Thanks again!

Share this post


Link to post
Share on other sites

My description.ext at the very least usually looks something like... 

respawn = 3;
respawnDelay = 30;
respawnOnStart = 1;


The base respawn should just be a marker called "respawn_west". I don't use the respawn position editor modules.

Or for example in your init.sqf file you can add respawn points to your own custom named markers using the syntax... 
 

[<SIDE>, <MARKER NAME>] call BIS_fnc_addRespawnPosition;


Here's an example of how I've set up the respawn points in one of my missions...
 

[WEST, "base_infantry","Infantry Base"] call BIS_fnc_addRespawnPosition;
[WEST, "base_air","Air Base"] call BIS_fnc_addRespawnPosition;
[WEST, "base_naval","Naval Base"] call BIS_fnc_addRespawnPosition;
[WEST, "base_armor","Armor Base"] call BIS_fnc_addRespawnPosition;
[WEST, "base_paradrop","Paradrop Muster"] call BIS_fnc_addRespawnPosition;


 

Share this post


Link to post
Share on other sites
41 minutes ago, billyeatworld said:

My description.ext at the very least usually looks something like... 


respawn = 3;
respawnDelay = 30;
respawnOnStart = 1;


The base respawn should just be a marker called "respawn_west". I don't use the respawn position editor modules.

Or for example in your init.sqf file you can add respawn points to your own custom named markers using the syntax... 
 


[<SIDE>, <MARKER NAME>] call BIS_fnc_addRespawnPosition;


Here's an example of how I've set up the respawn points in one of my missions...
 


[WEST, "base_infantry","Infantry Base"] call BIS_fnc_addRespawnPosition;
[WEST, "base_air","Air Base"] call BIS_fnc_addRespawnPosition;
[WEST, "base_naval","Naval Base"] call BIS_fnc_addRespawnPosition;
[WEST, "base_armor","Armor Base"] call BIS_fnc_addRespawnPosition;
[WEST, "base_paradrop","Paradrop Muster"] call BIS_fnc_addRespawnPosition;


 

add  to descriprion.ext  "  respawnTemplates[] = {"MenuPosition"};  " i think that way you get a menu to choose your respawnpoint

Share this post


Link to post
Share on other sites

Hi,

 

I added the

[<SIDE>, <MARKER NAME>] call BIS_fnc_addRespawnPosition;

to the init.sqf file.  I also added this to each player in their respective init within the EDEN editor. IE: [west, "player1] call ...etc .... This worked.  I had the menu come up after my character was killed.  I was able to choose either the 'other' players and / or the base location.  However, I was not able to keep any of the 'saved' loadouts on respawn.  I have 5 loadouts.  If I wanted to respawn a few time with the 4th loadout, that what I want to do.  If I then want to change to a different loadout, let's say loadout 2, then I want to respawned with that a few times during the game.  Is the possible? 

 

In the respawn menu it stated two things: Loadout unspecified and will be chosen automatically and Role unspecified and will be chosen automatically.  Is there a way to respawn as the same player?  IE if my friend was 'player1' and I was 'player2', if we both die at the same time, can we come back as our original players and keep our 'saved' loadouts?

 

In my description.ext file i have the following:

respawn=3;
respawnDelay=30;
respawnTemplates[] = {"Revive", "MenuPosition"};
respawnOnStart=-1;
reviveForceRespawnDelay=3;
#execVM"onPlayerKilled.sqf";          <-- tried this and it didn't work
#execVM"onPlayerRespawn.sqf";   <--tried this and it didn't work

 

in my init.sqf file i have this:

[west, "player1"] call BIS_fnc_addRespawnPosition;
[west, "player2"] call BIS_fnc_addRespawnPosition;
[west, "player3"] call BIS_fnc_addRespawnPosition;

 

onPlayerKilled.sqf :

#player setVariable["Saved_Loadout",getUnitLoadout player];
[player, [missionNamespace, "inventory_var"] call BIS_fnc_saveInventory;  <-- this did not work

 

onPlayerRespawn.sqf

#removeAllWeapons player;
#removeGoggles player;
#removeHeadgear player;
#removeVest player;
#removeUniform player;
#removeAllAssignedItems player;
#clearAllItemsFromBackpack player;
#removeBackpack player;
#player setUnitLoadout(player getVariable["Saved_Loadout",[]]);
[player, [missionNamespace, "inventory_var"]] call BIS_fnc_saveInventory;  <--this did not work

 

Share this post


Link to post
Share on other sites

Figured it out.

 

1. Took out the lines: execVM"onPlayerKilled.sqf";   execVM"onPlayerRespawn.sqf"; from the description.ext

2.   Took out this from onPlayerKilled.sqf
[player, [missionNamespace, "inventory_var"] call BIS_fnc_saveInventory;

3.  Took out this form onPlayerrespawn.sqf

[player, [missionNamespace, "inventory_var"]] call BIS_fnc_saveInventory;  <--this did not work

4. and removed the '#' in the onPlayerrespawn.sqf and made sure all those lines were active.

 

Sorry that i'm a noob at this but it is very interesting and i'm learning fast.  Also, at the respawn menu i still have this: Loadout unspecified and will be chosen automatically and Role unspecified and will be chosen automatically.  Anyway to fixed this or just leave it alone?

Thanks!

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

×