monotone 3 Posted March 15, 2014 (edited) I'm making a script about light object. I want to create a growing helper when any user in MP call it. So,my script includes setlightbrightness which works only on executed machine. I found BIS_fnc_MP but it only works with functions,not commands. How can I execute "local" commands on every machine? Edited March 18, 2014 by Monotone Share this post Link to post Share on other sites
na_palm 19 Posted March 15, 2014 A function can be anything from a one line command to code of several 100th of lines. - So put your "one liner", :) noting bad about it, in an extra file, - compile that file on computers needed or everywhere, - hand the function over to BIS_fnc_MP. For more specific help, more details are needed. greetings Na_Palm Share this post Link to post Share on other sites
jacmac 2 Posted March 15, 2014 (edited) A function looks like this (let us assume this is in init.sqf): FUNC_I_WANT_EXECUTED = { _a_passed_parameter = _this select 0; hint format ["My function just executed%1",_a_passed_parameter]; }; To use the function somewhere in another script executed everywhere: [[", because I called it."],"FUNC_I_WANT_EXECUTED",nil,true] spawn BIS_fnc_MP; or locally: [", because I called it."] call FUNC_I_WANT_EXECUTED; Should produce a hint with "My function just executed, because I called it." (assuming I have not made any syntax errors here). Edited March 15, 2014 by Jacmac Share this post Link to post Share on other sites
Johnson11B2P 3 Posted March 15, 2014 Two options. First create a file called initPlayerLocal.sqf and everything that you have inside that file will run local to the player when they connect to the mission. There you can easily put the command without using BIS_fnc_MP. Second if you call it through a script you try this out. [[{*Your code*}],"BIS_fnc_Spawn",target,false] spawn BIS_fnc_MP; Share this post Link to post Share on other sites
fight9 14 Posted March 15, 2014 Shouldn't use BIS_fnc_spawn with fnc_MP. It will work, that's true. But the way it works is overkill and can hurt performance. The way it was explained to me, is that will will be run globally for each person. Not the way you want though. Each person will send the command to everyone else. So if you have 5 players, and you use the code above, it will be executed 25 times. That's the most common useage you see on the BIS forums here, but it's not right. Much better to make your own function and send that through fnc_MP. Share this post Link to post Share on other sites
Johnson11B2P 3 Posted March 16, 2014 BIS_fnc_Spawn shouldn't spawn something globally. That is why I put target in the target parameter for BIS_fnc_MP so it will only execute for that object only. BIS_fnc_Spawn private ["_params","_code"]; _params = []; _code = [_this,0,{},[{},[]]] call bis_fnc_param; if (typename _code == typename []) then { _params = [_this,0,[]] call bis_fnc_param; _code = [_this,1,{},[{}]] call bis_fnc_param; }; _params call _code Share this post Link to post Share on other sites
monotone 3 Posted March 21, 2014 It finally works on my environment. Thank you guys! Share this post Link to post Share on other sites