Sweetwater.I 10 Posted October 16, 2017 Hello, I'm trying to make heads or tails of getting around an error that I'm getting when attempting to make Radio Channels to specific units to private communication between Zeus to Squad Leaders. The error is that the variables are undefined for the radioChannelCreate when the unit with the variable does not exist. I'm thinking I will need a !isnull check to an array but I'm unsure how to implement this as I am still very new to Arma scripting. Here is the code I am using, Most of this is from a script I found on another post: if(isServer) then { west_channel = radioChannelCreate [[0, 0.2, 1, 1], "GM-Bluefor", "Game Master", [bz1,bz2,mz1,mz2]]; east_channel = radioChannelCreate [[1, 0, 0.2, 1], "GM-Redfor", "Game Master", [rz1,mz1,mz2]]; independent_channel = radioChannelCreate [[0, 1, 0.2, 1], "GM-Independent", "Game Master", [iz1,mz1,mz2]]; RADIO_fnc_manage = { private["_unit","_channel","_bool"]; _unit = [_this,0,ObjNull,[ObjNull]] call BIS_fnc_param; _bool = [_this,1,false,[false]] call BIS_fnc_param; _channel = [_this,2,0,[0]] call BIS_fnc_param; //Series of checks? if(isNull _unit) exitWith {}; //Null unit if(_channel < 1) exitWith {}; //No channels below 1 should be passed. switch (_channel) do { case 1: { if(_bool) then {west_channel radioChannelAdd [_unit];} else {west_channel radioChannelRemove [_unit];};}; case 2: { if(_bool) then {east_channel radioChannelAdd [_unit];} else {east_channel radioChannelRemove [_unit];};}; case 3: { if(_bool) then {independent_channel radioChannelAdd [_unit];} else {independent_channel radioChannelRemove [_unit];};}; }; }; }; Variables "bz1, bz2, mz1, mz2, iz1, rz1" is referencing unit's I've placed within Eden Editor with those variables tagged to them. E.g, "bz1" = Blufor Zeus or "mz1" = Master Zeus The intention of this script is to allow private communication from Squad leaders. (In this case bz1,bz2,iz1,rz1) to have separate channels to the two Master Zeus's which will be acting as "game masters" That is not seen by anyone outside of the units aforementioned. > I am using RHS, ACE, CBA Pack, ARES:Achilles and TFAR mod's as well. Share this post Link to post Share on other sites
HazJ 1289 Posted October 17, 2017 Works fine here. Just tested using your code above, I only changed the unit variable names (bp_1, bp_2, bp_3, bp_4). Where do you call the RADIO_fnc_manage function? Also, make sure the unit variable names are correct and exist in the editor. On client: [player] remoteExec ["RADIO_fnc_manage", ([0, -2] select isDedicated), false]; I guess you could have it all together if you wanted. Make a forEach that loops through playableUnits then add _x to the channel. Whichever you want. { // blah blah blah // Use _x instead of _unit // You'll probably want channel to show for specific side or units so either do unit check (in array or a certain slot), etc... } forEach playableUnits; Screenshot here! I added all channels to myself just for testing purposes. Share this post Link to post Share on other sites
Sweetwater.I 10 Posted October 17, 2017 Thanks for checking it out, For the RADIO_fnc_manage, I was calling via the unit(s) init. As for the error message I'm getting, its showing up on mission start. Normally I would Ignore these messages, but its for a MP mission I'm building and I'm unsure if this is gonna effect JIP. Share this post Link to post Share on other sites
HazJ 1289 Posted October 17, 2017 You shouldn't ever ignore these messages, SP or MP. Did you try what I said? [player] remoteExec ["RADIO_fnc_manage", ([0, -2] select isDedicated), false]; Put the above in init.sqf file. EDIT: Try this: initServer.sqf west_channel = radioChannelCreate [[0, 0.2, 1, 1], "GM-Bluefor", "Game Master", [bz1, bz2, mz1, mz2]]; east_channel = radioChannelCreate [[1, 0, 0.2, 1], "GM-Redfor", "Game Master", [rz1, mz1, mz2]]; independent_channel = radioChannelCreate [[0, 1, 0.2, 1], "GM-Independent", "Game Master", [iz1, mz1, mz2]]; RADIO_fnc_manage = { private ["_unit", "_channel", "_bool"]; _unit = [_this, 0, objNull, [objNull]] call BIS_fnc_param; _bool = [_this, 1, false, [false]] call BIS_fnc_param; _channel = [_this, 2, 0, [0]] call BIS_fnc_param; if ((isNull _unit)) exitWith {}; if ((_channel < 1)) exitWith {}; switch (_channel) do { case 1 : { if ((_bool)) then { west_channel radioChannelAdd [_unit]; } else { west_channel radioChannelRemove [_unit]; }; }; case 2 : { if ((_bool)) then { east_channel radioChannelAdd [_unit]; } else { east_channel radioChannelRemove [_unit]; }; }; case 3 : { if ((_bool)) then { independent_channel radioChannelAdd [_unit]; } else { independent_channel radioChannelRemove [_unit]; }; }; }; }; init.sqf [player] remoteExec ["RADIO_fnc_manage", ([0, -2] select isDedicated), false]; Example mission: https://1drv.ms/u/s!ArYSs9w5RSIDhDRnUTxePyxL_gox Share this post Link to post Share on other sites
Sweetwater.I 10 Posted October 17, 2017 Awesome! Thank you HazJ Seems to be working now, Each unit appears to have its own channel to the Master Zeus's. and no error. I tried it via Multiplayer and it shows again, but single player works. I assume the error message will pop up when going into MP as I have AI disabled (aka unit does not exist unless player is in slot). Share this post Link to post Share on other sites
HazJ 1289 Posted October 17, 2017 Fixed. Example mission link updated. init.sqf enableSaving [false, false]; waitUntil {(!isNull player)}; // Just in case. Needed...??? switch ((side player)) do { case blufor : { west_channel_units pushBack player; publicVariable "west_channel_units"; [player, true, west_channel] remoteExec ["RADIO_fnc_manage", ([0, -2] select isDedicated), false]; }; case opfor : { east_channel_units pushBack player; publicVariableServer "east_channel_units"; [player, true, east_channel] remoteExec ["RADIO_fnc_manage", ([0, -2] select isDedicated), false]; }; case independent : { independent_channel_units pushBack player; publicVariableServer "independent_channel_units"; [player, true, independent_channel] remoteExec ["RADIO_fnc_manage", ([0, -2] select isDedicated), false]; }; }; initServer.sqf west_channel_units = []; publicVariable "west_channel_units"; east_channel_units = []; publicVariable "east_channel_units"; independent_channel_units = []; publicVariable "independent_channel_units"; west_channel = radioChannelCreate [[0, 0.2, 1, 1], "GM-Bluefor", "Game Master", []]; east_channel = radioChannelCreate [[1, 0, 0.2, 1], "GM-Redfor", "Game Master", []]; independent_channel = radioChannelCreate [[0, 1, 0.2, 1], "GM-Independent", "Game Master", []]; RADIO_fnc_manage = { private ["_unit", "_channel", "_bool"]; _unit = [_this, 0, objNull, [objNull]] call BIS_fnc_param; _bool = [_this, 1, false, [false]] call BIS_fnc_param; _channel = [_this, 2, 0, [0]] call BIS_fnc_param; if ((isNull _unit)) exitWith {}; if ((_channel < 1)) exitWith {}; switch (_channel) do { case 1 : { if ((_bool)) then { west_channel radioChannelAdd [_unit]; } else { west_channel radioChannelRemove [_unit]; }; }; case 2 : { if ((_bool)) then { east_channel radioChannelAdd [_unit]; } else { east_channel radioChannelRemove [_unit]; }; }; case 3 : { if ((_bool)) then { independent_channel radioChannelAdd [_unit]; } else { independent_channel radioChannelRemove [_unit]; }; }; }; }; Code may be a little sloppy but it's 03:23 (am) here and I need sleep ha! :D EDIT: Just had a quick look over the code again and noticed the {side}_channel_units variables aren't doing anything. I have a feeling anyone on that side will be added... My brain hurts at the moment. Maybe you can test and let me know? I'll clean it up later. I guess my intention with those variables was to check player slot against whitelisted slots (who should have the channels). Share this post Link to post Share on other sites
Sweetwater.I 10 Posted October 17, 2017 Hmm... With that added, All Blufor units (west) are seeing the Redfor channel. Redfor is seeing Independant. and Independant and Master Zeus have no additional channels. Was thinking about setVariable on the unit's init with a if isPlayer, not sure if that would work. But its really late here as well. Thanks for all your help so far! Share this post Link to post Share on other sites
Tajin 349 Posted October 17, 2017 I have no idea if radioChannelAdd needs to be called locally. My guess would've been to just call it on the server. //initServer.sqf west_channel = radioChannelCreate [[0, 0.2, 1, 1], "GM-Bluefor", "Game Master", [bz1, bz2, mz1, mz2]]; east_channel = radioChannelCreate [[1, 0, 0.2, 1], "GM-Redfor", "Game Master", [rz1, mz1, mz2]]; independent_channel = radioChannelCreate [[0, 1, 0.2, 1], "GM-Independent", "Game Master", [iz1, mz1, mz2]]; //initPlayerServer.sqf params["_player","_jip"]; local["_sides","_channels","_channel"]; _sides = [blufor,opfor,independent]; _channels = [west_channel,east_channel,independent_channel]; _channel = _channels select ((side player) find _sides); _channel radioChannelAdd [_player]; Share this post Link to post Share on other sites
Sweetwater.I 10 Posted October 17, 2017 Hi Tajin, To better help visualize I've made a crude graphic, here is the current issue I am seeing. [x Slots] is just to say how many slots are on that side for players. Share this post Link to post Share on other sites
Tajin 349 Posted October 17, 2017 Ah I see. In that case... //initServer.sqf channels = [ [ radioChannelCreate [[0, 0.2, 1, 1], "GM-Bluefor", "Game Master", []] , [bz1, bz2, mz1, mz2] ], [ radioChannelCreate [[1, 0, 0.2, 1], "GM-Redfor", "Game Master", []] , [rz1, mz1, mz2] ], [ radioChannelCreate [[0, 1, 0.2, 1], "GM-Independent", "Game Master", []] , [iz1, mz1, mz2] ] ]; //initPlayerServer.sqf params["_player","_jip"]; local["_i","_sides","_channel"]; _sides = [blufor,opfor,independent]; _i = (side player) find _sides; _list = (channels select _i) select 1; _channel = (channels select _i) select 0; if (_player in _list) then { _channel radioChannelAdd [_player]; }; Share this post Link to post Share on other sites
Sweetwater.I 10 Posted October 17, 2017 Aww I was hoping that was it, sadly I'm still getting undefined variable errors. and a different one now.Tailed RPT Log: 10:45:53 Error in expression <1], "GM-Bluefor", "Game Master", []] , [bz1, bz2, mz1, mz2] ], [ radioChannelCre> 10:45:53 Error position: <bz1, bz2, mz1, mz2] ], [ radioChannelCre> 10:45:53 Error Undefined variable in expression: bz1 10:45:53 File C:\~\initServer.sqf, line 2 10:45:53 A null object passed as a target to RemoteExec(Call) 'bis_fnc_shownotification' 10:45:53 A null object passed as a target to RemoteExec(Call) 'bis_fnc_shownotification' 10:45:53 Error in expression <erServer.sqf" params["_player","_jip"]; local["_i","_sides","_channel"]; _sides> 10:45:53 Error position: <local["_i","_sides","_channel"]; _sides> 10:45:53 Error local: Type Array, expected Object,Group 10:45:53 File C:\~\initPlayerServer.sqf, line 2 Share this post Link to post Share on other sites
Sweetwater.I 10 Posted October 20, 2017 Ended up with this solution, started pulling my hair out attempting to get a variable so I decided classname was next best thing... if ( isDedicated ) then { private _channeln1 = "Blufor-GM"; private _channeln2 = "Opfor-GM"; private _channeln3 = "Independant-GM"; private _channel1 = radioChannelCreate [[0, 0.2, 1, 1], _channeln1, "Game Master", []]; private _channel2 = radioChannelCreate [[1, 0, 0.2, 1], _channeln2, "Game Master", []]; private _channel3 = radioChannelCreate [[0, 1, 0.2, 1], _channeln3, "Game Master", []]; if (_channel1 == 0) exitWith {diag_log format ["Custom channel '%1' creation failed!", _channeln1]}; if (_channel2 == 0) exitWith {diag_log format ["Custom channel '%1' creation failed!", _channeln2]}; if (_channel3 == 0) exitWith {diag_log format ["Custom channel '%1' creation failed!", _channeln3]}; missionNamespace setvariable ["blueforgm",_channel1]; missionNamespace setvariable ["opforgm",_channel2]; missionNamespace setvariable ["guergm",_channel3]; }; _bluelist = ["rhsusf_army_ocp_officer","C_Soldier_VR_F"]; _redlist = ["LOP_ISTS_OPF_Infantry_SL","C_Soldier_VR_F"]; _greenlist = ["LOP_AM_Infantry_SL","C_Soldier_VR_F"]; _iamblue = ({typeOf player == _x} count _bluelist) > 0; _iamred = ({typeOf player == _x} count _redlist) > 0; _iamgreen = ({typeOf player == _x} count _greenlist) > 0; if (_iamblue) then { _blueforgm = missionnamespace getvariable "blueforgm"; _blueforgm radioChannelAdd [player]; }; if (_iamred) then { _opforgm = missionnamespace getvariable "opforgm"; _opforgm radioChannelAdd [player]; }; if (_iamgreen) then { _guergm = missionnamespace getvariable "guergm"; _guergm radioChannelAdd [player]; }; Share this post Link to post Share on other sites