Kolmain 6 Posted November 12, 2014 I'll be referencing my script located here: https://github.com/kmain4/Hotfoot/blob/master/functions/respawn/fn_createRespawnHeli.sqf if I call this function from a (isServer) condition, the units are spawned, but none of the he sideChat or addActions work on any clients. But if I run the script on all clients, it spawns for each client. So what do I need to do to properly execute the script so it only runs once, but all clients have the addaction and sideChats. Share this post Link to post Share on other sites
champ-1 40 Posted November 12, 2014 When you add (isServer) condition, it runs only on server. You can just run sideChat commands via BIS_fnc_MP. [{player sideChat "hello world"},"BIS_fnc_spawn",true] call BIS_fnc_MP; Share this post Link to post Share on other sites
Kolmain 6 Posted November 12, 2014 And the same with addAction? Share this post Link to post Share on other sites
champ-1 40 Posted November 12, 2014 Oh nevermind, sideChat is a global command. It should be fine if you run it from server only. Share this post Link to post Share on other sites
Kolmain 6 Posted November 12, 2014 Oh nevermind, sideChat is a global command. It should be fine if you run it from server only. Nope, I get 0 sideChat messages from that script. edit: when in multiplayer! Single player works fine. Share this post Link to post Share on other sites
champ-1 40 Posted November 12, 2014 Note: This function only types text to the list, it does not broadcast the message. If you want the message to show on all computers, you have to execute it on all of them. Yeah, use BIS_fnc_MP. Share this post Link to post Share on other sites
cruoriss 12 Posted November 12, 2014 In your script you're calling the sidechat on _heli, wich is a vechile . It needs to be a side/player . ( like : player1 sidechat "Blabla" ) Look here : https://community.bistudio.com/wiki/sideChat Share this post Link to post Share on other sites
Kolmain 6 Posted November 12, 2014 Yeah, use BIS_fnc_MP. Ill give it a go. Danke! ---------- Post added at 14:34 ---------- Previous post was at 14:33 ---------- In your script you're calling the sidechat on _heli, wich is a vechile .It needs to be a unit/player . ( like : player1 sidechat "Blabla" ) If you use a vehicle, it uses the driver (commander?). Share this post Link to post Share on other sites
cruoriss 12 Posted November 12, 2014 "If you want the message to show on all computers, you have to execute it on all of them. " It probably uses the driver as you said if it works in sp so it's more a locality issue . BIS_fnc_mp as stated before should fix it . Share this post Link to post Share on other sites
jshock 512 Posted November 12, 2014 (edited) When you add (isServer) condition, it runs only on server. You can just run sideChat commands via BIS_fnc_MP. [{player sideChat "hello world"},"BIS_fnc_spawn",true] call BIS_fnc_MP; You should be able to also just use the script command directly with the latest game update :D : [[player, "hello world"],"sideChat",true] call BIS_fnc_MP; I lied, its not in the list :(, I was thinking systemChat, not side chat. Edited November 12, 2014 by JShock Share this post Link to post Share on other sites
Kolmain 6 Posted November 13, 2014 So I tried it, but this line: [{_heli sideChat format["%1 is departing in 10 seconds with loaded troops, over.", groupID (group _heli)] },"BIS_fnc_spawn",true] call BIS_fnc_MP; But it says that _heli is undefined... Share this post Link to post Share on other sites
champ-1 40 Posted November 13, 2014 (edited) You need to do some trickery to pass local variable in there. Try this: [compile format ["%1 sideChat '%2 is departing in 10 seconds with loaded troops, over.'", _heli, groupID (group _heli)], "BIS_fnc_spawn", true] call BIS_fnc_MP; Edited November 13, 2014 by Champ-1 Share this post Link to post Share on other sites
Kolmain 6 Posted November 14, 2014 Thanks Champ, I'll give it a go tonight and let you know if it works. Share this post Link to post Share on other sites
Tajin 348 Posted November 14, 2014 Jesus... ...why doesn't anyone tell the man to use BIS_fnc_MP properly and create functions? Define this function somewhere: fnc_globalChat = { (_this select 0) globlChat (_this select 1); }; Use this for your message: _message = format["%1 is departing in 10 seconds with loaded troops, over.", groupID (group _heli)]; [[_heli, _message], "fnc_globalChat", true] call BIS_fnc_MP; No weird "compile" trickery needed. Share this post Link to post Share on other sites
jshock 512 Posted November 14, 2014 Jesus......why doesn't anyone tell the man to use BIS_fnc_MP properly and create functions? Define this function somewhere: fnc_globalChat = { (_this select 0) globlChat (_this select 1); }; Use this for your message: _message = format["%1 is departing in 10 seconds with loaded troops, over.", groupID (group _heli)]; [[_heli, _message], "fnc_globalChat", true] call BIS_fnc_MP; No weird "compile" trickery needed. If your using globalChat there is no need to write a function for it because globalChat is remotely executable through BIS_fnc_MP, I had referenced that usage earlier in post #10 of this thread, but at that point it was with sideChat (which is not remotely executable). https://community.bistudio.com/wiki/CfgRemoteExecCommands So for globalChat through BIS_fnc_MP: [[_heli, format["%1 is departing in 10 seconds with loaded troops, over.", groupID (group _heli)]], "globalChat", true] call BIS_fnc_MP; Share this post Link to post Share on other sites
Tajin 348 Posted November 14, 2014 (edited) globalChat is remotely executable through BIS_fnc_MP I know, but it's still good practice to use functions instead. Especially when you want to change something afterwards. Believe me, the little extra effort to write functions can really pay off. ps.: Depending on your mission/server setup, functions are also safer. (provided you use compileFinal or the FunctionLibrary) I personally wouldn't leave "RemoteExecCommands" unprotected. Edited November 14, 2014 by Tajin Share this post Link to post Share on other sites
jshock 512 Posted November 14, 2014 Believe me, the little extra effort to write functions can really pay off. Yep, I do enjoy functions, I'm just getting the info out there cause not too many people are aware of that new functionality :D. Share this post Link to post Share on other sites
Kolmain 6 Posted November 14, 2014 (edited) I prefer functions, so I'll give that approach a try when I get a chance. Thanks! ---------- Post added at 15:17 ---------- Previous post was at 13:54 ---------- Jesus......why doesn't anyone tell the man to use BIS_fnc_MP properly and create functions? Define this function somewhere: fnc_globalChat = { (_this select 0) globlChat (_this select 1); }; Use this for your message: _message = format["%1 is departing in 10 seconds with loaded troops, over.", groupID (group _heli)]; [[_heli, _message], "fnc_globalChat", true] call BIS_fnc_MP; No weird "compile" trickery needed. As I'm coding this I noticed you're using globalChat and not sideChat. I'm looking for the sideChat channel.... ---------- Post added at 15:21 ---------- Previous post was at 15:17 ---------- What do you think about this, I've created this function, KOL_fnc_globalSideChat: if (isMultiplayer) then { [compile format ["%1 sideChat %2", (_this select 0), (_this select 1)], "BIS_fnc_spawn", true] call BIS_fnc_MP; } else { (_this select 0) sideChat (_this select 1); }; Edited November 14, 2014 by Kolmain Share this post Link to post Share on other sites
champ-1 40 Posted November 14, 2014 (edited) BIS_fnc_MP should work in singleplayer too. When you set 3rd parametr to 'true' it will execute on all machines including the one you calling from. Also I don't see the purpose of this function, as you still using BIS_fnc_spawn. You can call your function directly through BIS_fnc_MP, see example above from Tajin. Edited November 14, 2014 by Champ-1 Share this post Link to post Share on other sites
Kolmain 6 Posted November 14, 2014 I'm calling it via [_heli, format["Mayday! Mayday! %1 going down!", groupID (group _heli)]] call KOL_fnc_globalSideChat; ---------- Post added at 15:40 ---------- Previous post was at 15:34 ---------- So would this code get an addAction on all clients? [compile format [ "_takeOffAction = _heli addaction ["<t color='#C2BF19'>Take Off</t>", { %1 removeAction %2; %1 setVariable ["transportReady", false, true]; [%3, "All in, dust off!"] call KOL_fnc_globalVehicleChat; sleep 2; ", (_this select 0), (_this select 2), (_this select 1)], "BIS_fnc_spawn", true] call BIS_fnc_MP; Share this post Link to post Share on other sites
champ-1 40 Posted November 14, 2014 Read this: https://community.bistudio.com/wiki/BIS_fnc_MP First parameter are the arguments you passing into the function (in case of "BIS_fnc_spawn" your passing code you want to spawn). Second is the name of function, it can be any global function. Or if you don't have much code to create independent function for that you can just use BIS_fnc_spawn instead. That's what we did. Third parameter defines where to execute given function. Share this post Link to post Share on other sites
Kolmain 6 Posted November 14, 2014 Read this:https://community.bistudio.com/wiki/BIS_fnc_MP First parameter are the arguments you passing into the function (in case of "BIS_fnc_spawn" your passing code you want to spawn). Second is the name of function, it can be any global function. Or if you don't have much code to create independent function for that you can just use BIS_fnc_spawn instead. That's what we did. Third parameter defines where to execute given function. Right, but the problem is my local variables aren't in scope in that arguments array? Share this post Link to post Share on other sites
champ-1 40 Posted November 14, 2014 (edited) In case of "BIS_fnc_spawn" you passing ready to use code, so you need to squeeze local variables in there somehow. If you call your custom function with BIS_fnc_MP, you can just pass array of local variables [[_heli, _group, _whatever], "MY_fnc_heli", true] call BIS_fnc_MP; ---------- Post added at 23:01 ---------- Previous post was at 21:31 ---------- I guess you can pass local variables normally into "BIS_fnc_spawn" too. So instead of this: [compile format ["%1 sideChat '%2 is departing in 10 seconds with loaded troops, over.'", _heli, groupID (group _heli)], "BIS_fnc_spawn", true] call BIS_fnc_MP; you could do this: [[[_heli], {(_this select 0) sideChat format ["%1 is departing in 10 seconds with loaded troops, over.", groupID (group (_this select 0))]}], "BIS_fnc_spawn", true] call BIS_fnc_MP; It's a little bit easier to understand. Edited November 14, 2014 by Champ-1 Share this post Link to post Share on other sites
Kolmain 6 Posted November 15, 2014 I got ti working with your suggestions, thanks everyone! :D Share this post Link to post Share on other sites