Jump to content
Sign in to follow this  
flyinpenguin

Issue with addPublicVariableEventHandler

Recommended Posts

Hey guys, I normally solve issues and dont have them, but I ran into one that I am having trouble with and want to make sure its not just me. This last patch changed addPublicVariableEventHandler and seems to have broken one of my scripts that lets a player use the action menu on an item to start a script on the server, in this case being a rifle range script. Add action calls this piece of code succesfully

SSrr_gridPos = (getPos (_this select 0)) select 1;
publicVariable "SSrr_gridPos";
[sSrr_gridPos] execVM "SSRifleRange\handleRange.sqf";

Mission Init has this code

missionNameSpace setVariable ["SSrr_gridPos", 0];

"SSrr_gridPos" addPublicVariableEventHandler {
[_this select 1] execVM "SSRifleRange\handleRange.sqf";
};

the handleRange.sqf has a if(isServer) check to run anything.

This script worked flawlessly to send data and run a script based off of that on server side. Since the update, it has not worked. If you run it via singleplayer it works normally and if you host the server as client, it works when only the host starts it. This has pointed me to addPublicVariableEventHandler, or publicVariable not working as it had before. Bohemias patchnotes on the subject are as follows

Added: addPublicVariableEventHandler support for object, group and teammember targets. setVariable accepts a 3rd ‘public’ parameter for its namespace version.

Anyone have any ideas on what changed, or if it is no longer viable to use this method to send data and execute scripts server side? Many thanks!

Share this post


Link to post
Share on other sites

So an update, I tried using setVariable's new public parameter instead of publicVariable. Still not working.

Share this post


Link to post
Share on other sites

Honestly, I've just had the time to skim your text there, but just in case, two important things:

1.) Putting variables into missionNamespace is the same as creating a global variable.

2.) Changes to a variable are only broadcast when you execute "publicVariable" on them. If you simply change the value to the variable, it won't be broadcast.

If I understand the BIKI correctly, the third parameter for "setVariable" should mean the same as using "publicVariable" to a global variable.

missionNameSpace setVariable ["SSrr_gridPos", 0, true];

Should be the same as

SSrr_gridPos = 0;
publicVariable "SSrr_gridPos";

...having said that I could be mistaken somewhere.

Share this post


Link to post
Share on other sites
the handleRange.sqf has a if(isServer) check to run anything.

This script worked flawlessly to send data and run a script based off of that on server side.

Why not just use publicVariableServer? There is literally no reason to have if (isServer) then {}

Added: addPublicVariableEventHandler support for object, group and teammember targets. setVariable accepts a 3rd ‘public’ parameter for its namespace version.

Anyone have any ideas on what changed, or if it is no longer viable to use this method to send data and execute scripts server side? Many thanks!

I think the first part means that now PVEH's can use setVariable variables for object, group, and teammembers. It's hard to tell though, of course they know what changes were made since they programmed it but reading this does not make any sense to me, but the second change is pretty cool. Now you can have code like:

missionNamespace setVariable ["myVar", 0, true];

which in the past was not possible.

Share this post


Link to post
Share on other sites
Why not just use publicVariableServer? There is literally no reason to have if (isServer) then {}

I think the first part means that now PVEH's can use setVariable variables for object, group, and teammembers. It's hard to tell though, of course they know what changes were made since they programmed it but reading this does not make any sense to me, but the second change is pretty cool. Now you can have code like:

missionNamespace setVariable ["myVar", 0, true];

which in the past was not possible.

Yeah, I know publicVariableServer is a better method for server execution. I have had issues in the past with it so I just use publicVariable unless I have continuous transmission of data. I agree as well that the change to setVariable is a nice addition. Just wish it would actually work.

Hopefully someone can find the solution why this doesn't work anymore. It's possible there was syntax changes to addpublicvariableeventhandler. I'm going to try to find bohemias declaration in their code for their EH they use in BIS_fnc_MP. I fixed my code a while ago with BIS_fnc_MP, but the point of this thread remains. Why does the code I posted above no longer work? What syntax change or variable types changed to make this no longer work?

Edited by flyinpenguin
  • Like 1

Share this post


Link to post
Share on other sites

I have the same issue.

 

tried to solve with BIS_fnc_MP but doesn't work

 

it seems that all things related to remote execution are broken in 1.48 patch

 

they say they want to retain the backward compatibility, but something has changed and i can't find it, or i miss something

 

this is my reload script:

 

https://mega.nz/#!xJUQXKaa!AykIbqCAhsCYIpI6efg7CqGUYCPL_adRGUklTPxdzT4

 

add a REPEATABLE trigger for ANYBODY and follow instructions inside file

 

the script worked until 1.48 patch

 

this is the same script with BIS_fnc_MP (tried to solve the problem, but fail):

 

https://mega.nz/#!NZNHGIyS!W83QrxnIZ7Q_8cWmkbHOP9twAPdJe76LTH8Jp0wuGSM

 

 

NOTE ADDED:

 

the script with BIS_fnc_MP seems to work. i was trying to remotly execute the vehicleChat command that is not whitelisted, solved defining my VehicleChat custom function

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  

×