Jump to content
Sign in to follow this  
Whiplash

[ACRE2] Predefining channels and switching channels

Recommended Posts

So, I tried to implement a script into my mission that automatically programs channel names and that switches radio channels depending on what unit it is.
 
I tried to stick strictly to the format shown here: http://acre.idi-systems.com/api/examples.html#company-rto-setup-script
 
All I did was I changed the channel names, added all the 3 main radios (I did consider the different labels for each radio type) and then expanded the case definition at the end.
 
Now, without going too much into detail, the script did not work. I had to switch the piece of code I entered into the units init to make it work in the editor.
 
 

// This did not work, but gave me an error ("missing ;"). Of course I renamed the script itself and changed the line of code accordingly.
[this, "platoon_rto"] call compile "scripts\acre_init.sqf";
 
// This did work. Though I have no idea what I did there ...
[this, "platoon_rto"] call compile preprocessFileLineNumbers "scripts\acre_init.sqf";

 
 

// First few lines of codes from my "acre_init.sqf" (more or less the same script I linked above) and the condition switch:
//if(isDedicated) exitWith {}; (commented out on purpose though I cannot say why....)
 
private["_unit", "_localUnitType"];
_unit = _this select 0;
_localUnitType = _this select 1;
 
waitUntil {[] call acre_api_fnc_isInitialized};
 
if(_unit != player) exitWith { false };
 
 
//....
//.... --> Here are the different channel names for the PRC148, PRC152, PRC117F
//....
  

if(isDedicated) exitWith { false };
 
_this spawn {
        _unit = _this select 0;
        _localUnitType = _this select 1;
 
        waitUntil { ([] call acre_api_fnc_isInitialized) };
 
        switch _localUnitType do {
 
//...
//... --> Here are the different units and the desired code to switch channels
//...
 

 
 
I tried to relocate the script into my root mission folder and change the path accordingly, but nothing changed. Anyway, so that second piece of code worked and I was happy. However, when I tested it in MP (locally hosted and on SRV4), the script again did not work. I got no error message or anything. I also could not find anything wrong in the rpt file.
 
Does anyone know what causes this to work perfectly fine in SP (editor) but not in an MP environment? I am assuming I messed up either the piece of code I entered in the players init (see above) or the script wont get executed correctly in an MP environment. Sadly I have no idea why. Especially as I am confident that I precisely followed the code found on the site linked above.
Since the channel names are all the default names in MP (CH01,...) I figured that even the first bit of the script does not fire correctly.
 
 
Note: I triple checked all variable names and all other important words. I did change the channel names and unit names in my own script but that cannot be the root of the error as it is working perfectly fine in SP (shows all the custom channel names and whatever unit I select has the desired predefined radio channel selected for all of the 5 main radios).

Share this post


Link to post

Noone any clue? I know that something similar is implemented in the Zeus missions, at least players there start with the correct channel and the long range nets already have custom names. So I figured maybe someone could guide me in the right direction on how to implement this.

Share this post


Link to post

I use this script to set the channels and spatialization:


	private ["_group","_radioList"];

	_group = groupId(group player);

	waitUntil {[] call acre_api_fnc_isInitialized};

	_radioList = [] call acre_api_fnc_getCurrentRadioList;
	switch _group do {
		case "PLT HQ": {
			{if ([_x, "ACRE_PRC343"] call acre_api_fnc_isKindOf) then {[_x,5] call acre_api_fnc_setRadioChannel; [_x,"LEFT"] call acre_api_fnc_setRadioSpatial}} forEach _radioList;
			{if ([_x, "ACRE_PRC148"] call acre_api_fnc_isKindOf) then {[_x,"RIGHT"] call acre_api_fnc_setRadioSpatial}} forEach _radioList;
		};
		case "1'1": {
			{if ([_x, "ACRE_PRC343"] call acre_api_fnc_isKindOf) then {[_x,1] call acre_api_fnc_setRadioChannel; [_x,"LEFT"] call acre_api_fnc_setRadioSpatial}} forEach _radioList;
			{if ([_x, "ACRE_PRC148"] call acre_api_fnc_isKindOf) then {[_x,"RIGHT"] call acre_api_fnc_setRadioSpatial}} forEach _radioList;
		};
		case "1'2": {
			{if ([_x, "ACRE_PRC343"] call acre_api_fnc_isKindOf) then {[_x,2] call acre_api_fnc_setRadioChannel; [_x,"LEFT"] call acre_api_fnc_setRadioSpatial}} forEach _radioList;
			{if ([_x, "ACRE_PRC148"] call acre_api_fnc_isKindOf) then {[_x,"RIGHT"] call acre_api_fnc_setRadioSpatial}} forEach _radioList;
		};
		case "1'3": {
			{if ([_x, "ACRE_PRC343"] call acre_api_fnc_isKindOf) then {[_x,3] call acre_api_fnc_setRadioChannel; [_x,"LEFT"] call acre_api_fnc_setRadioSpatial}} forEach _radioList;
			{if ([_x, "ACRE_PRC148"] call acre_api_fnc_isKindOf) then {[_x,"RIGHT"] call acre_api_fnc_setRadioSpatial}} forEach _radioList;
		};
	};
Edited by zumorc

Share this post


Link to post

Thanks for the reply.

 

I took a look at the Zeus mission and it seems to be similar to zumorc's code up there. I am guessing that code is executed on mission start and only takes into account the different groups. I was hoping I could get mine to work as I could give each individual player a specific channel if needed (helpful if you have a group including JTAC's, FO's, SL, etc.).

 

Guess I can only keep playing around with different commands and hope it will work out eventually. But since it is working fine in SP I was hoping someone would spot an error in the scripts execution or in the command which is used to call the script.

 

Not sure if related to this, but I use a similar structure to apply unit insignias to the units. Same happened. It works perfectly fine in SP, but when testing in MP the insignias will not be applied.

Did I screw up the way I am executing those commands in the init? Though, why would it work then in SP? I will just paste in an example init of one of my units, maybe someone sees why this only gets executed in SP:

 

BW_292_2COY_1PLT_1SQD = group this;
group this setGroupID ["2./292 A-PLT 1-SQD- "];
{_x stop true;} forEach units BW_292_2COY_1PLT_1SQD;
[this, "WEST", "BW_292_2COY_1PLT_SL"] call tb3_fLoadout;
[this, "SL"] call BIS_fnc_setUnitInsignia;
[this, "BW_292_2COY_1PLT_1SQD_SL"] call compile preprocessFileLineNumbers "scripts\client_side\acre_init.sqf";

 

Each unit has a similar init field, just different parameters. When testing the mission in SP, everything works like a charm. But in MP, the last two commands (Insignia and ACRE) are not being executed. Everything else is executed in MP and SP.

Share this post


Link to post

Well you obviously then have to modifiy the script and have it based on your unit names, or whatever you wanna use to identify the individuals for which the channel settings apply.

 

the unit insigina thing apparently needs to be excuted using  BIS_fnc_MP:

[[1SQD_SL, "SL"], "BIS_fnc_setUnitInsignia", nil, true, true] call BIS_fnc_MP;

Not so sure why the acre script is not working. Is the script itself not firing? (try to include some hint commands to track where it fails.

Share this post


Link to post

Script is not firing at all. A hint set in the very beginning (even before setting channel names) never showed up, nor any other hint placed at different places inside the script. Is there any way to also execute the script using the BIS_fnc_MP or something similar?

 

The second line of code of my first code block in the OP still fires in SP though. Just won't execute in MP.

 

 

After a quick check on a locally hosted MP session the insignias now also work perfectly in MP with BIS_fnc_MP!

Share this post


Link to post

After many more tries to get it to work I am about to give up on this and just expect people to tune in the correct channels themselves....

 

I managed to split the script in half and have the channel names be executed separately from the case definition for the individual units. This helped me as I am now able to have the channels named correctly for all players joining the game (JIP and dedicated server testing pending).

 

However, whatever I try, I don't seem to be able to get the second half of the script to fire at all in an MP environment. The script currently looks like this:

// file: \scripts\acre.sqf
 
//if(isDedicated) exitWith {};
 
private["_unit", "_localUnitType"];
_unit = _this select 0;
_localUnitType = _this select 1;
 
hint "Script preinit!!!";
 
if(_unit != player) exitWith { false };
 
hint "Script executed...";
 
//if(isDedicated) exitWith { false };
 
_this spawn {
        _unit = _this select 0;
        _localUnitType = _this select 1;
 
        waitUntil { ([] call acre_api_fnc_isInitialized) };
        
        hint "Entering CASE definition";
 
        switch _localUnitType do {
            
                // Mission Commander
                case 'BW_FOB_MC': {
                        hint "CASE entered";
                        [ (["ACRE_PRC148"] call acre_api_fnc_getRadioByType), 1] call acre_api_fnc_setRadioChannel;
                        [ (["ACRE_PRC152"] call acre_api_fnc_getRadioByType), 2] call acre_api_fnc_setRadioChannel;
                        ["ACRE_PRC148", "LEFT" ] call acre_api_fnc_setRadioSpatial;
                        ["ACRE_PRC152", "RIGHT" ] call acre_api_fnc_setRadioSpatial;
                        hint "Script done";
                };
 
// .....
// ..... --> Some more cases to follow, nothing else
// .....
 
 
In SP, it fires with no error at all and works like intended. In MP, however, it does do nothing. I tried it by using different ways to execute it, including transforming it into a function and then call the function. No joy....
I am at the end of my scripting knowledge and I am about done spending time on this. Again, if anyone sees anything obvious that makes this non functional in MP, don't hesitate to share it. Would really appreciate it.
 
Just for completions sake, here are the different ways I used to call the above function:
// all these commands are run within the units init fiels:
 
// Variant 1
[this, "BW_FOB_MC"] call compile preprocessFileLineNumbers "scripts\acre.sqf";
 
// Variant 2
[this, "BW_FOB_MC"] call whip_fnc_acreInit; // --> The function is initiated in my init file and this too works in SP just fine.
 
// Variant 3
[[this, "BW_FOB_MC"], "whip_fnc_acreInit", nil, true, true] call BIS_fnc_MP;
Edited by Whiplash

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...