Jump to content

Recommended Posts

Posted (edited)

How would I turn this short script global.

 

Basically, I need these mines, when placed by any Curator on the map, to lose the ability to be edited by the Curator who placed it.

Spoiler

{

    _x addEventHandler [ "CuratorObjectPlaced", {

        params [ "_curator", "_entity" ];

        if ( ( _entity isKindOf "ModuleMine_APERSBoundingMine_F" ) || ( _entity isKindOf "ModuleMine_APERSMine_F" ) || ( _entity isKindOf "ModuleMine_ATMine_F" ) ) then {

            _curator removeCuratorEditableObjects [ [ _entity ], true ];

            };

        }

    ];

} foreach allCurators;

Currently, I have this short piece of code located in my "initPlayerLocal.sqf", however, when I test my multiplayer map using the "arma3server_x64.exe", it doesn't remove the ability for me to edit the mines after they are placed.

 

Please help!

Edited by rkemsley
Solved

Share this post


Link to post
Share on other sites

probably because the removeCuratorEditableObjects must run on server.

There is no reason to run your script from initPlayerLocal.sqf as you write something for allCurators.

 

Try your code from initServer.sqf (not sure that works)

or

in initPlayerLocal.sqf
 

player addEventHandler [ "CuratorObjectPlaced", {
  params [ "_curator", "_entity" ];
  if ( ( _entity isKindOf "ModuleMine_APERSBoundingMine_F" ) || ( _entity isKindOf "ModuleMine_APERSMine_F" ) || ( _entity isKindOf "ModuleMine_ATMine_F" ) ) then {
    [_curator, [ [ _entity ], true ] ] remoteExec ["removeCuratorEditableObjects",2];
  };
}];

 

 

 

 

Share this post


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

probably because the removeCuratorEditableObjects must run on server.

There is no reason to run your script from initPlayerLocal.sqf as you write something for allCurators.

 

Try your code from initServer.sqf

I thought because it adds the EventHandler to the Curator Module, I thought that it would need to be added when a player joins the game, so their Curator Module will also have the piece of code.

 

I originally had it in my "initServer.sqf", but it still didnt work when I was testing it using the "arma3server_x64.exe".

Edit: I have also tried it in the "init" of the Curator Modeles in the Eden editor.

Spoiler

this addEventHandler [ "CuratorObjectPlaced", {

    params [ "_curator", "_entity" ];

    if ( ( _entity isKindOf "ModuleMine_APERSBoundingMine_F" ) || ( _entity isKindOf "ModuleMine_APERSMine_F" ) || ( _entity isKindOf "ModuleMine_ATMine_F" ) ) then {

        [ _curator, [ [ _entity ], false ] ] remoteExec [ "removeCuratorEditableObjects ", 0, true ];

        };

    }

];

...and it still doesn't work (still able to edit the explosives after they have been placed).

Share this post


Link to post
Share on other sites

You just have to test the initPlayerLocal version (above) with the remoteExec on server (as written).

Share this post


Link to post
Share on other sites
Posted (edited)
13 hours ago, pierremgi said:

player addEventHandler [ "CuratorObjectPlaced", {
  params [ "_curator", "_entity" ];
  if ( ( _entity isKindOf "ModuleMine_APERSBoundingMine_F" ) || ( _entity isKindOf "ModuleMine_APERSMine_F" ) || ( _entity isKindOf "ModuleMine_ATMine_F" ) ) then {
    [_curator, [ [ _entity ], true ] ] remoteExec ["removeCuratorEditableObjects",2];
  };
}];

 

How come you are telling the "remoteExec" to only execute the function on the server when "removeCuratorEditableObjects" is already a server exec?
 

11 hours ago, pierremgi said:

You just have to test the initPlayerLocal version (above) with the remoteExec on server (as written).

Also, apologies that was wasn't very clear.

 

I had initially had this...

Spoiler

{

    _x addEventHandler [ "CuratorObjectPlaced", {

        params [ "_curator", "_entity" ];

        if ( ( _entity isKindOf "ModuleMine_APERSBoundingMine_F" ) || ( _entity isKindOf "ModuleMine_APERSMine_F" ) || ( _entity isKindOf "ModuleMine_ATMine_F" ) ) then {

            _curator removeCuratorEditableObjects [ [ _entity ], true ];

            };

        }

    ];

} foreach allCurators;

...located in my "initServer.sqf". Which I then changed the "removeCuratorEditableObjects" part to be "[ _curator, [ [ _entity ], false ] ] remoteExec [ "removeCuratorEditableObjects ", 0, true ];" (Didn't work).

 

I then tried these two versions of the piece of code, but had it located in my "initPlayerLocal.sqf" instead of my "initServer.sqf" (Didn't work).

 

Then I tried the two versions again in the "init" of the Curator Module (Still, didn't work).

 

This is why I am really confused...

Edit: 

Spoiler
13 hours ago, pierremgi said:


player addEventHandler [ "CuratorObjectPlaced", {
  params [ "_curator", "_entity" ];
  if ( ( _entity isKindOf "ModuleMine_APERSBoundingMine_F" ) || ( _entity isKindOf "ModuleMine_APERSMine_F" ) || ( _entity isKindOf "ModuleMine_ATMine_F" ) ) then {
    [_curator, [ [ _entity ], true ] ] remoteExec ["removeCuratorEditableObjects",2];
  };
}];

 

Just realised this wouldn't work, because you have to add the "CuratorObjectPlaced" EH to the Curator Module, it doesn't work with the player.

Edited by rkemsley
Problem with player addEventHandler6

Share this post


Link to post
Share on other sites

 

2 hours ago, rkemsley said:

How come you are telling the "remoteExec" to only execute the function on the server when "removeCuratorEditableObjects" is already a server exec?

 

The "SE" icon means as of biki:

Quote

... that the command or function has to be executed on the server machine, either mission host or dedicated server

 

It is not automatically executed on the server. The scripter must ensure that it is executed on the server machine.

Share this post


Link to post
Share on other sites
Posted (edited)
9 hours ago, sarogahtyp said:

 

 

The "SE" icon means as of biki:

 

It is not automatically executed on the server. The scripter must ensure that it is executed on the server machine.

Ohh, I think I see what you mean.

 

Let me do some testing and get back to you.

 

Edit: Ok, so I did some testing and found something quite useful!
I placed 3 pieces of code into my "initPlayerLocal.sqf" to see which ones work with what type of player. (I'm sure we are all aware that when testing a multiplayer server using the "PLAY SCENARIO in multiplayer" button in the Eden Editor, it considers the host player to be the server and not just a client, so certain pieces of code will work when they don't work for clients.)

 

Basically, I have 3 civilian units which are added to all Curators at the start of the game (for testing). Each civilian has a different version of the "addCuratorEditableObjects" to see which one works with what type of player. Here are the results.

Spoiler

{

    [ _x, [ [ Civ1 ], false ] ] remoteExec [ "addCuratorEditableObjects", 0, true ];

} foreach allCurators;

Works for the server player.
Works for the client players.

 

Spoiler

{

    [ _x, [ [ Civ2 ], false ] ] remoteExec [ "addCuratorEditableObjects", 2, true ];

} foreach allCurators;

Doesn't work for the server player.
Doesn't work for the client players.

 

Spoiler

{

    _x addCuratorEditableObjects [ [ Civ3 ], true ];

} foreach allCurators;

 

Works for the server player.

Doesn't work for the client players.

Edited by rkemsley
Testing different types "addCuratorEditableObjects"

Share this post


Link to post
Share on other sites

Yes my bad!

in initPlayerLocal:

getAssignedCuratorLogic player addEventHandler [ "CuratorObjectPlaced", {
  params [ "_curator", "_entity" ];
  if ( ( _entity isKindOf "ModuleMine_APERSBoundingMine_F") || ( _entity isKindOf "ModuleMine_APERSMine_F") || ( _entity isKindOf "ModuleMine_ATMine_F") ) then {
     [_curator, [ [ _entity ], true ] ] remoteExec ["removeCuratorEditableObjects",2];
   };
}];

 

Share this post


Link to post
Share on other sites
43 minutes ago, pierremgi said:

Yes my bad!

in initPlayerLocal:


getAssignedCuratorLogic player addEventHandler [ "CuratorObjectPlaced", {
  params [ "_curator", "_entity" ];
  if ( ( _entity isKindOf "ModuleMine_APERSBoundingMine_F") || ( _entity isKindOf "ModuleMine_APERSMine_F") || ( _entity isKindOf "ModuleMine_ATMine_F") ) then {
     [_curator, [ [ _entity ], true ] ] remoteExec ["removeCuratorEditableObjects",2];
   };
}];

 

I tried your advised method, with a slight change because of a few things I noticed in previous testing, and it still doesn't work. No error message, just no change from what normally happens when you place a mine as the Curator.
 

Spoiler

getAssignedCuratorLogic player addEventHandler [ "CuratorObjectPlaced", {

    params [ "_curator", "_entity" ];

    if ( ( _entity isKindOf "ModuleMine_APERSBoundingMine_F" ) || ( _entity isKindOf "ModuleMine_APERSMine_F" ) || ( _entity isKindOf "ModuleMine_ATMine_F" ) ) then {

        [ _curator, [ [ _entity  ], true ] ] remoteExec [ "removeCuratorEditableObjects", 0, true ];

        };

    }

];

 

Share this post


Link to post
Share on other sites

Really, with all your tests, I can't guess if you already test :
 

getAssignedCuratorLogic player addEventHandler [ "CuratorObjectPlaced", {
  params [ "_curator", "_entity" ];
  if ( ( _entity isKindOf "ModuleMine_APERSBoundingMine_F") || ( _entity isKindOf "ModuleMine_APERSMine_F") || ( _entity isKindOf "ModuleMine_ATMine_F") ) then {
    [_curator, [ [ _entity ], true ] ] remoteExec ["removeCuratorEditableObjects",2];
  };
}];

in initPlayerLocal.sqf

  Yes or No ?

I tested it and that work for me. (Last post btw)

Share this post


Link to post
Share on other sites
On 6/22/2021 at 7:02 PM, pierremgi said:

Really, with all your tests, I can't guess if you already test :
 


getAssignedCuratorLogic player addEventHandler [ "CuratorObjectPlaced", {
  params [ "_curator", "_entity" ];
  if ( ( _entity isKindOf "ModuleMine_APERSBoundingMine_F") || ( _entity isKindOf "ModuleMine_APERSMine_F") || ( _entity isKindOf "ModuleMine_ATMine_F") ) then {
    [_curator, [ [ _entity ], true ] ] remoteExec ["removeCuratorEditableObjects",2];
  };
}];

in initPlayerLocal.sqf

  Yes or No ?

I tested it and that work for me. (Last post btw)

Yes, it's located in the "initPlayerLocal.sqf", and yes, it is now working. No idea why it wasn't before!

 

Anyway, for anyone else having the same problem, the script below is working for me (and it's not that much different from the one posted by pierremgi!).

Quote

{

    _x addEventHandler [ "CuratorObjectPlaced", {

        params [ "_curator", "_entity" ];

        if ( ( _entity isKindOf "ModuleMine_APERSBoundingMine_F" ) || ( _entity isKindOf "ModuleMine_APERSMine_F" ) || ( _entity isKindOf "ModuleMine_ATMine_F" ) ) then {

            [ _curator, [ [ _entity ], true ] ] remoteExec [ "removeCuratorEditableObjects", 0, true ];

            };

        }

    ];

} foreach allCurators;

 

Share this post


Link to post
Share on other sites
2 hours ago, rkemsley said:

Anyway, for anyone else having the same problem, the script below is working for me (and it's not that much different from the one posted by pierremgi!).

 

 

Sorry, it's totally different!

As we are on forum and you write for "anyone", the removeCuratorEditableObjects is a command which must run on server.

This command is SE so as you can read on Biki: server exec means that the command or function has to be executed on the server machine, either mission host or dedicated server

The fact that  [ _curator, [ [ _entity ], true ] ] remoteExec [ "removeCuratorEditableObjects", 0, true ]; as @rkemsley  does, can work (not tested) but is weird for 2 reasons:

- it's a bad habit, and you can experience errors or not working scripts, when you disregard the BIKI syntax, or locality (like here). The fact that can work for this command doesn't guarantee you can do that with other SE ones;

- it's a total waste of net resource, remote executing (so broadcasting) for nuts a command/function on each clients + server + JIP here... when a command needs to run on server only. That can be fine when testing one server (+ eventually one client), that can be a desync or some other lags with multiple remote players.


In MP, you can't improvise or you'll experience many disappointments.

  • 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

×