Jump to content
Nutzgo

3rd person limit script on a server?

Recommended Posts

Is there a way to globally execute a script on a server without adding it to the mission init? Could I use the debug console as server admin? 

 

Let me clarify with an example. 

In my missions I use HallyGs 3rd person limit script, that force players into 1st person mode if they are on foot, and allows it when they're in a vehicle. 

 

Quote

/* Function: HALs_fnc_limitThirdPerson Author: HallyG Limits third person use to vehicles only. Arguments(s): None Return Value: None Example: // initPlayerLocal.sqf call HALs_fnc_limitThirdPerson; __________________________________________________________________*/ if (!hasInterface) exitWith {}; if (!isNil "HALs_tp_cameraView") exitWith {}; HALs_tp_cameraView = cameraView; HALs_tp_oldVehicle = vehicle player; addMissionEventHandler ["EachFrame", { if (inputAction "PersonView" > 0 || !(cameraView isEqualTo HALs_tp_cameraView) || !(vehicle player isEqualTo HALs_tp_oldVehicle)) then { if (cameraOn isEqualTo vehicle player) then { if (isNull objectParent player) then { if (cameraView isEqualTo "EXTERNAL") then { player switchCamera "INTERNAL"; }; }; }; }; HALs_tp_cameraView = cameraView; HALs_tp_oldVehicle = vehicle player; }];

 

But, if I start a vanilla mission, e.g. "Escape Altis" or "Warlords" - how do I execute this script in these missions, without digging for the .pbo file and adding it manually? 

Share this post


Link to post
Share on other sites

You can global execute it from the console. You could also put it in an add-on and have it execute postinit

Share this post


Link to post
Share on other sites
15 hours ago, Mr H. said:

You can global execute it from the console. You could also put it in an add-on and have it execute postinit


For some reason, the Debug Console wont show up when I'm logged in as admin on the server. Any idea how I can fix it?

Share this post


Link to post
Share on other sites

And how do I put it in an add-on?
I'm new to server management and I have never created an addon. 

I want the script to run server side, all the time on all of my missions, including official ones. 
For now, I've included it in "InitPlayerLocal.sqf" in the mission folder, but I cannot do that for the offical missions (Warlords, Escape and so on). I can't open the debug console on these official missions either, and I cannot seem to find out how I can fix that. 

Share this post


Link to post
Share on other sites

It's doable and very simple to do, however it's a bit long to explain. I'm on my phone right now but when I have access to my computer I will put together a simple tutorial.

  • Thanks 1

Share this post


Link to post
Share on other sites
7 hours ago, nutzgo said:


For some reason, the Debug Console wont show up when I'm logged in as admin on the server. Any idea how I can fix it?

 

Did you enable it in mission config?

Share this post


Link to post
Share on other sites
Just now, killzone_kid said:

 

Did you enable it in mission config?

In my self made missions, yes. In the official missions from BIH, the escape missions, Warlords, End Game and so on, it seems to be disabled. I can't seen to find all the official pbos. Awaiting Mr Hs guide so I always could have it enabled. 

Share this post


Link to post
Share on other sites

ok so quick guide it is:
We will create an addon. So you need Arma 3 tools (available on steam) to pack it as a pbo
For the following assume that every time you see myAddon in script and /or explanations you will replace it by your chosen addon name (including in paths and config reference)

and when you see MyMod replace it by your mod name (it can be different)

step 1) create a folder named myAddon (hope you've read above ;-)
step 2) in this folder create a text file that you will rename config.cpp where .cpp is the file extension.
open it with a text editor and copypaste the following code:

class CfgPatches {
	class myAddon{
		units[] = {}; //
		weapons[] = {}; //
		requiredVersion = 0.1; //
		requiredAddons[] = {}; //
	};
};



class cfgFunctions
{
	class HALs
	{
		
			class HALsCategory
		{
		tag = "HALs";
		file = "\myAddon";
			class limitThirdPerson
			{
				postInit =1;
			};
			
		};
		
	};
};

hope you've been paying attention to our renaming rule
step 3)

in the same folder create a second textfile and rename it to;
fn_limitThirdPerson.sqf
it has to be EXACTLY that name.

step 4) in this file place the following code:
 

if !(isServer) exitWith {};

// we are assuming that you want this to be a server only mod
[[],
	{
		//copypaste your function here
	}
] remoteExec ["Call",[0,-2] select isDedicated,true];

and copy your function where I commented to paste it. At this point it's worth mentioning that you should ask the author's permission to use it in your addon (MUST if you intend to distribute it.

step 5) Open arma 3 tools and launch addon builder, select the folder we have created and pack the addon to a pbo.

step 6) somewhere else create a folder named

@MyMod

the @ is mandatory unless you intend to upload it to steam workshop, which is not necessary since your addon is server only compatible.

step 7) in this folder

create a mod.cpp
and fill it with this template code that you can edit:
 

name = "TestMod";
picture = "";
actionName = "TestMod";
action = "";
logo = "";
logoOver = "";
tooltip = "TestMod";
tooltipOwned = "TestMod Owned";
overview = "";
author = "";
overviewPicture = "";
overviewText = "";
overviewFootnote = "";

step 8)

create a meta.cpp (not absolutely sure that one is necessary but let's play it safe)
with this code inside
 

protocol = 1;

name = "myMod";

step 9) in your mod folder create two new subfolders named exactly:
Addons
Keys
(not sure the keys folder is mandatory either, it will remain empty unless you decide to sign your addon)

step 10)
move your myAddon.pbo to the addons folder.

step 11) congrats you're done! Use it as a server only addon!:f:

Edited by Mr H.
forgotten to change addonname to myaddon
  • Like 1
  • Thanks 2

Share this post


Link to post
Share on other sites

Thank you very much! :) That was really helpful, and it works!!
First I tried to only load it under "serverMod" command line, didn't work.
Loaded it under "mod", and it works.

Thank you so much for your time!

Share this post


Link to post
Share on other sites

Maybe you should add something to wait until the player initializes to the function to have it work as a server mod 

Share this post


Link to post
Share on other sites
On 1/20/2019 at 9:55 AM, Mr H. said:

ok so quick guide it is:
We will create an addon. So you need Arma 3 tools (available on steam) to pack it as a pbo
For the following assume that every time you see myAddon in script and /or explanations you will replace it by your chosen addon name (including in paths and config reference)

and when you see MyMod replace it by your mod name (it can be different)

step 1) create a folder named myAddon (hope you've read above ;-)
step 2) in this folder create a text file that you will rename config.cpp where .cpp is the file extension.
open it with a text editor and copypaste the following code:


class CfgPatches {
	class myAddon{
		units[] = {}; //
		weapons[] = {}; //
		requiredVersion = 0.1; //
		requiredAddons[] = {}; //
	};
};



class cfgFunctions
{
	class HALs
	{
		
			class HALsCategory
		{
		tag = "HALs";
		file = "\myAddon";
			class limitThirdPerson
			{
				postInit =1;
			};
			
		};
		
	};
};

hope you've been paying attention to our renaming rule
step 3)

in the same folder create a second textfile and rename it to;
fn_limitThirdPerson.sqf
it has to be EXACTLY that name.

step 4) in this file place the following code:
 


if !(isServer) exitWith {};

// we are assuming that you want this to be a server only mod
[[],
	{
		//copypaste your function here
	}
] remoteExec ["Call",[0,-2] select isDedicated,true];

and copy your function where I commented to paste it. At this point it's worth mentioning that you should ask the author's permission to use it in your addon (MUST if you intend to distribute it.

step 5) Open arma 3 tools and launch addon builder, select the folder we have created and pack the addon to a pbo.

step 6) somewhere else create a folder named

@MyMod

the @ is mandatory unless you intend to upload it to steam workshop, which is not necessary since your addon is server only compatible.

step 7) in this folder

create a mod.cpp
and fill it with this template code that you can edit:
 


name = "TestMod";
picture = "";
actionName = "TestMod";
action = "";
logo = "";
logoOver = "";
tooltip = "TestMod";
tooltipOwned = "TestMod Owned";
overview = "";
author = "";
overviewPicture = "";
overviewText = "";
overviewFootnote = "";

step 8)

create a meta.cpp (not absolutely sure that one is necessary but let's play it safe)
with this code inside
 


protocol = 1;

name = "myMod";

step 9) in your mod folder create two new subfolders named exactly:
Addons
Keys
(not sure the keys folder is mandatory either, it will remain empty unless you decide to sign your addon)

step 10)
move your myAddon.pbo to the addons folder.

step 11) congrats you're done! Use it as a server only addon!:f:

Hi, I did it by myself according to your tutorial, but it doesn't work in the game, I don't understand the foot aspect of the game at all, sorry .

Share this post


Link to post
Share on other sites

What did you do exactly what's not working?

Share this post


Link to post
Share on other sites
8 hours ago, Mr H. said:

What did you do exactly what's not working?

I according to your tutorial will pack it into PBO file, and put it in my ARMA3 "addons" folder in the directory, when I choose a task after entering the game, the PBO won't limit me in the third person, it doesn't work, I will my PBO file upload, hope you can help me to see if there are key steps I did wrong.😢

 

My pbo files:

https://drive.google.com/file/d/1mtgoF4RV3YwoyHb7PM14UDWiD0WEYuDH/view?usp=drivesdk

 

 

Share this post


Link to post
Share on other sites
3 hours ago, Nana1999 said:

put it in my ARMA3 "addons" folder in the directory,

not in ARMA's addons folder! (that's an absolute don't!). Also did you include the function that @Nutzgo posted at the top of this post?

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

×