Jump to content

Recommended Posts

I have created a simple dialog , but I only want admin or certain playersID to be able to use it any idea how I can just allow admin's or certain players to have aces to it  and link it to a Key ?

 

Thanks

 

 

Share this post


Link to post
Share on other sites

OK  so a little more help now please :)

 

This is what i have so far , what I am trying to do is if I press  f10 I need it to open up my dialog - but not having much luck :(

/*
 =======================================================================================================



 =======================================================================================================
*/

private [ "_access" ];
_access = false;

if ( isMultiplayer ) then
{
	private [ "_uid" ];
	_uid = getPlayerUID player;

	switch ( _uid ) do
	{
		case "76561198027698xxxxxx":
		{

			_access = true;
		};

		case "76561198027698xxxxx":
		{

			_access = true;

		};

		default	{ _access = false; };
	};
} else { _access = true;};


if ( ! _access ) exitWith {};

////Run My dialog if F10 is pressed run the dialog////

onKeyPress = compile preprocessFile "runthisscript.sqf";   ///  run my dialoge 
waituntil {!(IsNull (findDisplay 46))};
(findDisplay 46) displaySetEventHandler ["KeyDown", "_this call onKeyPress;"];

 

Share this post


Link to post
Share on other sites
#include "\a3\ui_f\hpp\definedikcodes.inc"

_adminIDs = [ "76561198027698xxxxxx", "76561198027698xxxxxx" ];

if (
	hasInterface &&		//Client machine
	{
		!isMultiplayer ||	//SP
		{ getPlayerUID player in _adminIDs } ||		//Predefined admin
		{ serverCommandAvailable "#exportjipqueue" } ||		//Logged in admin
		{ !isNil { missionNamespace getVariable "BIS_fnc_admin" } && { call BIS_fnc_admin isEqualTo 2 } }	//Logged in admin, A3 version 1.70 maybe?
	}
) then {
	waitUntil { !isNull ( findDisplay 46 ) };
	( findDisplay 46 ) displayAddEventHandler [ "KeyDown", {
		params[ "_display", "_keyCode", "_shft", "_ctr", "_alt" ];
		
		if ( _keyCode isEqualTo DIK_F10 ) then {
			//open display here
		};
	} ];
};

And you can take your pick from the conditions I have added in the IF statement to determine who is an admin.

  • Like 1

Share this post


Link to post
Share on other sites

Many thanks for that Awesome !

 

This is causing a A3 crash  #include "a3\ui_f\hpp\definedikcodes.inc"   

 

Any idea why it said it is not found?

Share this post


Link to post
Share on other sites
59 minutes ago, 1para{god-father} said:

This is causing a A3 crash  #include "a3\ui_f\hpp\definedikcodes.inc"   

 

Any idea why it said it is not found?

Sorry forgot the backslash in front of a3. Fixed code in previous post.

Share this post


Link to post
Share on other sites

Hi,

 

To make this work on dedi would i just need to change as below ?  , as tried that but still get nothing on dedi when i try i hit f10

!isMultiplayer ||	//SP   to   isMultiplayer ||	

 

Thanks

Share this post


Link to post
Share on other sites
10 minutes ago, 1para{god-father} said:

Hi,

 

To make this work on dedi would i just need to change as below ?  , as tried that but still get nothing on dedi when i try i hit f10


!isMultiplayer ||	//SP   to   isMultiplayer ||	

 

Thanks

 

isDedicated is your friend

 

https://community.bistudio.com/wiki/isDedicated

Share this post


Link to post
Share on other sites

hmm must be me but still does not work on Dedi ?

 

initplayerlocal.sqf

#include "\a3\ui_f\hpp\definedikcodes.inc"

_adminIDs = [ "76561198027698xxxxxx", "76561198027698xxxxxx" ];

if (
	hasInterface &&		//Client machine
	{
		isDedicated  ||	//Dedi
		{ getPlayerUID player in _adminIDs } ||		//Predefined admin
		{ serverCommandAvailable "#exportjipqueue" } ||		//Logged in admin
		{ !isNil { missionNamespace getVariable "BIS_fnc_admin" } && { call BIS_fnc_admin isEqualTo 2 } }	//Logged in admin, A3 version 1.70 maybe?
	}
) then {
	waitUntil { !isNull ( findDisplay 46 ) };
	( findDisplay 46 ) displayAddEventHandler [ "KeyDown", {
		params[ "_display", "_keyCode", "_shft", "_ctr", "_alt" ];
		
		if ( _keyCode isEqualTo DIK_F10 ) then {
			//open display here
		};
	} ];
};

 

Share this post


Link to post
Share on other sites
8 hours ago, 1para{god-father} said:

To make this work on dedi would i just need to change as below ?

There should be no need to change anything. Although there maybe a timing issue with player, that could possibly be null right at the beginning.

 

There are other problems I see with using it from the intPlayerLocal.sqf the way you have, that the checks for logged in admin are only ever going to work if the client is logged in as admin before the initPlayerLocal runs.

Try changing it around a bit and do the admin check on the key press instead, then if someone logs in as admin during the game it will also work for them...

//initPlayerLocal.sqf
#include "\a3\ui_f\hpp\definedikcodes.inc"

if ( hasInterface ) then { //NOT a headless client
	
	//wait for main interface in a scheduler thread
	//so this does not stop anything else in the initPlayerLocal from initialising
	_h = [] spawn {
		
		//Wait for main display
		waitUntil { !isNull ( findDisplay 46 ) };
		
		//Add Key event
		( findDisplay 46 ) displayAddEventHandler [ "KeyDown", {
			params[ "_display", "_keyCode", "_shft", "_ctr", "_alt" ];
			
			_adminIDs = [ "76561198027698xxxxxx", "76561198027698xxxxxx" ];
			
			if (
				_keyCode isEqualTo DIK_F10 && //F10 pressed
				{
					!isMultiplayer ||	//SP
					{ getPlayerUID player in _adminIDs } || //Predefined admin
					{ serverCommandAvailable "#exportjipqueue" } || //Logged in admin
					{ ( !isNil { missionNamespace getVariable "BIS_fnc_admin" } && { call BIS_fnc_admin isEqualTo 2 } ) } //Logged in admin, A3 version 1.70 maybe?
				}			
			) then {
				//open display here
			};
		} ];
	};
};

 

8 hours ago, M1ke_SK said:

isDedicated is your friend

This is not needed as explained above it is a client side dialog. god-fathers wording was misleading as this does not need to run on a dedicated BUT needs to work for a client on a dedicated.

 

2 hours ago, M1ke_SK said:

BIS_fnc_admin is not yet in stable branch

That is why the condition first checks if the function is defined before trying to use it.

  • Like 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

×