Jump to content

Recommended Posts

Mod the Arma 3 main menu center spotlight button to join a specific server with 1 click.

Based on KK's work.

4IaeoN2.png

 

See it in action.

GitHub

 

Main components:

config.cpp

class CfgPatches {
    class amp_spotlight {
        units[] = {};
        weapons[] = {};
        requiredVersion = 0.6;
        requiredAddons[] = {};
        version = 2.0;
        versionStr = 2.0;
        versionAr[] = {2, 0};
        author = "Ampersand";
    };
};

class RscStandardDisplay;
class RscDisplayMain: RscStandardDisplay
{
	class Spotlight
	{
		class AwesomeServer
		{
			text = "[ OFFICIAL ] Arma 3 Zeus by Bohemia Interactive (EU) #15"; // Text displayed on the square button, converted to upper-case
			textIsQuote = 0; // 1 to add quotation marks around the text
			picture = "\amp_spotlight\button.paa"; // Square picture, ideally 512x512
			//video = "\a3\Ui_f\Video\spotlight_1_Apex.ogv"; // Video played on mouse hover
			//action = "0 = [_this, 'your.domain.here', '2302', 'yourpasshere'] execVM '\amp_spotlight\joinServer.sqf';";
			action = "0 = [_this, '85.190.155.165', '2302', ''] execVM '\amp_spotlight\joinServer.sqf';";
			actionText = "Join server: [ OFFICIAL ] Arma 3 Zeus by Bohemia Interactive (EU) #15"; // Text displayed in top left corner of on-hover white frame
			condition = "true"; // Condition for showing the spotlight
		};
	};
};

joinServer.sqf

#include "\A3\Ui_f\hpp\defineResincl.inc"

params 								
[
    ["_buttons", []],
    ["_IP", "127.0.0.1"], 
    ["_PORT", "2302"],
    ["_PASS", ""], 
    ["_TIMEOUT", 30]
];

ctrlactivate ((ctrlparent (_buttons # 0)) displayctrl 105);

/*
1	_IP
2	_PORT
3	_PASS
4	IDC_CANCEL
5	IDD_MISSION
6	IDD_DEBRIEFING
7	IDD_MP_SETUP
8	IDD_MULTIPLAYER
9	IDC_MULTI_TAB_DIRECT_CONNECT
10	IDD_IP_ADDRESS
11	IDC_IP_ADDRESS
12	IDC_IP_PORT
13	IDC_MULTI_SESSIONS
14	IDC_OK
15	IDC_MULTI_JOIN
16	IDD_PASSWORD
17	IDC_PASSWORD
18	diag_tickTime + _TIMEOUT
*/

onEachFrame format [
"
    onEachFrame 
    {
		ctrlActivate (findDisplay %8 displayCtrl %9);
		
		onEachFrame
		{
			private _ctrlServerAddress = findDisplay %10 displayCtrl 2300;
			_ctrlServerAddress controlsGroupCtrl %11 ctrlSetText ""%1""; 
			_ctrlServerAddress controlsGroupCtrl %12 ctrlSetText ""%2"";
			ctrlActivate (_ctrlServerAddress controlsGroupCtrl %14);
			
			onEachFrame 
			{   
				((findDisplay %8 displayCtrl %13) lbData 0) call 
				{
					if (diag_tickTime > %18) then
					{
						diag_log ""RCTS Timeout (no server)"";
						onEachFrame {};
					};
					
					if !(_this isEqualTo '') then
					{
						findDisplay %8 displayCtrl %13 lbSetCurSel 0;
						
						onEachFrame 
						{
							ctrlActivate (findDisplay %8 displayCtrl %15);
							
							onEachFrame 
							{                       
								if (diag_tickTime > %18) then
								{
									diag_log ""RCTS Timeout (cannot join)"";
									onEachFrame {};
								};
								
								if (!isNull findDisplay %16) then
								{
									private _ctrlPassword = findDisplay %16 displayCtrl %17;
									_ctrlPassword ctrlSetTextColor [0,0,0,0];
									_ctrlPassword ctrlSetText ""%3"";
									ctrlActivate (findDisplay %16 displayCtrl %14);
								};
								
								if (getClientStateNumber >= 3) then
								{
									diag_log ""RCTS Success"";
									onEachFrame {};
								};
							};
						};
					};
				};
			};
		};
    };
", _IP, _PORT, _PASS, IDC_CANCEL, IDD_MISSION, IDD_DEBRIEFING, IDD_MP_SETUP, IDD_MULTIPLAYER, 
IDC_MULTI_TAB_DIRECT_CONNECT, IDD_IP_ADDRESS, IDC_IP_ADDRESS, IDC_IP_PORT, IDC_MULTI_SESSIONS, 
IDC_OK, IDC_MULTI_JOIN, IDD_PASSWORD, IDC_PASSWORD, diag_tickTime + _TIMEOUT];

 

  • Like 3
  • Thanks 4

Share this post


Link to post
Share on other sites

Pretty cool actually, never would have thought about something like this. Nice one mate!

Share this post


Link to post
Share on other sites

Button fails if there are cached lines in servers listbox. This can happen if you have working LAN server and last MP page was LAN.

To fix it double onEachFrame after JOIN button pressing, it will skip 1 frame and clear cached servers:

			ctrlActivate (_ctrlServerAddress controlsGroupCtrl %14);
			
			onEachFrame 
			{ onEachFrame {
				((findDisplay %8 displayCtrl %13) lbData 0) call 

Also

actionText = "$STR_disp_multi_join"

is most suitable localized string for config.

  • Thanks 1

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

×