Jump to content
McIntire

Shooting Range Scripts work in editor but not on Server

Recommended Posts

I'm making a post after looking through a few topics and consulting with one of my contacts.  We have tried a number of fixes, but none have solved the problem.

 

Scenario:

  • There is a rifle qualification range and a pistol qualification range on the same mission.  Controls are linked to scripts via addAction to either raise targets at 1 of 3 set distances at the rifle range or to raise the pistol targets in sequence.
  • The rifle targets need to reset after being hit, while the pistol targets need to stay down after being hit.

 

Problem:

  • Through various scripts, I was able to get the ranges to work properly when loaded in the editor.
  • However, on the server, the combinations will either make all the targets pop up or stay down despite trying a number of combinations.

 

Attempts:

  • Since one of the topics I found mentioned locality, I tried implementing if (isServer) line in pistol range scripts - Scripts would not work at all on server.
  • Also tried moving nopop = true/false; into target objects' init lines - Does not work.
  • Moving nopop = false; line to rifle range scripts - Targets initially in up position, stay down when hit.  Upon executing scripts, will reset as intended in editor, but not in server.
  • Moved lines from init.sqf into range.sqf file executed from init.sqf - Organizes it better but does not address issue.

 

Scripts:

 

There is a execVM "range.sqf"; line in the init.sqf file which calls the range.sqf script:

Quote

nopop = false;

ptgt_1_1 animate["terc", 1];
ptgt_1_2 animate["terc", 1];
ptgt_1_3 animate["terc", 1];
ptgt_1_4 animate["terc", 1];
ptgt_1_5 animate["terc", 1];
ptgt_2_1 animate["terc", 1];
ptgt_2_2 animate["terc", 1];
ptgt_2_3 animate["terc", 1];
ptgt_2_4 animate["terc", 1];
ptgt_2_5 animate["terc", 1];
ptgt_3_1 animate["terc", 1];
ptgt_3_2 animate["terc", 1];
ptgt_3_3 animate["terc", 1];
ptgt_3_4 animate["terc", 1];
ptgt_3_5 animate["terc", 1];
ptgt_4_1 animate["terc", 1];
ptgt_4_2 animate["terc", 1];
ptgt_4_3 animate["terc", 1];
ptgt_4_4 animate["terc", 1];
ptgt_4_5 animate["terc", 1];
ptgt_5_1 animate["terc", 1];
ptgt_5_2 animate["terc", 1];
ptgt_5_3 animate["terc", 1];
ptgt_5_4 animate["terc", 1];
ptgt_5_5 animate["terc", 1];
ptgt_6_1 animate["terc", 1];
ptgt_6_2 animate["terc", 1];
ptgt_6_3 animate["terc", 1];
ptgt_6_4 animate["terc", 1];
ptgt_6_5 animate["terc", 1];
ptgt_7_1 animate["terc", 1];
ptgt_7_2 animate["terc", 1];
ptgt_7_3 animate["terc", 1];
ptgt_7_4 animate["terc", 1];
ptgt_7_5 animate["terc", 1];
ptgt_8_1 animate["terc", 1];
ptgt_8_2 animate["terc", 1];
ptgt_8_3 animate["terc", 1];
ptgt_8_4 animate["terc", 1];
ptgt_8_5 animate["terc", 1];
ptgt_9_1 animate["terc", 1];
ptgt_9_2 animate["terc", 1];
ptgt_9_3 animate["terc", 1];
ptgt_9_4 animate["terc", 1];
ptgt_9_5 animate["terc", 1];
ptgt_10_1 animate["terc", 1];
ptgt_10_2 animate["terc", 1];
ptgt_10_3 animate["terc", 1];
ptgt_10_4 animate["terc", 1];
ptgt_10_5 animate["terc", 1];
ptgt_11_1 animate["terc", 1];
ptgt_11_2 animate["terc", 1];
ptgt_11_3 animate["terc", 1];
ptgt_11_4 animate["terc", 1];
ptgt_11_5 animate["terc", 1];
ptgt_12_1 animate["terc", 1];
ptgt_12_2 animate["terc", 1];
ptgt_12_3 animate["terc", 1];
ptgt_12_4 animate["terc", 1];
ptgt_12_5 animate["terc", 1];
ptgt_13_1 animate["terc", 1];
ptgt_13_2 animate["terc", 1];
ptgt_13_3 animate["terc", 1];
ptgt_13_4 animate["terc", 1];
ptgt_13_5 animate["terc", 1];
ptgt_14_1 animate["terc", 1];
ptgt_14_2 animate["terc", 1];
ptgt_14_3 animate["terc", 1];
ptgt_14_4 animate["terc", 1];
ptgt_14_5 animate["terc", 1];
ptgt_15_1 animate["terc", 1];
ptgt_15_2 animate["terc", 1];
ptgt_15_3 animate["terc", 1];
ptgt_15_4 animate["terc", 1];
ptgt_15_5 animate["terc", 1];

 

One of the rifle range scripts:

Quote

//200m Target Script
nopop = false;

// popup target manually (0 - up, 1 - down)

//200m targets up
tgt200_1 animate["terc", 0];
tgt200_2 animate["terc", 0];
tgt200_3 animate["terc", 0];
tgt200_4 animate["terc", 0];
tgt200_5 animate["terc", 0];
tgt200_6 animate["terc", 0];
tgt200_7 animate["terc", 0];
tgt200_8 animate["terc", 0];
tgt200_9 animate["terc", 0];
tgt200_10 animate["terc", 0];
tgt200_11 animate["terc", 0];
tgt200_12 animate["terc", 0];
hint "Targets set to 200m";

//300m targets down
tgt300_1 animate["terc", 1];
tgt300_2 animate["terc", 1];
tgt300_3 animate["terc", 1];
tgt300_4 animate["terc", 1];
tgt300_5 animate["terc", 1];
tgt300_6 animate["terc", 1];
tgt300_7 animate["terc", 1];
tgt300_8 animate["terc", 1];
tgt300_9 animate["terc", 1];
tgt300_10 animate["terc", 1];
tgt300_11 animate["terc", 1];
tgt300_12 animate["terc", 1];

//500m targets down
tgt500_1 animate["terc", 1];
tgt500_2 animate["terc", 1];
tgt500_3 animate["terc", 1];
tgt500_4 animate["terc", 1];
tgt500_5 animate["terc", 1];
tgt500_6 animate["terc", 1];
tgt500_7 animate["terc", 1];
tgt500_8 animate["terc", 1];
tgt500_9 animate["terc", 1];
tgt500_10 animate["terc", 1];
tgt500_11 animate["terc", 1];
tgt500_12 animate["terc", 1];
 

 

Pistol Range Script:

Quote

//Pistol Qualification Script
nopop = true;

//popup target manually (0 - up, 1 - down)

hint "Pistol Qualification Start";

//Target 1
sleep 4;
ptgt_1_1 animate["terc", 0];
ptgt_1_2 animate["terc", 0];
ptgt_1_3 animate["terc", 0];
ptgt_1_4 animate["terc", 0];
ptgt_1_5 animate["terc", 0];

//Target 2
sleep 4;
ptgt_2_1 animate["terc", 0];
ptgt_2_2 animate["terc", 0];
ptgt_2_3 animate["terc", 0];
ptgt_2_4 animate["terc", 0];
ptgt_2_5 animate["terc", 0];

//Target 3
sleep 2;
ptgt_3_1 animate["terc", 0];
ptgt_3_2 animate["terc", 0];
ptgt_3_3 animate["terc", 0];
ptgt_3_4 animate["terc", 0];
ptgt_3_5 animate["terc", 0];

//Target 4
sleep 2;
ptgt_4_1 animate["terc", 0];
ptgt_4_2 animate["terc", 0];
ptgt_4_3 animate["terc", 0];
ptgt_4_4 animate["terc", 0];
ptgt_4_5 animate["terc", 0];

//Target 5
ptgt_5_1 animate["terc", 0];
ptgt_5_2 animate["terc", 0];
ptgt_5_3 animate["terc", 0];
ptgt_5_4 animate["terc", 0];
ptgt_5_5 animate["terc", 0];

//Target 6
sleep 4;
ptgt_6_1 animate["terc", 0];
ptgt_6_2 animate["terc", 0];
ptgt_6_3 animate["terc", 0];
ptgt_6_4 animate["terc", 0];
ptgt_6_5 animate["terc", 0];

//Target 7
sleep 2;
ptgt_7_1 animate["terc", 0];
ptgt_7_2 animate["terc", 0];
ptgt_7_3 animate["terc", 0];
ptgt_7_4 animate["terc", 0];
ptgt_7_5 animate["terc", 0];

//Target 8
ptgt_8_1 animate["terc", 0];
ptgt_8_2 animate["terc", 0];
ptgt_8_3 animate["terc", 0];
ptgt_8_4 animate["terc", 0];
ptgt_8_5 animate["terc", 0];

//Target 9
sleep 8;
ptgt_9_1 animate["terc", 0];
ptgt_9_2 animate["terc", 0];
ptgt_9_3 animate["terc", 0];
ptgt_9_4 animate["terc", 0];
ptgt_9_5 animate["terc", 0];

//Target 10
sleep 2;
ptgt_10_1 animate["terc", 0];
ptgt_10_2 animate["terc", 0];
ptgt_10_3 animate["terc", 0];
ptgt_10_4 animate["terc", 0];
ptgt_10_5 animate["terc", 0];

//Target 11
sleep 4;
ptgt_11_1 animate["terc", 0];
ptgt_11_2 animate["terc", 0];
ptgt_11_3 animate["terc", 0];
ptgt_11_4 animate["terc", 0];
ptgt_11_5 animate["terc", 0];

//Target 12
sleep 2;
ptgt_12_1 animate["terc", 0];
ptgt_12_2 animate["terc", 0];
ptgt_12_3 animate["terc", 0];
ptgt_12_4 animate["terc", 0];
ptgt_12_5 animate["terc", 0];

//Target 13
ptgt_13_1 animate["terc", 0];
ptgt_13_2 animate["terc", 0];
ptgt_13_3 animate["terc", 0];
ptgt_13_4 animate["terc", 0];
ptgt_13_5 animate["terc", 0];

//Target 14
sleep 2;
ptgt_14_1 animate["terc", 0];
ptgt_14_2 animate["terc", 0];
ptgt_14_3 animate["terc", 0];
ptgt_14_4 animate["terc", 0];
ptgt_14_5 animate["terc", 0];

//Target 15
ptgt_15_1 animate["terc", 0];
ptgt_15_2 animate["terc", 0];
ptgt_15_3 animate["terc", 0];
ptgt_15_4 animate["terc", 0];
ptgt_15_5 animate["terc", 0];

//End Qualification
sleep 3;
playMusic "ceasefire";
hint "CEASEFIRE ON PISTOL RANGE!";

 

There are also scripts to reset the ranges after use, but those are working as intended so I don't think I need to post them.

Share this post


Link to post
Share on other sites

If you want to create MP script then I have to be aware of the locality. You have to ensure that it commands have a global or a local effect. Your hints for example have only a local effect on the machine where the hints are executed and therefore u have to execute it remotely.
Look in the wiki on the top left. There is the information about where the command takes effect. In case of hint it takes only a local effect. You can use remoteExec or remoteExecCall to execute commands or functions remotely.

sent from mobile using Tapatalk

Share this post


Link to post
Share on other sites
On 6/28/2017 at 0:46 AM, sarogahtyp said:

If you want to create MP script then I have to be aware of the locality. You have to ensure that it commands have a global or a local effect. Your hints for example have only a local effect on the machine where the hints are executed and therefore u have to execute it remotely.
Look in the wiki on the top left. There is the information about where the command takes effect. In case of hint it takes only a local effect. You can use remoteExec or remoteExecCall to execute commands or functions remotely.

sent from mobile using Tapatalk
 

 

Thanks for the response, finally got to take a look at this issue again and somewhat comprehend it.

 

So from my understanding, I should be using remoteExecCall?

And should this go next to the addAction of the controller that calls the scripts or the scripts themselves?

 

Another method I tried was:

 

this addEventHandler ["Hit", {this animate["terc", 1];}]

 

That is not working either unfortunately.

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

×