Jump to content
Sign in to follow this  
-=-Sengira-=-

Respawn Issue

Recommended Posts

Hello all,

First off I am sorry if this has been answered before, but after using the search feature to some length I have not been able to find the sulution.

I am currently making a 25player COOP mission, and all the units that are playable have had there weapons changed to variants of the Xm8 (via the units Init line). My problem is when the unit respawns they respawn with the default load out for that unit type (ie rifleman starts out with M16a4). I currently am not using any kind of respawn script. What I have done is used the description.sqf to add the respawn="BASE"; respawndelay = 15; and on my mission add the "respawn_west" marker.

I am sorry if the terms I have used are wrong. I am new to scripting and mission development.

Thank you in advance for any help.

Sengira

Share this post


Link to post
Share on other sites

Unfortunately, or, I would say, luckily, you have to script a bit for that purpose. Luckily, because only with scripting mission writing becomes the REAL fun ;)

But don't panic, I'll try to guide you through the basic idea so that you should be able to continue on your own.

1. Create a file "weapons.sqf" in your missions folder.

Write in it:

switch (typeOf player){
  case "USMC_Soldier" : {_primweapon = "XM8"};
  case "othertype" : {_primweapon = "other XM8 variant"};
  case ...
};

removeAllWeapons player;
player addWeapon _primweapon;
player selectWeapon _primweapon;
player addMagazine "<whatever XM8 needs, i think the G36 mags>";
player addMagazine ....; // other/more magazines
player addWeapon ....; // pistol? launcher?
...

With the switch-case control you set which player class gets which XM8 variant.

2. Now, create another file "playerInit.sqf", and write in it:

[] execVM "weapons.sqf";
While{true} do{
  WaitUntil{not alive player};
  WaitUntil{alive player};
  [] execVM "weapons.sqf";
};

3. Last but not least create the "Init.sqf" file and write in it:

WaitUntil{not isNull player};
[] execVM "playerInit.sqf";

Ok, this is the basic idea:

The Init.sqf is being executed every time the mission starts, i.e. the player joins the mission.

The Init.sqf now executes the "playerInit.sqf". Of course you can avoid creating an Init.sqf file by writing

init = [] execVM "playerInit.sqf";

into the init line of the player unit. I prefer this variant for no special reason. Anyway make yourself familiar with the Init.sqf, it is an essential tool in writing missions.

However, the Init.sqf executes the playerInit.sqf, which checks permanently if the player died, waits until the player respawns then gives back the player your customized weapon configuration.

Thats the way I always do it, perhaps someone has a more convenient method. Of course the names of the files you can choose on your own, except the Init.sqf.

Edited by Bon

Share this post


Link to post
Share on other sites

Thank you Bon, for your reply. I'll give it a try tonight when I get time. Again thank you for your help!

Sengira

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  

×