Jump to content
Sign in to follow this  
Spunned

custom soldier layout only works on first spawn

Recommended Posts

in the init field of my units, i have my loadout:

removeAllWeapons this;
removeAllAssignedItems this;
removeAllContainers this;
this addVest "V_PlateCarrier2_rgr";
this addUniform "U_B_CombatUniform_mcam_tshirt";
this addWeapon "ItemMap";
this addWeapon "ItemCompass";
this addWeapon "ItemRadio";
this addWeapon "ItemWatch";
this addWeapon "ItemGPS";
this addMagazine ["30Rnd_65x39_caseless_mag_Tracer", 30];
this addMagazine ["30Rnd_65x39_caseless_mag_Tracer", 30];
this addMagazine ["30Rnd_65x39_caseless_mag_Tracer", 30];
this addMagazine ["30Rnd_65x39_caseless_mag_Tracer", 30];
this addMagazine ["30Rnd_65x39_caseless_mag_Tracer", 30];
this addWeapon "arifle_MX_ACO_F";
this addItem "FirstAidKit";
this addItem "FirstAidKit";
this addHeadgear "H_Cap_headphones";

however when i die and respawn, the unit reverts back to it's original settings. how can i make sure that it loads my loadout every time i respawn?

Share this post


Link to post
Share on other sites

You can either save the loadout at intervals so you respawn with the same gear you had when you died:

http://forums.bistudio.com/showthread.php?148577-GET-SET-Loadout-(saves-and-loads-pretty-much-everything)

Or you use a script like this:

while { true } do
{
//Waits till player dies
waitUntil { !(alive player) };
//Player died, wait till he's back alive
waitUntil { (alive player) };
//Insert your gear script here:
};

Share this post


Link to post
Share on other sites
You can either save the loadout at intervals so you respawn with the same gear you had when you died:

http://forums.bistudio.com/showthread.php?148577-GET-SET-Loadout-(saves-and-loads-pretty-much-everything)

Or you use a script like this:

while { true } do
{
//Waits till player dies
waitUntil { !(alive player) };
//Player died, wait till he's back alive
waitUntil { (alive player) };
//Insert your gear script here:
};

thanks for your reply.

you wouldn't happen to know, how i execute an external loadout script, so i don't have to paste all these lines into every unit's init field?

i have a post about it here : http://forums.bistudio.com/showthread.php?157625-executing-external-script-error but nobody seems to respond.

thanks in advance

---------- Post added at 10:01 ---------- Previous post was at 09:33 ----------

You can either save the loadout at intervals so you respawn with the same gear you had when you died:

http://forums.bistudio.com/showthread.php?148577-GET-SET-Loadout-(saves-and-loads-pretty-much-everything)

Or you use a script like this:

while { true } do
{
//Waits till player dies
waitUntil { !(alive player) };
//Player died, wait till he's back alive
waitUntil { (alive player) };
//Insert your gear script here:
};

i my own script working, however, when i paste your code it doesn't work:

while { true } do
{
   //Waits till player dies
   waitUntil { !(alive player) };
   //Player died, wait till he's back alive
   waitUntil { (alive player) };
   //Insert your gear script here:
removeAllWeapons _this;
removeAllAssignedItems _this;
removeAllContainers _this;
_this addUniform "U_B_HeliPilotCoveralls";
_this addWeapon "ItemMap";
_this addWeapon "ItemCompass";
_this addWeapon "ItemRadio";
_this addWeapon "ItemWatch";
_this addWeapon "ItemGPS";
_this addItem "FirstAidKit";
_this addItem "FirstAidKit";
_this addHeadgear "H_CrewHelmetHeli_B";
_this addVest "V_TacVest_oli";
_this addMagazine ["16Rnd_9x21_Mag", 16];
_this addMagazine ["16Rnd_9x21_Mag", 16];
_this addMagazine ["16Rnd_9x21_Mag", 16];
_this addMagazine ["16Rnd_9x21_Mag", 16];
_this addMagazine ["16Rnd_9x21_Mag", 16];
_this addWeapon "hgun_P07_snds_F";
};

maybe i'm using it wrong?

Share this post


Link to post
Share on other sites

make a new file and call it removegear.sqf

removegear.sqf

removeAllWeapons _this;
removeAllAssignedItems _this;
removeAllContainers _this;
_this addUniform "U_B_HeliPilotCoveralls";
_this addWeapon "ItemMap";
_this addWeapon "ItemCompass";
_this addWeapon "ItemRadio";
_this addWeapon "ItemWatch";
_this addWeapon "ItemGPS";
_this addItem "FirstAidKit";
_this addItem "FirstAidKit";
_this addHeadgear "H_CrewHelmetHeli_B";
_this addVest "V_TacVest_oli";
_this addMagazine ["16Rnd_9x21_Mag", 16];
_this addMagazine ["16Rnd_9x21_Mag", 16];
_this addMagazine ["16Rnd_9x21_Mag", 16];
_this addMagazine ["16Rnd_9x21_Mag", 16];
_this addMagazine ["16Rnd_9x21_Mag", 16];
_this addWeapon "hgun_P07_snds_F";

and annother script called unitgearHandle.sqf

unitgearHandle.sqf

_player = _this;
waitUntil { (alive player) };
_player execVM "removegear.sqf";
while { true } do
{
   //Waits till player dies
   waitUntil { !(alive player) };
   //Player died, wait till he's back alive
   waitUntil { (alive player) };

  _player execVM "removegear.sqf";
}; 

Then in the missions init.sqf (this makes sure everyone joining will have this script executed). Now you don't need anything anymore in the unit's init field.

player execVM "unitgearHandle.sqf";

Share this post


Link to post
Share on other sites

i'm afraid it's not really working :/

i've tripple checked that i have the right files and everything. it loads the layout just fine, but when i respawn, im back to the original layout for that particular class.

Share this post


Link to post
Share on other sites

hmm.

You could try the killed eventhandler.

Delete the unitgearHandle part.

In the mission init.sqf:

player execVM "removegear.sqf";
player addEventHandler ["KILLED", {
 [] spawn
 {
   // Wait for respawn.
   waitUntil { alive player };

   // Wait until the unit has its equipment reset after the respawn.  
   waitUntil { (count (weapons player)) > 0 };

   player execVM "removegear.sqf";
 };
}];

Share this post


Link to post
Share on other sites
hmm.

You could try the killed eventhandler.

Delete the unitgearHandle part.

In the mission init.sqf:

player execVM "removegear.sqf";
player addEventHandler ["KILLED", {
 [] spawn
 {
   // Wait for respawn.
   waitUntil { alive player };

   // Wait until the unit has its equipment reset after the respawn.  
   waitUntil { (count (weapons player)) > 0 };

   player execVM "removegear.sqf";
 };
}];

that did the trick! :)

there's only one problem left.

i have 4 different layouts for 4 different classes. how can i make sure that the pilot only spawns with the pilot layout and the officer spawns with officer layout and so on?

thanks for the help so far. it's been amazing :)

---------- Post added at 11:07 ---------- Previous post was at 10:54 ----------

i figured it out myself.

here's what i did:

i made a file called officer.sqf

removeAllWeapons _this;
removeAllAssignedItems _this;
removeAllContainers _this;
_this addUniform "U_I_OfficerUniform";
_this addWeapon "ItemMap";
_this addWeapon "ItemCompass";
_this addWeapon "ItemRadio";
_this addWeapon "ItemWatch";
_this addWeapon "ItemGPS";
_this addItem "FirstAidKit";
_this addItem "FirstAidKit";
_this addHeadgear "H_Beret_brn_SF";

then i made a file called setofficer.sqf

player execVM "officer.sqf";
player addEventHandler ["KILLED", {
 [] spawn
 {
   // Wait for respawn.
   waitUntil { alive player };

   // Wait until the unit has its equipment reset after the respawn.  
   waitUntil { (count (weapons player)) > 0 };

   player execVM "officer.sqf";
 };
}]; 

and finally in the unit init field

null = this execVM "officer.sqf";

Recap of what it does for future reference and people who wanna use it: You spawn with a custom layout of clothes, gear and weapons. when you die, you spawn with that initial layout again.

Share this post


Link to post
Share on other sites

hi..

u can tune it even more and meke it as function.. in fact.. u should do so.. :)

since it will be called repeatedly and there is no why u should compile it each time...... https://community.bistudio.com/wiki/execVM

keep the content of your officer.sqf and rename it to TAG_fnc_setOfficer.sqf

and in the init file add something like this...

TAG_fnc_setOfficer = compileFinal preprocessFileLineNumbers "TAG_fnc_setOfficer.sqf";

_null = [] spawn
{
 waitUntil { !isNull player && isPlayer player };

 _null = player addEventHandler ["Respawn", { player call TAG_fnc_setOfficer; }];
};

and in the description.ext

respawnOnStart = 1;

init field

this call TAG_fnc_setOfficer;

Edited by LoonyWarrior

Share this post


Link to post
Share on other sites

Are there any updates to this? I am using the 2 scripts you ended up with however when I start my game, go and get a weapon or anything from the ammo crate at spawn then someone else joins it reloads MY gear back to the start loadout. very annoying when Im running a mission and someone joins late. Anyone know how to stop it doing this?

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  

×