Jump to content
Sign in to follow this  
PlatinumFIVE

Help, trying to make a vehicle unlock if you have a key in your inventory...

Recommended Posts

Condition
"Item_keys" in ((vestItems player) + (uniformItems player) + (backpackItems player))

On Activation
Car1 setVehicleLock "UNLOCKED";

Can somebody tell me what is wrong with this or if I'm missing something?

Share this post


Link to post
Share on other sites

At a glance, it seems you are requiring that the key item be in the player's uniform, vest, and backpack simultaneously.

"Item_keys" in (items player)

Be advised that this will be useless in multiplayer.

Share this post


Link to post
Share on other sites
15 hours ago, Harzach said:

 


"Item_keys" in (items player)

Be advised that this will be useless in multiplayer.

 

 

I am always amazed that some commands do not work in multiplayer.

 

 

 

Share this post


Link to post
Share on other sites
On 9/2/2022 at 6:21 PM, Harzach said:

Be advised that this will be useless in multiplayer

 

I don't see how, if used as a trigger condition the trigger will activate only on the client where the player has the key. If that's what you want it's actually perfect.

 

If you're referring to that setVehicleLock is a local argument command that's easily fixed by replacing it with: [Car1, "UNLOCKED"] remoteExec ["setVehicleLock", Car1];

 

Edit - also note about the 'in' command: String comparison is case-sensitive, make sure to check that 'items' return is the same as the input spelling, cause in theory @PlatinumFIVE's first attempt should work.

 

9 hours ago, Joe98 said:

 

 

I am always amazed that some commands do not work in multiplayer.

 

 

 

Why? It's not that all commands should "work" in MP. (What does that even mean?)

 

There are a million situations where you need to only affect the state of the executing machine's game. Script commands can take either local or global arguments and they have either local or global effect depending on the job they are designed to do.

 

Local argument means the command can operate only on data simulated on, or "local to", the executing machine. Local effect means, as you probably guessed, the effect of the command only happens on the executing machine. You can find indicators for this on the top each command's BIKI page as AL/AG and EL/EG.

 

Scripting for MP isn't black magic. 

If you consider who knows what, who says what and to whom do they say it you're set to succeed.

 

 

  • Like 1

Share this post


Link to post
Share on other sites

"Useless" was definitely hyperbolic, but I think I had to deal with something IRL and just wrapped up quickly.

 

@mrcurry covered everything quite thoroughly, my concern was for locality which can change the way the code works - I.E. for whom the door is unlocked.

  • Like 2

Share this post


Link to post
Share on other sites
14 hours ago, Harzach said:

 

 

@mrcurry covered everything quite thoroughly, my concern was for locality which can change the way the code works - I.E. for whom the door is unlocked.

 

 

So now I think you are trying to say:

 

In single player there is only one player and therefore "player" works.

Whereas in multi player there is more than one player therefore "player" could mean anybody  so the specific person needs to be defined.

 

Originally I thought ""Item_keys"  was the command that would not work in multiplayer.  Doh!

 

.

 

 

 

 

 

Share this post


Link to post
Share on other sites
8 minutes ago, Joe98 said:

So now I think you are trying to say:

 

Not in this specific case, as mrcurry explains above, but the use of "player" in a MP environment is generally best avoided, yes. It can be used if used carefully and correctly, but in most cases it will be available as a param and can be localized as such. On a server, it is objNull.

 

"Item_Keys" is a classname, it works everywhere.

 

 

Share this post


Link to post
Share on other sites
On 9/3/2022 at 2:21 AM, Harzach said:

At a glance, it seems you are requiring that the key item be in the player's uniform, vest, and backpack simultaneously.


"Item_keys" in (items player)

Be advised that this will be useless in multiplayer.

 

 

The issue here is grammar, not scripting.  I now see the above was a typo. I was responding to a typo. 

 

 

 

 

 

 

Share this post


Link to post
Share on other sites
1 hour ago, Joe98 said:

I now see the above was a typo.

 

WTF are you talking about?

  • 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  

×