Jump to content

Recommended Posts

Here is my issue. Players that JIP (join in progress) can mess up the mission because they spawn with access to an addAction that was removed for players that were in the server since the start of the mission.
 

The following code works perfect and does what I need it to. It even works when JIP players execute it. I just don't want them to have access to the addAction because they can disrupt the flow of the mission with it.

 

With the help of some people on discord and here, I have written an addAction that executes a .sqf that changes weather, time of day, and a few other things. Here is the addAction:
 

MPScriptGlobal = player addAction ["MP Script Global", {["MPglobal.sqf"] remoteExec ["execVM", 0];}, [], 8, false, true];

The above addAction executes this .sqf:

 

player removeAction MPScriptGlobal; //removes the addAction for players

call{playsound "wait1"}; //plays radio message below
player sideChat "Razorback, HQ. We're in position and waiting for the patrol. Over."; //subtitles for radio message
sleep 7;
call{playsound "wait2"};
sleep 1;
HQRadio sideChat "HQ, Razorback. Good copy. Don't let the bugs get you. Over and out.";
sleep 6;

titleText ["", "BLACK OUT", 3]; //fades screen to black
3 fadesound 0; //fades audio to mute
sleep 5;

NavalPatrolvariableActivated = true; //activates trigger to unhide patrol

skipTime -24; //rewinds time to addjust overcast
86400 setOvercast .5; //sets the overcast
skipTime 24; //advances time to allow engine to create overcast
0 setRain .40; //sets rain
0 setFog [1, .20, 5]; //sets fog
setDate [1967, 3, 31, 5, 57]; //sets time of day

3 fadesound 1;
sleep 2;

titleText ["", "BLACK IN", 3];
sleep 3;
[] Spawn {
[ 
 [ 
  ["Recon Position", "<t align = 'center' shadow = '1' size = '1.5' font='tt2020style_e_vn_bold'>%1</t><br/>"],  
  ["0557h", "<t align = 'center' shadow = '1' size = '1.0'>%1</t><br/>"]
 ] 
] spawn vn_ms_fnc_sfx_typeText;}; //type text appears on screen

600 setOvercast .25; //sets overcast to be completed after 5 minutes

I have received some advice on discord that "It would be way easier if you would just use a global variable for a action condition and publicvariable it to disable the action." But I don't know exactly how to implement this. Another person was saying to create a initServer file and put some variable in there. Problem is I'm so new I really need this spelled out for me. I've messed around for hours trying different stuff but I think I'm just digging myself a hole. But I'm not giving up!

  • Like 1

Share this post


Link to post
Share on other sites

"It would be way easier if you would just use a global variable for a action condition and publicvariable it to disable the action."  seems to be the most simple way of doing it.

 

Try using this as the addaction, it has the condition parameter set as a mission namespace variable "showGlobalAction" which if defined will not allow the addaction to be seen / used.

MPScriptGlobal = player addAction [
	"MP Script Global",	// title
	{
		["MPglobal.sqf"] remoteExec ["execVM", 0];
	},
	nil,		// arguments
	8,		// priority
	false,		// showWindow
	true,		// hideOnUse
	"",			// shortcut
	"isNil 'showGlobalAction'"		// condition
];

Then put the following in the beginning of your MPglobal.sqf script. This is a global variable which gets broadcasted to all clients and is also JIP compatible. This will prevent the addAction from appearing.

showGlobalAction = false;
publicVariable "showGlobalAction";
  • Like 2

Share this post


Link to post
Share on other sites

Just tested this on the dedicated server and it works perfectly! Thank you for this! This is literally 17 hours of me stumbling in the dark trying a million different things. And now I can move on to the next thing that will take twice as long and is twice as easy for experience scripters haha. A couple questions to help my understanding.

First, do I really need "MPScriptGlobal =" anymore? Seems like the heavy lifting is being done by "publicVariable "showGlobalAction";".

Second, do I really need to "remoteExec" this since "publicVariable" is global? Shouldn't that sync all the computers up?

Haha, this dude comes out of nowhere, makes his third post ever and solves my problem like it was nothing. What an absolute legend! Thanks again!

Share this post


Link to post
Share on other sites

No problem! 🙂

 

1. Correct, you don't need the MpScriptGlobal
2. Correct, It would actually be better to just place it in the addaction as it only gets executed once

player addAction [
	"MP Script Global",	// title
	{
		showGlobalAction = false;
        	publicVariable "showGlobalAction";
		["MPglobal.sqf"] remoteExec ["execVM", 0];
	},
	nil,		// arguments
	8,		// priority
	false,		// showWindow
	true,		// hideOnUse
	"",			// shortcut
	"isNil 'showGlobalAction'"		// condition
];

 

  • Like 1

Share this post


Link to post
Share on other sites

I just tested out this new one and it works great for JIP players I couldn't get it to break. This is one slight problem though. I have a trigger area that is supposed to remove the addAction. It works to remove it for all players when they enter the area except for someone who JIP. They have access to even after the trigger was fired. Right now the trigger activates like this:

ShowGlobalAction = false;

I'm confused as to why JIP players can still see this addAction after the trigger has fired for everyone else. My understanding is since this is a global variable it should be broadcast to all clients. So JIP players should see the addAction but they do.

So to be clear I'm trying to remove this addAction for all players including JIP, without using the addAction itself to do so. Basically I give the players this addAction as an option at the beginning of the mission then use a trigger to take that option away if they advance far enough in the mission.

Share this post


Link to post
Share on other sites

I haven't really dealt with triggers before but i believe that they are local. Therefore you'd have to use publicVariable "ShowGlobalAction" once more. Each time you make a change to that global variable you'd have to publicVariable it again if you want the new version of it to be broadcasted.

Share this post


Link to post
Share on other sites

So I just tried this in the trigger field:
 

publicVariable "ShowGlobalAction";
ShowGlobalAction = false;

It was interesting because the action went away but 1 second later it returned. Almost like it was being overidden by the "isNil 'showGlobalAction".

I'm going back through lots of threads but no luck yet. I'm surprised that removing an addAction is so hard for JIP players. I can't count the times that someone had to leave the mission to answer the door, timed out, computer crashed, etc which turned them into a JIP player. I definitely want to take advantage of JIP functionality because of this.

Share this post


Link to post
Share on other sites
12 hours ago, FoxClubNiner said:

So I just tried this in the trigger field:
 


publicVariable "ShowGlobalAction";
ShowGlobalAction = false;

It was interesting because the action went away but 1 second later it returned. Almost like it was being overidden by the "isNil 'showGlobalAction".

I'm going back through lots of threads but no luck yet. I'm surprised that removing an addAction is so hard for JIP players. I can't count the times that someone had to leave the mission to answer the door, timed out, computer crashed, etc which turned them into a JIP player. I definitely want to take advantage of JIP functionality because of this.

 

All publicVariable does is broadcast the current value of the provided variable. 

 

So what's currently happening is:

1. ShowGlobalAction starts as undefined (nil)

2. publicVariable sends the nil value to/from the server.

3. Line 2 assigns ShowGlobalAction to false which hides the action

4. The network update to/from the server arrives and overrides ShowGlobalAction to nil again, revealing the action once more.

 

So reverse the order and call publicVariable after the assignment is done.

 

Edit: To be more efficient the trigger should be set to server only.

  • Like 1

Share this post


Link to post
Share on other sites
5 hours ago, mrcurry said:

 

All publicVariable does is broadcast the current value of the provided variable. 

 

So what's currently happening is:

1. ShowGlobalAction starts as undefined (nil)

2. publicVariable sends the nil value to/from the server.

3. Line 2 assigns ShowGlobalAction to false which hides the action

4. The network update to/from the server arrives and overrides ShowGlobalAction to nil again, revealing the action once more.

 

So reverse the order and call publicVariable after the assignment is done.

 

Edit: To be more efficient the trigger should be set to server only.

 

Even with my limited knowledge, what you said in step 1-4 makes sense to me.

 

However, I don't quite understand what you mean "reverse the order and call publicVariable after the assignment is done". Do you mean that I just have to swap the order of the lines in the trigger field to look like this?

ShowGlobalAction = false;
publicVariable "ShowGlobalAction";

 

Share this post


Link to post
Share on other sites
12 hours ago, FoxClubNiner said:

However, I don't quite understand what you mean "reverse the order and call publicVariable after the assignment is done". Do you mean that I just have to swap the order of the lines in the trigger field to look like this?

Correct

  • Like 1

Share this post


Link to post
Share on other sites
11 hours ago, mrcurry said:

Correct

Bang on man. Works perfect now. Thank you for the help! Do you know how to mark the thread as SOLVED?

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

×