Jump to content
Sign in to follow this  
Catchdog64

Respawn question

Recommended Posts

I am trying to write a script that will let a player keep his uniform but remove weapons, gear, magazines, and vests when they respawn. So far no luck, can somebody help?

 

OnPlayerKilled.sqf

player setVariable["Saved_Loadout",getUnitLoadout player];
player removeAllWeapons;
player removeBackpack;
player removeAllHandgunItems;
player removeMagazines;
player removeVest;

 

OnplayerRespawn.sqf

player setUnitLoadout(player getVariable["Saved_Loadout",[]]);
player enableFatigue false;
player removeAllWeapons;
player removeBackpack;
player removeAllHandgunItems;
player removeMagazines;
player removeVest;

Share this post


Link to post
Share on other sites

You can use these commands to get and add the uniform only, instead of the entire loadout:

https://community.bistudio.com/wiki/uniform

And

https://community.bistudio.com/wiki/addUniform

Or

https://community.bistudio.com/wiki/forceAddUniform

As for many of the rest of your commands, it's:

command:unit

Not

unit:command

You can check the wiki for specifics.

Share this post


Link to post
Share on other sites

Yeah I realized I had the unit command structure backwards,, what I cannot figure out how to do is get the uniform and then add it upon respawn. Basically I want it so that if a player is killed, they'll respawn with whatever uniform that they might have picked up. I can get it to work with what the class starts with or with everything that they have picked up.

Share this post


Link to post
Share on other sites

Have you tried it with the uniform commands instead of the unitLoadout commands? get/setUnitLoadout look like they might still be WIP. You could also try the "Killed" and "Respawn" event handlers to run loadout scripts.

Share this post


Link to post
Share on other sites

I got it!

 

You have to put this in the init of the unit

 

this addEventHandler ["Respawn", {
 [_this select 0, [this, "last_loadout"]] call BIS_fnc_loadInventory;
}];

 

Then onPlayerKilled

player setVariable["Saved_Loadout",getUnitLoadout player];
 

onPlayerRespawn

player setUnitLoadout(player getVariable["Saved_Loadout",[]]);
removeAllWeapons player;
removeVest player;
removeBackpackGlobal player:
 

  • Like 1

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  

×