Jump to content
Sign in to follow this  
BadHabitz

Add backpack only if backpack slot is empty

Recommended Posts

So, I've got a basic script that I'm adding as an addAction to a box:

if (!local player) exitWith {}; 
player addBackpack "B_Parachute";
hint "Parachute equipped";

What I want to do is add a check that makes sure the backpack slot is empty first, and if not it will give a hint "Please unequip backpack". 

Also, the locality check on the first line... I know it doesn't hurt anything when I use it, for this and other scripts, but do I need it?

 

Thanks in advance.

Share this post


Link to post
Share on other sites
backpack player

returns backpack what carried by player, and if empty will returns "".

  • Like 1

Share this post


Link to post
Share on other sites

Thanks. This code works for me.

if (!local player) exitWith {}; 
if (backpack player != "") exitWith {hint "Please unequip backpack";};
player addBackpack "B_Parachute";
hint "Parachute equipped";

 

Share this post


Link to post
Share on other sites
45 minutes ago, BadHabitz said:

if (!local player) exitWith {}; 

is unnecessary : the player is always local.

  • Like 3
  • Thanks 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  

×