Jump to content

Recommended Posts

Hi, I want to make a small key-card script but I need some help.

 

I want to make it so that when you have a certain item in your inventory you automaticly get access to PD/DOC doors. ( player setVariable ["copLevel",1,true]; )

 

This is what I have tried:

 

_items = items player;

 

if ("Toolkit" in _items) then {

 player setVariable ["copLevel",1,true];

} else {

 player setVariable ["copLevel",0,true];

};

 

Though I can't get it to work this way, and I also dont know where I would put this script to make it work.

Any help is appreciated.

Share this post


Link to post
Share on other sites

Try:

_items = (vestItems player) + (uniformItems player) + (backpackItems player);

might not be correct, was just a quick thought.

Share this post


Link to post
Share on other sites
5 minutes ago, Moon_chilD said:

Try:


_items = (vestItems player) + (uniformItems player) + (backpackItems player);

might not be correct, was just a quick thought.

I already use the same script for a bank robbery system, "items player" automaticly searches through the vest, uniform and backpack already.

Share this post


Link to post
Share on other sites

First of all, place the script where player is defined (MP), initPlayerLocal.sqf is the best place in all cases.
loop it. If you want an updated code:
 

player spawn {
  while {true} do {
     waitUntil {sleep 1; "ToolKit" in items _this};
     _this setVariable ["copLevel",1,true];
     waitUntil {sleep 1; !("ToolKit" in items _this)};
     _this setVariable ["copLevel",0,true];
    };
};

Note1: This code is just an example. It can be more complex if you plan other levels of coop with other items.
Note2:  the in command is case sensitive so "ToolKit" works, not "Toolkit"

 

  • Like 2

Share this post


Link to post
Share on other sites
8 hours ago, pierremgi said:

First of all, place the script where player is defined (MP), initPlayerLocal.sqf is the best place in all cases.
loop it. If you want an updated code:
 


player spawn {
  while {true} do {
     waitUntil {sleep 1; "ToolKit" in items _this};
     _this setVariable ["copLevel",1,true];
     waitUntil {sleep 1; !("ToolKit" in items _this)};
     _this setVariable ["copLevel",0,true];
    };
};

Note1: This code is just an example. It can be more complex if you plan other levels of coop with other items.
Note2:  the in command is case sensitive so "ToolKit" works, not "Toolkit"

 

Thanks alot, this works perfectly as how I wanted it to work. 

Share this post


Link to post
Share on other sites
14 minutes ago, steam-76561198069261992 said:

Thanks alot, this works perfectly as how I wanted it to work. 

 

Right, I was over excited. It works when the classname in question is ToolKit.

 

But when I change it to "vop_keycard_west" it doesnt work anymore, and yes it is the correct classname.

 

Any ideas @pierremgi ?

Share this post


Link to post
Share on other sites

3 seconds using google:

("vop_keycard_west" in Magazines player);

 

So it seems to be a magazine

  • Like 1
  • Confused 1

Share this post


Link to post
Share on other sites
3 minutes ago, sarogahtyp said:

3 seconds using google:

("vop_keycard_west" in Magazines player);

 

So it seems to be a magazine

Whoops, that makes sense. Sorry haha. Thanks alot though.

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

×