Jump to content
pognivet

How to lock doors on a building for all players on a multiplayer server

Recommended Posts

I have a mission where some doors are locked and you need keys/keycards to open them. The doors are locked using the edit terrain object module under environment in the eden editor. That part works fine in editor or singleplayer. The only problem is that when I host the mission online the doors are only locked for me and nobody else. I'm the only one that needs keys to unlock the doors, but for everyone else they're just unlocked.

 

How do I make it so this is synchronized for all the players.

Share this post


Link to post
Share on other sites

Just use bis_fnc_disabled_door variable: set to 1 for locking, 0 for unlocking.

 

For example in repeatable trigger area :

 

on act:
 

{
  _nbDoors = getNumber (configfile >> "CfgVehicles" >> typeOf _x >> "numberOfDoors");
  for "_i" from 0 to _nbDoors - 1 do {
    _var = format ["bis_disabled_Door_%1", _i];
    _x setVariable [_var,1]
  }
} forEach ( nearestTerrainObjects [getpos thisTrigger, ["house","building"],(triggerArea thisTrigger) select 0] )

 

on deact :
 

{
  _nbDoors = getNumber (configfile >> "CfgVehicles" >> typeOf _x >> "numberOfDoors");
  for "_i" from 0 to _nbDoors - 1 do {
    _var = format ["bis_disabled_Door_%1", _i];
    _x setVariable [_var,0]
  }
} forEach (nearestTerrainObjects [getpos thisTrigger, ["house","building"],(triggerArea thisTrigger) select 0])

 

That works in MP. The trigger fires the code on each PC, using something like:  anyBuilding setVariable ["bis_disabled_door_0",1] to lock the first door because this can work locally on each PC.

If you are scripting something else on server side only (server only trigger or else), just write something like:

anyBuilding setVariable ["bis_disabled_door_0",1,true]

This way you broadcast the variable (JIP compliant).

The first (normal trigger) method is more network saving, of course.

 

  • Like 1

Share this post


Link to post
Share on other sites

Ok, say for instance I want the door locked, but want the user to have to enter a code to open the door.  Now with that, I want to be able to assign different codes to different doors in a particular structure in some cases.  How would I go about making it ask for the code, and assign the passcode?  I have been looking everywhere with poor results, and I'm not quite up to par with SQF as of yet, but do know some basics of programming with other languages.

Share this post


Link to post
Share on other sites

I don't know why they didn't make the "Edit terrain objects" module work in multiplayer.

 

I have a similar problem, I can see destroyed buildings that I've made with the module but everyone else see both the destroyed building and the undamaged one, and they are flickering and occupy the exact same place. Also AI shoot through the undamaged building and kill the client players inside.

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

×