Jump to content
Sign in to follow this  
1para{god-father}

Help on script after removal of processInitCommands

Recommended Posts

Ok, so what I am gathering from what you are typing is there there is going to be an INCREASE in IO traffic.. Nice more IO events that servers and clients have to process.. sounds a lot like LAG to me.. Thumbs up!! I love LAG

The shit are you on about.

You could just use BIS_fnc_MP and call that, with the appropriate variables, and it'd be BETTER than setvehicleinit, which sends code over, vs just a function call. I'm not seeing much difference.....

Share this post


Link to post
Share on other sites

Broadcasting an entire function across the network is probably something that we're better off without... The only thing it's going to disturb are server-side mods such as the Zeus briefing info mod, which should probably be incorporated into the game anyway via some kind of serverinfo.html which will be broadcasted once on player connect or even be visible from server browser, making it easier to use for server admins and more functional for the players.

Breaking old missions is obviously something that should be avoided, but since it is an alpha you have already been warned that your missions may break in order to make the game features work the best way possible, rather than keeping your missions working but giving up on game improvements (for example, leaving class names with typos or security-vulnerable commands would just be ugly) is simply not worth it. When the full game is released you'll probably have to revise your missions anyway to keep them as enjoyable as the other missions people will be making, taking advantage of the full game features. Never needing to modify content you create now (during alpha or even beta) is just not a reasonable expectation.

If you want to run code remotely, create the function in advance, and call it from a public variable event handler. That way you are only broadcasting a single variable (which, btw, can be an array, as long as it isn't a nested array (aka array of arrays)), rather than broadcast an entire function. You just have to keep in mind that the event handler will not run on the machine that executes the publicVariable command, and thus you'll have to call that function separately on said machine, preferably immediately after you execute the publicVariable command.

If you use the parameters passed to the event handler (check the wiki for addPublicVariableEventHandler), you should even be able to use a single variable to execute the same function multiple times for different variable values. Though I haven't tested this thoroughly, based on the documentation it *should* work, as publicVariable is supposed to be reliable and thus always trigger the event handler if such an event handler exists.

Another thing to keep in mind is that at start of a mission the event handler might not yet exist. Either create it from some kind of pre-init (aka a script you call (not execVM/spawn) from an init line of a unit), or just make sure that after the initialization scripts are done running, your mission is still functional (for example, make sure you are initializing the vehicle script for all relevant vehicles after the event handler was added, and only use the event handler to initialize vehicles spawned later on).

Edited by galzohar

Share this post


Link to post
Share on other sites
[All the things]

+1 to this. Having predefined 'flags' set in a PVEH (Public Variable Event Handler) that trigger specific functions.

Best idea is to NEVER 'call compile' any publicvariable passed variable, because otherwise you've got a big assed hole in your code and people can just brick your mission in no-time.

Share this post


Link to post
Share on other sites
You just have to keep in mind that the event handler will not run on the machine that executes the publicVariable command, and thus you'll have to call that function separately on said machine, preferably immediately after you execute the publicVariable command.

I realize all the consternation over BIS_fnc_MP, but the beauty of that command is that it solves the above problem by giving you the option to call/spawn the function on the same machine as well. The parameter marked in red below (designated as target) can accept different types of values (see the link for details). When you use a boolean and make it true (or do not include it all by default), it will execute everywhere to include on the machine that called/spawned it.

[[myArg1, myArg2], "myFunction", [color=#ff0000]true[/color], false] spawn BIS_fnc_MP;

To expand further, if you do not want/need to create a function, you can also use BIS_fnc_MP to execute an already existing script to include passing arguments by using it to call/spawn the BIS_fnc_execVM function:

[[[myArg1, myArg2], "myScript.sqf"],"BIS_fnc_execVM",true,true] spawn BIS_fnc_MP;

Share this post


Link to post
Share on other sites

Better they fixed the hole that allows clients to inject their own scripts in the first place.

Share this post


Link to post
Share on other sites
Broadcasting an entire function across the network is probably something that we're better off without... The only thing it's going to disturb are server-side mods such as the Zeus briefing info mod, which should probably be incorporated into the game anyway via some kind of serverinfo.html which will be broadcasted once on player connect or even be visible from server browser, making it easier to use for server admins and more functional for the players.

Breaking old missions is obviously something that should be avoided, but since it is an alpha you have already been warned that your missions may break in order to make the game features work the best way possible, rather than keeping your missions working but giving up on game improvements (for example, leaving class names with typos or security-vulnerable commands would just be ugly) is simply not worth it. When the full game is released you'll probably have to revise your missions anyway to keep them as enjoyable as the other missions people will be making, taking advantage of the full game features. Never needing to modify content you create now (during alpha or even beta) is just not a reasonable expectation.

If you want to run code remotely, create the function in advance, and call it from a public variable event handler. That way you are only broadcasting a single variable (which, btw, can be an array, as long as it isn't a nested array (aka array of arrays)), rather than broadcast an entire function. You just have to keep in mind that the event handler will not run on the machine that executes the publicVariable command, and thus you'll have to call that function separately on said machine, preferably immediately after you execute the publicVariable command.

If you use the parameters passed to the event handler (check the wiki for addPublicVariableEventHandler), you should even be able to use a single variable to execute the same function multiple times for different variable values. Though I haven't tested this thoroughly, based on the documentation it *should* work, as publicVariable is supposed to be reliable and thus always trigger the event handler if such an event handler exists.

Another thing to keep in mind is that at start of a mission the event handler might not yet exist. Either create it from some kind of pre-init (aka a script you call (not execVM/spawn) from an init line of a unit), or just make sure that after the initialization scripts are done running, your mission is still functional (for example, make sure you are initializing the vehicle script for all relevant vehicles after the event handler was added, and only use the event handler to initialize vehicles spawned later on).

Don't think you got the concept of BIS_fnc_MP, for simple comparison, the long bit of details you posted is exactly what BIS_fnc_MP is, BIS_fnc_MP doesn't send an entire function over the network, it uses a variable/function already defined and tells whoever it needs to, to execute the function and pass the parameters it needs. Short terms, it's exactly the way you were talking about setting up a publicvariableventhandler and use of publicvariable.

Biggest difference is BIS_fnc_MP is designed if you tell it to, to tell JIP players to also run the code if they need to once they are initialized..

BIS_fnc_MP is the best replacement of setVehicleInit if you actually read the wiki on the command and test around with it, but I can see a lot of people aren't understanding this.

Share this post


Link to post
Share on other sites

What I don't see a replacement for is something like...

player SetVehicleInit "this SwitchMove 'AovrPercMrunSrasWrflDf'";

ProcessInitCommands;

...which I think should previously have made the jump animation visible to everyone in the game without requiring everyone to have an addon installed or the mission to be edited. This allows some people to run an addon without everyone *having* to have it. Clearly this capability has been abused but, as said, I'd have much preferred they dealt with script injections at the source by securing network traffic. Patching the scripting language is shutting the gate after the horse has bolted and more damage limitation than solution.

Share this post


Link to post
Share on other sites
What I don't see a replacement for is something like...

I believe the following would accomplish the same effect (appears on every machine).

in the init.sqf or anywhere else as long as it is on every machine:

// Create a function that will make a unit jump.
fnc_switchMoveJump = 
{
   private ["_unit"];
   _unit = _this select 0;
   _unit switchMove "AovrPercMrunSrasWrflDf";
};

in a script or other instance when you want to activate the animation:

// Spawn the switchMove function passing to it the unit you want to animate, with no other parameters it will execute everywhere but JIP will not see it later.
[[player], "fnc_switchMoveJump"] spawn BIS_fnc_MP;

Share this post


Link to post
Share on other sites
...as long as it is on every machine:

And therein is the lost functionality.

Share this post


Link to post
Share on other sites
And therein is the lost functionality.

What on earth are you on about? You wanted an animation played over the network (ie, ran on all clients), and the code he gave is exactly that.....

Share this post


Link to post
Share on other sites
And therein is the lost functionality.

what are you talking about? if you make your missions without ever touching init.sqf then you are not using even 1 percent of arma potential. you need to learn how to add basic scripts to init.sqf for your own benefit as it executes on every machine because old commands are not coming back.

Share this post


Link to post
Share on other sites

Ah, I get it guys. It took a while, but he's on about addons, vs missions. Didn't notice it because he was very non-specific for some reason.

With regards to addons, we've already covered that solution.... You publicvariable the function, then call it via BIS_fnc_MP..... JUST how it works with setvehicleinit, essentially.

Share this post


Link to post
Share on other sites
JUST how it works with setvehicleinit, essentially.

No, because everyone has to already have the addon, just adding to the difficulty of allowing mods on a public server.

Which is still putting to one side the already existing reproach that it's up to the scripter to propagate such things in the first place, that's what a multiplayer engine is for.

Share this post


Link to post
Share on other sites
No, because everyone has to already have the addon, just adding to the difficulty of allowing mods on a public server.

Which is still putting to one side the already existing reproach that it's up to the scripter to propagate such things in the first place, that's what a multiplayer engine is for.

What addon? BIS_fnc_MP is ArmA 3 library means if you have ArmA 3 you have BIS_fnc_MP. init.sqf is downloaded automatically when you connect to a server. What addons are you talking about?

Share this post


Link to post
Share on other sites
what are you talking about? if you make your missions without ever touching init.sqf then you are not using even 1 percent of arma potential. you need to learn how to add basic scripts to init.sqf for your own benefit as it executes on every machine because old commands are not coming back.

You DO know you are talking to Defunct, a respected and talented programmer?

Share this post


Link to post
Share on other sites
What addon? BIS_fnc_MP is ArmA 3 library means if you have ArmA 3 you have BIS_fnc_MP. init.sqf is downloaded automatically when you connect to a server. What addons are you talking about?

I give up. This has totally train wrecked for no reason whatsoever.

Defunkt is on about an addon he's written (Or whatever) which uses setvehicleInit. Now, re-read everything he's said thus far, and it'll make a lot more sense. Though, it's still not impossible to fix, and my solution is still valid.

Share this post


Link to post
Share on other sites
You DO know you are talking to Defunct, a respected and talented programmer?

Is this a sarcasm? I haven't been around for as long as you were to get on the joke.

---------- Post added at 11:25 ---------- Previous post was at 11:23 ----------

I give up. This has totally train wrecked for no reason whatsoever.

Defunkt is on about an addon he's written (Or whatever) which uses setvehicleInit. Now, re-read everything he's said thus far, and it'll make a lot more sense. Though, it's still not impossible to fix, and my solution is still valid.

I'm confused even more than Defunkt at this point...

Share this post


Link to post
Share on other sites

Can I just ask, when I make a function to be used by BIS_fnc_MP where am I supposed to put it? Currently it's inside the isServer if statement of my script and the function is to add an action for all players. It is set up to execute the code on all clients but it is still only showing the action for the server. Is this because I need to move the function it is calling outside of the isServer?

Share this post


Link to post
Share on other sites
Can I just ask, when I make a function to be used by BIS_fnc_MP where am I supposed to put it? Currently it's inside the isServer if statement of my script and the function is to add an action for all players. It is set up to execute the code on all clients but it is still only showing the action for the server. Is this because I need to move the function it is calling outside of the isServer?

The function needs to be defined on both client and server, if it's to be ran by the two. So, you need to assign it to a variable that will be set on both client and server. Yes.

Share this post


Link to post
Share on other sites

At this point i'm not making my scripts depending on BIS_fnc_MP, wouldn't be surprised if it changed or even got removed!

Share this post


Link to post
Share on other sites
At this point i'm not making my scripts depending on BIS_fnc_MP, wouldn't be surprised if it changed or even got removed!

This is very correct. So! In regards to addons, I suppose you'll just have to sit still and wait for beta or release, or something. Unless they say 100% that they're not changing it.

Edit: And something you could do to push this to either being 100% fixed, or whatever, is to pound the crap out of BIS's function library backbone and find bugs. Because ALPHA.

Edited by Radioman

Share this post


Link to post
Share on other sites
No, because everyone has to already have the addon, just adding to the difficulty of allowing mods on a public server.

Which is still putting to one side the already existing reproach that it's up to the scripter to propagate such things in the first place, that's what a multiplayer engine is for.

On balance I think it would be preferable to require everyone to have the addon. Transmitting whatever code you wish to be executed is the entire problem, and I guess that feature is just going to go away. The best you mght hope for I suppose is to wrap the call in a test for that addon, no addon, no call. It will mean some people won't see the desired result, but it's better than some knobhead flinging everyone up into the air :)

Share this post


Link to post
Share on other sites

You need to think outside how things are and consider how they might be.

I've long wished there was a greater emphasis among mod makers on creating new functionality that can work without requiring everybody on the server to have exactly the same set of add-ons. For instance, before ACRE there was A2TS, and while it certainly had problems that needed fixing (and were readily fixable), one of the best things about it is that you and a few friends could use it on a server without everybody else having to have it. So you could run a public server, you and your community could enjoy 3D positional sound in TS but your server could still be open to new players without them having to sort out a complicated mod install before even getting a taste of what you were about.

Losing SetVehicleInit just kills a lot of possible functionality that could really help the multiplayer landscape so used, to refer back to my previous example, like an *optional* addon that allowed those players that have it the ability to jump small obstacles, but again, without breaking the game for those that don't have the same addon installed.

---------- Post added at 23:13 ---------- Previous post was at 23:11 ----------

It will mean some people won't see the desired result, but it's better than some knobhead flinging everyone up into the air :)

Sure, but like I first said, it would be even better to cut these kiddies off at the knees by preventing clients from injecting their own scripts rather than just trying to limit the damage they can do.

Share this post


Link to post
Share on other sites
Losing SetVehicleInit just kills a lot of possible functionality that could really help the multiplayer landscape so used, to refer back to my previous example, like an *optional* addon that allowed those players that have it the ability to jump small obstacles, but again, without breaking the game for those that don't have the same addon installed.

You can do all the things you did with setvehicleinit, with BIS_fnc_MP...... You really need to give an example to push this to us. If you're saying "People can't join this server, because one of our mods needs to do netcode stuff, and some people wont have it, because I cannot push it to non-modded players", then you're incorrect.

function = compile {code};

publicvariable 'function';

^ Bam, code sent to all clients. Very much the same way as setvehicleinit did. All you have to do now, is call that passed function via BIS_fnc_MP, which can also call that code on JIP for new players, etc.

Am I missing something?

Share this post


Link to post
Share on other sites
Can I just ask, when I make a function to be used by BIS_fnc_MP where am I supposed to put it? Currently it's inside the isServer if statement of my script and the function is to add an action for all players. It is set up to execute the code on all clients but it is still only showing the action for the server. Is this because I need to move the function it is calling outside of the isServer?

If you go

my_function = {

...code

};

in init.sqf it will exist on both server and all clients.

At this point i'm not making my scripts depending on BIS_fnc_MP, wouldn't be surprised if it changed or even got removed!

Each to their own I guess, but I doubt BIS_fnc_MP is going anywhere. It is now integral part of ArmA 3 library and BIS themselves rely on it.

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  

×