OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting Multiplayer => Topic started by: Case on 04 Sep 2007, 05:05:15

Title: Script Issue on Dedicated Server
Post by: Case on 04 Sep 2007, 05:05:15
I finished a mission and had been testing it all along using the 'interactive' server (non-dedicated).  It works fine on that.  I now try to run the mission on a dedicated server and am having problems. 

It is at the very start of the mission, you start at an airbase and need to board two MH-6's.  Once aboard, I have two radio commands 'Insert Alpha', and 'Insert Bravo'.  Each of these radio triggers call a script.  Here is the content of the 'Alpha' script:

Code: [Select]
hint ""
hint "INSIDE alpha"
? (!isServer): exit

setfire=true
onMapSingleClick "AlphaTarget setpos _pos; setfire=false"

@!setfire
"AlphaInsertion" setmarkerpos getpos AlphaTarget
; onMapSingleClick ""

#Start
_markerobj = createMarker["Alpha", getpos AlphaTarget]
_markerobj setMarkerShape "ICON"
"Alpha" setMarkerType "DOT"
"Alpha" setMarkerText "Alpha Insertion"

driver MH6_1 flyinheight 50
driver MH6_1 domove getpos AlphaTarget
driver MH6_1 setspeedMode "Full"

#Insert
~1
? (MH6_1 distance AlphaTarget) < 500 : goto "Approach"
hint format ["%1",MH6_1 distance AlphaTarget]
goto "Insert"

#Approach
MH6_1 SetSpeedMode "Limited"
MH6_1 sidechat "Alpha team! Get ready boys, approaching insertion point"

#loop
~1
? not (unitready driver MH6_1):goto "loop"
MH6_1 sidechat "Alpha team! Get ready for quick deployment"
~3
MH6_1 land "GET OUT"


#loop3
_numcrew = count crew MH6_1
? _numcrew > 1: goto "loop3"
~1
[driver _MH6] join grpNull
MH6_1 domove getpos rtb_Alpha
MH6_1 SetSpeedMode "Normal"
MH6_1 flyinheight 50
#RTB
~1
? (MH6_1 distance rtb_Alpha) < 400 : goto "RTB_Approach"
goto "RTB"

#RTB_Approach
MH6_1 SetSpeedMode "Limited"

#RTB_loop
~1
? not (unitready driver MH6_1):goto "RTB_loop"
~3
MH6_1 land "LAND"
deleteMarker Alpha
~40
MH6_1 setFuel 0

#End
#Exit


I know it enters the script, because I get the hint 'inside' that I added for debugging.  When you click on the map, an icon should appear and the heli takes off.  This doesn't happen.

Does anyone have any ideas?

If you want to take a closer at the mission and scripts, I have the entire mission zipped up here:   http://www.rowlinson.ca/arma/c9_preemptive_action.zip

Cheers!!

Title: Re: Script Issue on Dedicated Server
Post by: Nixer6 on 04 Sep 2007, 09:16:41
Not much help here but............have you tried just executing the script on the server?

Code: [Select]
? (!isServer): exit
Just a thought as I am having LOTS of problems with MP scripting myself.
Title: Re: Script Issue on Dedicated Server
Post by: Mandoble on 04 Sep 2007, 11:31:03
Code: [Select]
_numcrew = count crew _MH6 ->
Code: [Select]
_numcrew = count crew MH6_1
Code: [Select]
? not (unitready _MH6):goto "loop" ->
Code: [Select]
? not (unitready driver MH6_1):goto "loop"
You may find another problem, ArmA stalls trying to solve long range paths for vehicles, so you may click a point on the other side of the island and the chopper will refuse to move.

Probably you should add more checks for damage level of the chopper as well as checking that the driver is inside the chopper (he might eject, so he will be ready, the chopper will be ready, but the destination has not been reached).
Title: Re: Script Issue on Dedicated Server
Post by: Case on 04 Sep 2007, 16:50:19
Nixer, thanks I will try that and report back.

Mandoble, I am actually just recently aware of the pathing issue.  During playtesting of this mission though, I have never had a problem with this, the places where you would want to insert your teams seem to work just fine for pathing.  Last night I even tested this trying to click on the map only about 700m away, and still no luck.  Also, your suggestions about the other checks are good, thanks for that.

Cheers!

EDIT:  I just finished testing using the 'run only on server' fix from Nixer.  Still the same problem.   Mandoble, I cleaned up those coding errors.  During troubleshooting of this problem, I had separated out my 'insertion' script from getting passed the heli, to having a hard-coded alpha and bravo script.  Just FYI.

Anyway, I am still stuck here, so let me know if anyone has any other suggestions.  Thanks!
Title: Re: Script Issue on Dedicated Server
Post by: Mandoble on 04 Sep 2007, 20:13:12
May you update first post with the resulting code after your last modifications?
Title: Re: Script Issue on Dedicated Server
Post by: Case on 04 Sep 2007, 21:13:53
Updated script in this post.  I also updated the zip file of the mission available to download in the first post's link.

Title: Re: Script Issue on Dedicated Server
Post by: Mandoble on 04 Sep 2007, 22:25:03
_markerobj = createMarker["Alpha", AlphaTarget]

AlphaTarget is a position or an object? If an object, you are missing getPos there.

MH6_1 domove getpos AlphaTarget
MH6_1 flyinheight 50
MH6_1 setspeedMode "Full"

->
MH6_1 flyinheight 50
driver MH6_1 domove getpos AlphaTarget
driver MH6_1 setspeedMode "Full"

or ->
MH6_1 flyinheight 50
driver MH6_1 domove getpos AlphaTarget
group driver MH6_1 setspeedMode "Full"

Title: Re: Script Issue on Dedicated Server
Post by: Case on 04 Sep 2007, 22:38:18
To be honest, I am not totally sure.  The original first mention of 'alphatarget' is in the onmapsingle click call which I plagiarized from someone's else script.

I will update the script with your changes though, and try again under dedicated server, this is all working fine using 'regular' server.

Thanks again.

EDIT:  Same problem.  Clicking on the map doesn't place a marker, and the heli's never leave.  I am updating the script to reflect the latest version.
Title: Re: Script Issue on Dedicated Server
Post by: Mandoble on 04 Sep 2007, 23:04:30
Does AlphaTarget exist? it seems to be an object already placed on the map, more than problably a gamelogic named that way.
Title: Re: Script Issue on Dedicated Server
Post by: Case on 04 Sep 2007, 23:07:11
Ooops,

Yes, it does.  Sorry about that, been so long since I first created it.

It exists as one of the Invisible 'H' heli pads.
Title: Re: Script Issue on Dedicated Server
Post by: Mandoble on 04 Sep 2007, 23:11:18
Add a hint format ["%1", getpos AlphaTarget] just after @!setfire and check that you get the hint and coordinates inside the map.

Title: Re: Script Issue on Dedicated Server
Post by: Case on 04 Sep 2007, 23:50:47
Ok,

Just tested.

On non-dedicated server, I got the coords displayed in hint, and then everything else worked (like usual).

Dedicated server:  coords displayed, then nothing else happened (ie. No marker created, heli doesn't take off).

Could the 'setmarkerpos' command be 'breaking' on the dedicated server?  Am I calling it wrong?

Title: Re: Script Issue on Dedicated Server
Post by: Mandoble on 05 Sep 2007, 00:03:54
On a dedicated server this will never work.
? (!isServer): exit
the dedicated server has no player, so no one will activate the map single click and no marker will be created, etc.
Are you executing this script from a trigger?
Title: Re: Script Issue on Dedicated Server
Post by: Case on 05 Sep 2007, 00:08:10
Ok, good to know, I will remember that.

I actually have that line commented out since right after I confirmed it didn't fix anything for me.

This script is being called from a radio activation trigger.

If you have time you could download the mission from the link above and have a closer look if you want.

Thanks again for your time.
Title: Re: Script Issue on Dedicated Server
Post by: Mandoble on 05 Sep 2007, 00:31:56
I would not test it in a dedi server, and it is already working in SP. If you dont get the hint with the coords then the problem is in onMapSingleClick "AlphaTarget setpos _pos; setfire=false" while it seems correct to me.
Does "AlphaInsertion" marker already exist on the map?
Title: Re: Script Issue on Dedicated Server
Post by: Case on 05 Sep 2007, 00:36:45
I do get the hint with the coords in both Ded and non-ded server.

It seems like it isn't creating the marker properly.

The 'AlphaInsertion' marker DOES NOT exist on the map, only the invisible H marker I use to place it.

I will try a test with creating the markers in the editor.

EDIT:  Just finished testing after creating the markers in the editor.  The markers aren't being placed at all on a map click, but the coords are being displayed in the Hint.

I will be offline for the next few hours, but will check in a little later this evening.
Title: Re: Script Issue on Dedicated Server
Post by: Nixer6 on 05 Sep 2007, 08:09:32
On a dedicated server this will never work.
? (!isServer): exit
the dedicated server has no player, so no one will activate the map single click and no marker will be created, etc.
Are you executing this script from a trigger?

Thanks Mando.... :-[

Sorry for the FUD case.

This MP stuff is SO much more complicated than SP scripting. :scratch:

I have pretty much resorted to using small lines of code in waypoint and trugger on activation fields to get things done.

edit:

Maybe someone can enlighten me. What's the difference between

Code: [Select]
? (!isServer): exit
and

Code: [Select]
if (not (local server)) exitwith {};
besides the obvious .sqs vs .sqf syntax......

The second example is from a perfectly working script in Evolution v 3.0 by KilJoy, which works quite well on a dedi server.
Title: Re: Script Issue on Dedicated Server
Post by: SyB on 06 Sep 2007, 14:28:02
both do exactly the same thing...

the first one utilizes the in-built ArmA scripting function that returns a boolean value indicating if the command has been issued on a 'dedicated server' or on a 'host'. then the boolean is being 'reversed' by applying a 'not' command to it.

Code: [Select]
case : When this script is run on a client...

the isServer will return 'false', then it will be reversed to a 'true', then the 'if' command test will be positive and so the exit command will be executed.


Code: [Select]
case: When this script is run on a 'server' or 'host'...

the isServer will return 'true', then it will be reversed to 'false', then the 'if' command test will be negative and the 'exit' command will not be run and processing of the script will continue.

So, for your first example... essentially the pseudo code is saying...

Code: [Select]
if this script is running on a dedicated server or host then continue else exit

the second example uses the scripting command 'local' to test if a particular 'object' is local to the machine that the script is being run on. In this case a gamelogic that has been given the 'vehicleVarName' of 'server'.
As gamelogics are only ever created on a 'dedicated server' or 'host' then when this script is run on a client computer the result will be 'false', then the result is being reversed by the 'not' command and consequently when the result is tested by the 'if' it will process the exitwith {};

so...

Code: [Select]
case : When this script is run on a client...

the 'local server' command will return a 'false' and then be reversed by the 'not' command and become a 'true'. When tested by the if statement it will result in a positive and so the exitWith command will be processed.

Code: [Select]
case: When this script is run on a 'server' or 'host'...

the 'local server' command will return a 'true' and the be reversed by the 'not' command and become a 'false'. When tested by the 'if' statement it willl result in a negative and so the exitWith command will not be processed - processing of the rest of the script file will continue.

So, for your 2nd example... essentially the pseudo code is saying...

Code: [Select]
if this script is running on a dedicated server or host then continue else exit

You should use the isServer boolean statement from this day on in ALL your scripting, irrespective of whether it is sqs or sqf syntax. Reason, it is more efficient by 1 order of magnitude in that it does not require the additional overhead of one gamelogic object called 'server' to exist within the mission.

Note:- I am not saying that the 'old' method is exactly taxing the whole of ArmA, your computer or the mission. I am simply stating that the use of the 'isServer' method was implemented in ArmA for a reason - note the reason and make use of it - it is more efficient.

does this ramble make sense?  :dry:


the main reason your script isn't working is...

when this script is run in single player mode it will display a 'hint' then the script will exit.

when this script is run in host mode it will display a 'hint' then the script will continue processing... but where is 'AlphaTarget' object defined? And, where is '_pos' defined?

when this script is run on a dedicated server it will not display a hint message on your client computer. the hint will display on the dedi. but seeing as there is no player to see it the nothing happens. the script will continue processing but as above... where is 'AlphaTarget' object defined? And, where is '_pos' defined?

Title: Re: Script Issue on Dedicated Server
Post by: Case on 06 Sep 2007, 16:40:59
Sy,

Thanks for the post, that is good info.

That makes sense about not seeing the 'hint'.  Any suggestions on debugging on a dedi server?  should I use 'sidechats' then?

To answer your questions:

AlphaTarget is a marker created in the editor originally.  This is a new change that I did while troubleshooting with Mandoble.  Originally, it didn't exist as an object as I was trying to create it via script (and this worked ok, but not on a dedicated server).

The _pos variable, I believe, is created during the 'onmapsingleclick' command.  Again, this was me copying someone else's script, and it worked for me, but not on a dedicated server.

Check my first post, I have the mission zipped up for download if you feel like taking a quick look at it.  I can't remember if that version has the alphatarget and bravotarget markers created in the editor.  If they are there, they will be in the farthest most NW corner of the map.

Cheers!
Title: Re: Script Issue on Dedicated Server
Post by: SyB on 06 Sep 2007, 17:13:52
I'll have a squizzy at your mission tomorrow... off to bed...

sidechats etc. need to be run on all computers you want the text displayed on... it's a bit of a headache really... but if you look at BAS2's (http://www.ballisticaddonstudios.com/) basf mission framework or Sickboy's mod over at SixthSense you can see examples of nifty clean tricks to transmit messages around MP clients...


as far as debugging MP missions... that's really the only way... displaying hint's and sidechats, groupchats etc...

personally, i use a in-game addon that lets me run script while in mission thereby allowing debugging of MP stuff without the need for hints etc.... and no i won't send you a copy, as it can be used for 'improper use' just as easily... you could create one yourself with enough effort.

sorry about the big blurb above, btw...
Title: Re: Script Issue on Dedicated Server
Post by: Case on 06 Sep 2007, 17:18:35
Good stuff, thanks Sy,

I will take another look at the BAS F and see if I can get a better handle on what is going on in my script on the dedi-server.

I appreciate your help!

Ok,

I was able to get some debugging comments to display on a dedicated server using 'sidechat'.

I modified the script adding some debugging info here:

Code: [Select]
hint ""
mh6_1 sidechat "INSIDE alphainsertion"
;? (!isServer): exit

setfire=true
onMapSingleClick "AlphaTarget setpos _pos; setfire=false"
@!setfire
mh6_1 sidechat format ["Alpha coords: %1", getpos AlphaTarget]
"AlphaInsertion" setmarkerpos getpos AlphaTarget
; onMapSingleClick ""
mh6_1 sidechat format ["Marker Placed: %1", getpos AlphaTarget]
#Start
_markerobj = createMarker["Alpha", getpos AlphaTarget]
_markerobj setMarkerShape "ICON"
"Alpha" setMarkerType "DOT"
"Alpha" setMarkerText "Alpha Insertion"
mh6_1 sidechat format ["Marker Created: %1", getpos AlphaTarget]
driver MH6_1 flyinheight 50
driver MH6_1 domove getpos AlphaTarget
driver MH6_1 setspeedMode "Full"
mh6_1 sidechat format ["Driver flying: %1", getpos AlphaTarget]
#Insert


All of the sidechat's display out when I run the mission.  I am getting what looks like a valid coordinate each time, but again, no marker is created and the heli doesn't take off.  I will keep working on it.  If I can find some examples of placing a marker differently from how I am doing it currently I will test that....

Any other suggestions are appreciated.

Cheers!


Another update after some testing.

I placed the displaying of the coords before and after the 'onmapsingleclick'.

I am seeing some strangeness.

The coords before the click are '-5590.15,27300.7,-70.7219'.  This is true on both dedi and non-dedi server.

On non-dedicated server, the coords change to wherever I click.  On a dedi server, the coords never change.  So, something is happening (or not), with my onmapsingleclick, it doesn't seem to be setting the coords for the 'alphatarget'.

I tested some more and found these results.

I had assumed that the above coords showed the location of where i 'pre-placed' (in the editor) that 'alphatarget' marker, but it isn't.  I moved the marker close to the heli to test.  I also did this to see if the heli was experiencing the 'doesn't take-off because marker is too far away' bug.  After moving the marker and testing again, I get the exact same coords, so this actually isn't the coords of the 'alphatarget' marker, I am thinking that it is just some placeholder coords when no actual coords exist.

Regardless, again, this is working in SP and non-dedicated server, so I am back to that how I am using 'onmapsingleclick' doesn't seem to be working for me in dedicated-server mode.

Does anyone have a script that is known to work on a dedicated server that uses 'onmapsingleclick'?

Thanks!

p.s.

Here is my current code (the part I changed anyway), reflecting a few of these changes:

Code: [Select]
hint ""
mh6_1 sidechat "INSIDE alphainsertion_2"
mh6_1 sidechat format ["Pre-Place coords: %1", getpos AlphaTarget]
;? (!isServer): exit

setfire=true
onMapSingleClick "AlphaTarget setpos _pos; setfire=false"
@!setfire
mh6_1 sidechat format ["Alpha coords: %1", getpos AlphaTarget]
;"AlphaInsertion" setmarkerpos getpos AlphaTarget
createMarker["Alpha", getpos AlphaTarget]
onMapSingleClick ""
mh6_1 sidechat format ["Marker Placed: %1", getpos AlphaTarget]
#Start
"Alpha" setMarkerShape "ICON"
"Alpha" setMarkerType "DOT"
"Alpha" setMarkerText "Alpha Insertion"
mh6_1 sidechat format ["Marker Created: %1", getpos AlphaTarget]
driver MH6_1 flyinheight 50
driver MH6_1 domove getpos AlphaTarget
driver MH6_1 setspeedMode "Full"
mh6_1 sidechat format ["Driver flying: %1", getpos AlphaTarget]
#Insert


me again ;)

I found a couple things that maybe someone can help out with.

First, there is a post here:  http://www.ofpec.com/forum/index.php?topic=26071.0 that talks about a reference in the editors depot about 'making onmapsingleclick public'.  The link referred in that post is broken, and I can't find this reference anywhere.  Does anyone have info on this.

The other thing, is I downloaded an MP Artillery script that had this:

onMapSingleClick "[_pos, _units, _shift, _alt] exec ""artillery.sqs""; false"

In the init.sqs.

Does this have to do with making onmapsingleclick public?

Thanks!
Title: Re: Script Issue on Dedicated Server
Post by: hoz on 08 Sep 2007, 01:23:55
Case,

No need to post 4 times in a row, edit your last post if you need to add to the discussion.

I combined all 4 posts into your last post. Feel free to clean it up.  :D

Hoz
Title: Re: Script Issue on Dedicated Server
Post by: Nixer6 on 08 Sep 2007, 10:46:33
Case

I "think" it is more of a situation where you have to make your variable a publicVariable than making OnMapSingleClick public.

here's little code from Vienna's Arty Script, which uses OnMapSingleClick AND works on a dedicated server!

Code: [Select]
if(isNil "ArtillerieZiel231206")then
{
ArtillerieZiel231206  =  [0,0];
_marker = createMarker   ["ArtillerieZiel231206",[0,0]];
_marker   setMarkerShape "ICON";
_marker   setMarkerType  "Destroy";
_marker   setMarkerColor "ColorRed";
_marker   setMarkerSize  [0.7,0.7];
};

//if: Artillerie frei? then: Artillerie aktivieren.
if(ArtillerieZiel231206 select 1 == 0)then
{
ArtillerieZiel231206 = [0,1];
onMapSingleClick "ArtillerieZiel231206 = _pos";
_ok = createDialog "ArtillerieKarte";

//Schleife max. 1 Minute (Zeit für Eingabe in Karte)
_i=0;
_wi=1;
while{_i < 300 and dialog}do
{
Sleep 0.2; // 0.2 Sek. Pause
//Klick auf die Karte erfolgt?
if(ArtillerieZiel231206 select 0 != 0)then
{
//Entfernung zum Ziel feststellen
_wi=0;_w=0;
{if(alive _x)then{_wi=_wi+1;_w=_w+(_x distance ArtillerieZiel231206)}}forEach(_this select 0);
if(_wi>0)then{_w=_w/_wi};
//if:erlaubte Reichweite? then:Marker setzen. else: Fehlerhafte Entfernung ausgeben.
if(_w < _this select 3)then
{
//if:Geschütze unzerstört? then:Marker setzen. else: Defektmeldung ausgeben
if(_wi>0)then
{
"ArtillerieZiel231206" setMarkerPos  ArtillerieZiel231206;
"ArtillerieZiel231206" setMarkerText "Artillerieziel";
_i=4999;
onMapSingleClick "";
Sleep 3;
closeDialog 0
}

Notice these lines of code:

Code: [Select]
ArtillerieZiel231206  =  [0,0];
ArtillerieZiel231206 is defined as an array

Code: [Select]
_marker = createMarker   ["ArtillerieZiel231206",[0,0]];
ArtillerieZiel231206 is a marker name

Code: [Select]
ArtillerieZiel231206 = [0,1];
onMapSingleClick "ArtillerieZiel231206 = _pos";

ArtillerieZiel231206 is the map click position

Code: [Select]
"ArtillerieZiel231206" setMarkerPos  ArtillerieZiel231206;
 :scratch:

As I said this works quite well on a dedicated server. You can find the whole script package in the MP mission Air Cavalry by Sgt Ace.

Thought it might give you some ideas.





Title: Re: Script Issue on Dedicated Server
Post by: Case on 09 Sep 2007, 05:16:44
Thanks Nixer,

That's probably what I need to make some progress on this.  I will work with that sample.

Hoz,

Sorry about the quadruple posting ;)

I got kinda carried away there with my testing.

Title: Re: Script Issue on Dedicated Server
Post by: hoz on 09 Sep 2007, 06:08:24
np, good luck. :)
Title: Re: Script Issue on Dedicated Server
Post by: Nixer6 on 11 Sep 2007, 07:59:48
Wow!

Thanks to you Mr Peanut...and Sy too. I am grasping more of this MP scripting Voodoo all the time.  :good:

Great stuff here.  :scratch:  :D
Title: Re: Script Issue on Dedicated Server
Post by: Case on 11 Sep 2007, 15:19:20
I just deleted this post as it was mostly invalid now.

I found through testing that using a local variable (_AlphaPos) wasn't working.  I just changed it to a regular variable, and it is working now on a non-dedicated server.

Running on a dedicated server, I am still having a problem.

The code seems to run fine, but the heli pilot won't fly to the coords.  As noted, this does work in non-dedicated server.

I put some debug lines to display the coords right before the pilot is order to domove, the coords look ok, but the pilot doesn't take off.


Does anyone have any ideas?

Here is the current code:

Code: [Select]
; *****************************************************
; ** Armed Assault Script File
; *****************************************************
_unit = _this
alphaPos = []
;...put all code here that you want to display messages/play sound  to all players prior to mapclick...
?(not local _unit): waitForMapClick

;...put code here that you want to run only for the player who activated the radio trigger, such as a prompt to click the map...
Hint "Click on map for Insertion Waypoint"
MapClicked = FALSE

onMapSingleClick "alphaPos = _pos; MapClicked = true; onMapSingleClick"""""
@MapClicked
Hint ""
alphaPosX = alphaPos select 0
alphaPosY = alphaPos select 1
alphaUnpause = TRUE

{publicVariable _x} forEach ["alphaPosX","alphaPosY","alphaUnpause"]

#waitForMapClick

@alphaUnpause
alphaUnpause = FALSE
;Code section for All Players
"AlphaInsertion" setmarkerpos [alphaPosX,alphaPosY]
createMarker["Alpha", [alphaPosX,alphaPosY]]
"Alpha" setMarkerShape "ICON"
"Alpha" setMarkerType "DOT"
"Alpha" setMarkerText "Alpha Insertion"
;and setPos your invisible H(if you have one) to [alphaPosX,alphaPosY]...

?(not isServer): waitForServer_0
; Code for Server to run... put code here to run only on server such as commanding the heli to position [alphaPosX,alphaPosY]...
;
heli1 sidechat "Taking Off"
heli1 sidechat format ["X: %1", alphaPosX]
heli1 sidechat format ["Y: %1", alphaPosY]
driver heli1 flyinheight 50
driver heli1 domove [alphaPosX,alphaPosY]

alphaUnpause = TRUE
publicVariable "alphaUnpause"

#waitForServer_0
@alphaUnpause
alphaUnpause = FALSE
Title: Re: Script Issue on Dedicated Server
Post by: Mr.Peanut on 15 Sep 2007, 21:58:41
Okay. In retrospect I can see why a global variable for alphaPos was required. For some reason, even though the local variable was defined before onMapSingleClick, that command does see the _alphaPos as anything but local to its code string.

What I would try is replacing your last block of server code with:
Code: [Select]
heli1 sidechat "Taking Off"
heli1 sidechat format ["X: %1", alphaPosX]
heli1 sidechat format ["Y: %1", alphaPosY]
driver heli1 flyinheight 50
driver heli1 domove [alphaPosX,alphaPosY]

First thing is that sideChat is local, so if you run it only on the server no one will see it. Secondly, there is no harm in issuing the flyInHeight or doMove commands on all machines because on the machines for which the helicopter is not local, it will be ignored.  Even so, I do not understand why the helicopter did not take off.

I am not familiar with this type of syntax:
Code: [Select]
?(not isServer): waitForServer_0Should it not be this:
Code: [Select]
?(not isServer): goto "waitForServer_0"
Leaving out the gotos would screw everything up.

Title: Re: Script Issue on Dedicated Server
Post by: Case on 16 Sep 2007, 05:35:02
Thanks Peanut,

Screwed up my syntax, I will throw in the 'gotos', brain-lock on that one.

After fixing the syntax, I will see if it is behaving the same way.

For the code block for the heli orders, are you saying move it after the waitforserver_0 section?

EDIT: 

Ok, just finished a bunch of testing and it is behaving differently now after fixing the goto syntax.

First, here is my current code version:

Code: [Select]
_unit = _this
alphaPos = []
;...put all code here that you want to display messages/play sound  to all players prior to mapclick...
?(not local _unit): goto "waitForMapClick"

;...put code here that you want to run only for the player who activated the radio trigger, such as a prompt to click the map...
Hint "Click on map for Insertion Waypoint_a"
MapClicked = FALSE

onMapSingleClick "alphaPos = _pos; MapClicked = true; onMapSingleClick"""""
@MapClicked
Hint ""
alphaPosX = alphaPos select 0
alphaPosY = alphaPos select 1
alphaUnpause = TRUE

{publicVariable _x} forEach ["alphaPosX","alphaPosY","alphaUnpause"]

#waitForMapClick
hint "inside wait for mapclick"

@alphaUnpause
alphaUnpause = FALSE
;Code section for All Players
"AlphaInsertion" setmarkerpos [alphaPosX,alphaPosY]
createMarker["Alpha", [alphaPosX,alphaPosY]]
"Alpha" setMarkerShape "ICON"
"Alpha" setMarkerType "DOT"
"Alpha" setMarkerText "Alpha Insertion"
;and setPos your invisible H(if you have one) to [alphaPosX,alphaPosY]...

?(not isServer): goto "waitForServer_0"
; Code for Server to run... put code here to run only on server such as commanding the heli to position [alphaPosX,alphaPosY]...
;
heli1 sidechat "Taking Off"
heli1 sidechat format ["X: %1", alphaPosX]
heli1 sidechat format ["Y: %1", alphaPosY]
driver heli1 flyinheight 50
driver heli1 domove [alphaPosX,alphaPosY]

alphaUnpause = TRUE
publicVariable "alphaUnpause"

#waitForServer_0
@alphaUnpause
heli1 sidechat "inside alphaunpause"
alphaUnpause = FALSE

Once again, this works perfectly on a non-dedicated server.

On a dedicated server, the following happens:
- enters script ok
- the '?not local _unit' condition is true, which it shouldn't be, so it goto's 'waitformapclick', then it is basically broken, as the whole section to capture the mapclick is skipped.

Not sure why this is happening on the dedi-server, any ideas?

Can someone test my sample mission for me and let me know if they get the same results?? If so, I will upload it for testing somewhere.

Thanks again.
Title: Re: Script Issue on Dedicated Server
Post by: Case on 21 Sep 2007, 00:42:50
Hello again,

I have tested again, and I am getting the results as in the previous post.

If someone could test my small sample mission on a dedi-server, and let me know if they are seeing the same issues as me?

Here is a link to a zip of the mission folder and pbo:  http://www.rowlinson.ca/arma/mptesting.zip

Thanks a lot!
Title: Re: Script Issue on Dedicated Server
Post by: Mr.Peanut on 22 Sep 2007, 21:51:07
To help debug change start to:
Code: [Select]
_unit = _this
hint format ["%1",_this]
~1
alphaPos = []
;...put all code here that you want to display messages/play sound  to all players prior to mapclick...
?(not local _unit): goto "waitForMapClick"
And report back what it says.

For the "last block of code" I meant replace:
Code: [Select]
?(not isServer): goto "waitForServer_0"
; Code for Server to run... put code here to run only on server such as commanding the heli to position [alphaPosX,alphaPosY]...
;
heli1 sidechat "Taking Off"
heli1 sidechat format ["X: %1", alphaPosX]
heli1 sidechat format ["Y: %1", alphaPosY]
driver heli1 flyinheight 50
driver heli1 domove [alphaPosX,alphaPosY]

alphaUnpause = TRUE
publicVariable "alphaUnpause"

#waitForServer_0
@alphaUnpause
heli1 sidechat "inside alphaunpause"
alphaUnpause = FALSE
with
Code: [Select]
heli1 sidechat "Taking Off"
heli1 sidechat format ["X: %1", alphaPosX]
heli1 sidechat format ["Y: %1", alphaPosY]
driver heli1 flyinheight 50
driver heli1 domove [alphaPosX,alphaPosY]
Title: Re: Script Issue on Dedicated Server
Post by: Case on 24 Sep 2007, 06:43:22
Ok,

Just finished some testing, got some interesting results.

When running the mission on a non-dedicated server, I get debug info for _this as:

west 1-1-b:1 (Case)

When running on a dedi-server, I get:

<NULL-object>

So this totally explains the results I am seeing.

Now, how to fix this??

I have uploaded the current iteration of the test mission to:

www.rowlinson.ca/arma/mptesting.zip

If anyone wants to take a closer look.

Thanks Mr. Peanut.
Title: Re: Script Issue on Dedicated Server
Post by: Mr.Peanut on 25 Sep 2007, 14:24:45
Ack! Seems I somehow deleted my first post in this thread which will make anyone who henceforth reads this thread very confused. I found a possible bug which is all my fault.

Try changing the trigger On Activation from:
Code: [Select]
AlphaOn = TRUE; AlphaUnit = player; {publicVariable _x} forEach ["AlphaOn", "AlphaUnit"]to
Code: [Select]
AlphaOn = TRUE; AlphaUnit = player; {publicVariable _x} forEach ["AlphaUnit", "AlphaOn"]
It is possible the AlphaOn trigger will fire before AlphaUnit is defined, although I thought grouping the publicVariable into a forEach ensured that the variables would all be sent in the same packet.

I guess the Condition for this trigger should really be something like:
Code: [Select]
AlphaOn && not isNull AlphaUnitor even just:
Code: [Select]
not isNull AlphaUnit
Let me know if this works.
Title: Re: Script Issue on Dedicated Server
Post by: Case on 26 Sep 2007, 05:05:43
Shoot,

That sucks Peanut.  Your overview was useful.  My code is totally written from your pseudocode, so hopefully people can make sense of my sample code.

Anyway,

I did some testing with your suggestions. 

Just to confirm what I have at this point:

2 Triggers on the map, and the alphaheli.sqs script.

1st trigger, activated by Radio Alpha, on act:
Code: [Select]
AlphaOn = TRUE; AlphaUnit = player; {publicVariable _x} forEach ["AlphaUnit", "AlphaOn"]; hint "first activated";
2nd trigger condition: not isNull AlphaUnit, on act:
Code: [Select]
AlphaUnit exec "alphaheli.sqs"; hint "first trigger";
On non-dedi, this all works fine.  On dedicated server, the 2nd trigger never fires, so, I guess the 'AlphaUnit' isn't being set properly somehow when run on the dedicated server.
Title: Re: Script Issue on Dedicated Server
Post by: Mr.Peanut on 26 Sep 2007, 16:35:33
Another stab:
Code: [Select]
AlphaOn = TRUE; AlphaUnit = player; {publicVariable _x} forEach ["AlphaUnit", "AlphaOn"]; hint "first activated";replaced with
Code: [Select]
AlphaOn = TRUE; AlphaUnit = player; {publicVariable _x} forEach ["AlphaUnit", "AlphaOn"]; hint format["first activated by %1", AlphaUnit];

addendum: after searching the forums I see that you can not use thisList select 0 to get the unit who activated the radio trigger, so I changed the above code snippet not to do that.
Title: Re: Script Issue on Dedicated Server
Post by: Case on 26 Sep 2007, 19:30:03
Ok, finished testing so I deleted my other post here.

As usual, works fine on non-dedi.

On dedicated server, the first hint on the radio activated trigger displays correctly "First Activated by west 1-1-b:1 (Case)".

Then nothing happens, so it is like the second trigger with the condition "not isNull AlphaUnit" never fires and initiates the sqs.

Of course, this doesn't make sense to me, as displayed in the first trigger activation, AlphaUnit definitely is defined properly....

Let me know if anyone wants to have a quick look at the mission file, I am paranoid that I am doing something wrong here...

Cheers!
Title: Re: Script Issue on Dedicated Server
Post by: Spooner on 26 Sep 2007, 20:32:22
I can't see that global (editor-placed) radio triggers are at all useful in MP games, since, as Peanut points out, everyone runs On Act when the radio is used and you cannot tell which player actually activated the trigger. Just use createTrigger to make local triggers on each client machine. That way, when activated, you can know that the local player (player) was the one that activated the trigger, then you must manually transmit the fact that that person has used the radio to the other clients and the server.
Title: Re: Script Issue on Dedicated Server
Post by: Mr.Peanut on 26 Sep 2007, 20:48:18
Spooner, are you sure that a Radio Trigger runs on all clients? AFAIK for OFP this was not the case. I do not have a dual processor pc so I can not test this for ArmA.
Title: Re: Script Issue on Dedicated Server
Post by: Spooner on 26 Sep 2007, 21:49:49
Yes, I had problems with it very recently and the fact that it didn't work like this in OFP makes perfect sense (I was converting and fixing some old scripts that would have worked if radio clicks weren't sent to every player)! Having a single, dual or quad processor doesn't make the slightest difference to you ability to test anything MP. You just need to run two clients and have "kickduplicate = 0;" in your server.cfg (so that you can join with two games from the same cd key).
Title: Re: Script Issue on Dedicated Server
Post by: Mr.Peanut on 26 Sep 2007, 23:07:31
Um. I said dual processor so that you could run a dedicated server and a client on one machine.  My computer could not run two ArmA clients either.

So Case. According to Spooner the radio trigger fires on all machines in ArmA.  So it looks like the solution is to create locally a radio trigger for each machine.  I guess the other solution would be to only let the leader of a group be able to activate the trigger.

Quote
the fact that it didn't work like this in OFP makes perfect sense
Care to elaborate? It may make "perfect sense" to you, but the for the rest of us there is no reason to think the trigger system is any different in arma than in ofp (other than the ability to dynamically create/control them).
Title: Re: Script Issue on Dedicated Server
Post by: Case on 26 Sep 2007, 23:29:55
Ok,

I can look into doing that, not quite sure how off the top of my head.

Does this explain though why this script isn't working?  At this point I am not concerned with multiple clients activating the radio trigger, I just want to get some of this script functional.

What will make sense for the mission I am doing is that I will only allow one specific unit (squad leader) activate the trigger.

Anyway, as per my question above, does all of this explain why it still isn't working in dedi-server?

Thanks again.
Title: Re: Script Issue on Dedicated Server
Post by: Spooner on 26 Sep 2007, 23:32:54
@ Mr Peanut:
Ah, well I generally do my testing on Ramadi, so I don't have too much trouble running server + 2 clients. I can just manage to play in normal missions with minimum settings, with 20-30 FPS being the norm in a "real" mission (15 FPS being the absolute minimum). My spec is AMD64 single-core 3700+ with 2gig 333Mhz memory (I suspect the memory size is actually more important than speed for running multiple clients without the PC grinding to a disk-swapping halt).

Well, if you only let leaders activate (with condition "this and (player == leader player)"), then yes, only they can activate it, but it is still triggered for absolutely everyone when they click the radio. This could be fine if you only have one player group (on any side) in the mission, but with more than one, you wouldn't know which leader did it. You'd need to make a separate trigger for each leader or this could still cause problems when trying to guess who was triggering the radio. You also have the problem that you can't tell a non-leader that the radio button is inactive for them, since they never get past the condition. I found using createTrigger resolved all the problems with global triggers, though there may be a way to deal with them effectively without resorting to scripting that I couldn't see...

As far as making sense in OFP, I didn't mean that the OFP way any more or less sense then the ArmA way. I meant that I now understand why OFP radio scripts (specifically, I was trying to make the westAri artillery script usable) are made as they are, because they seemed very broken when I tried to use them in ArmA!

I can see I'm going to have to make a test-mission to resolve this properly. It would be better to clearly describe the behaviour rather then me trying to remember based on the problems I've had so far.

@Case:
Not sure about whether this fixes your mission, since I was just commenting on a specific problem.
Title: Re: Script Issue on Dedicated Server
Post by: Case on 26 Sep 2007, 23:44:05
Thanks for clarifying Spooner.

If you want, download my mission, it is just created specifically to test this, so I don't mess up my actual mission.

I have a link in a previous post.  I will update the file with my current version, so hang on about 5 minutes for me to upload.

Cheers!
Title: Re: Script Issue on Dedicated Server
Post by: Mr.Peanut on 27 Sep 2007, 00:29:01
Spooner,
Thanks for clarification.

Case,
(If I've got my head around this)The problem with the script is that when one player activates the radio trigger, the trigger fires for everyone. This means any player can click on the map.

In my last snippet every player should see themselves as the unit in the hint for the first trigger. I am not sure why the second trigger never fires. Every machine will publicVariable its own player as AlphaUnit, including the server whose player unit would be ObjNull. You would think that sometimes the server would get one of the players as AlphaUnit. If the server always gets ObjNull then I would conclude that the radio trigger runs only on the server.

If you can create a local radio trigger for each player (to replace the editor placed radio trigger), then I think you can use everything else we've done as is i.e. same condition for radio trigger, same second trigger, same script for second trigger. This would seem to be the best option.
Title: Re: Script Issue on Dedicated Server
Post by: Spooner on 27 Sep 2007, 00:36:52
I need to clarify what I wrote based on quickly making a test mission:
- Radio trigger with condition "this": When clicked by anyone, everyone in the mission runs On Act.
- Radio trigger with condition "this and (player == leader player)": When clicked by anyone, then all player leaders run On Act.
Thus, clicks by an individual are sent to everyone first, then the condition is checked.

Editor solution (seperate trigger and group-name required for every group that wants radio access):
- Put "westFireteam1 = group this" in the init line of everyone in the first group.
- Create a radio trigger with condition "this and (player == leader westFireteam1)". The On Act will only be performed on the westFireteam1 leader's machine if he clicks on the radio.

Script solution:
- Use createTrigger to create local triggers for every player. The On Act of the trigger will only be called if the local player clicks on the radio.

**EDIT** Oops, I made a mistake in the first paragraph. Corrected :-[
Title: Re: Script Issue on Dedicated Server
Post by: Nixer6 on 07 Jan 2008, 06:38:57
Case and I have been discussing this on another board and in PM.

I have a nice little script that works just perfect in SP and in MP testing. But...........

It will not work on a dedicated server! I have a few map click scripts and none of them work on a dedicated server.  :no:

Went looking at the biki, found this example;

This is how you do it in a .sqf file:

Code: [Select]
onmapsingleclick "[_pos, _units, _shift, _alt] execvm ""mapclick.sqf""; true";
So I made a two super simple scripts to test it.

A player, a radio alpha trigger that execs the first script, a guy named airboss who sidechats telling you to click on the map where the helo goes, a LB named helo and an empty marker named "csarIP".

first script called by the radio trigger:

Code: [Select]
airboss sidechat "click on the map where you want the helo to move to";
sleep .01;
onmapsingleclick "[_pos, _units, _shift, _alt] execvm ""mapclick.sqf""; true";

the second script called mapclick.sqf:

Code: [Select]
_pos = [0,0];
_pos = _this select 0;
OnMapSingleClick "";

sleep .005;

"csarIP" setMarkertype "marker";
"csarIP" setMarkerPos _pos;
sleep 1;
helo domove (getMarkerPos "csarIP");

The marker moves to where I click on the map. But on a dedi the helo won't budge! And I am not even telling it to move to _pos, I am telling it to move to a markerPos.

I mean what's up here? It works perfect in Sp and MP except on a dedi.  ???
Title: Re: Script Issue on Dedicated Server
Post by: Spooner on 07 Jan 2008, 15:44:48
The issue is that in SP (and for the host in non-dedicated MP) the AI helo will always be local to the player's machine, but this is never true in dedicated MP server (or everyone except the host in non-dedicated MP). The command to doMove will be ignored unless the vehicle being given the order is local to the player. What you need to do is request the server to do the move if the player is remote to the server.

Need to accept requests to move the helo on the server (used when a non-host makes the request with a non-dedicated MP server or any player with a dedicated MP server):
Code: (init.sqf) [Select]
if (isServer) then
{
    "moveHeloTo" addPublicVariableEventHandler {
        _pos = _this select 1;
        helo domove _pos;
    };
};

There is no reason to initially define _pos to [0,0] since you will set it immediately after. If you want to define it as a local variable, just use private. I assume you added the sleeps thinking they may help (they often do), but they shouldn't have an effect on the script. Add them back in if you wanted a delay for effect, rather than to "nudge" the script towards working properly ;P
Code: (mapclick.sqf) [Select]
private "_pos";
_pos = _this select 0;
OnMapSingleClick "";

"csarIP" setMarkertype "marker";
"csarIP" setMarkerPos _pos;

if (local helo) then
{
    // In case we are SP or host on non-dedicated MP
    helo domove _pos;
}
else
{
    // Request the server to do the move from a remote player.
    moveHeloTo = _pos;
    publicVariable "moveHeloTo";
};

(code examples are untested, but I'm sure you can sort them out if there are problems. I also forgot to mention that this solution REQUIRES ArmA 1.09, though you could do something more complex in 1.08 if you really want to  :weeping:).
Title: Re: Script Issue on Dedicated Server
Post by: Nixer6 on 07 Jan 2008, 17:40:05
Thanks Spooner will test it out later today and get back with the results.
Title: Re: Script Issue on Dedicated Server
Post by: Case on 07 Jan 2008, 23:35:58
I just finished testing your samples Spooner, and this works properly.

I will start to use this process to try to fix my MP mission.

Much appreciated!!

Title: Re: Script Issue on Dedicated Server
Post by: Case on 09 Jan 2008, 21:39:41
So,

I have started converting my mission over from SQS to SQF and have started to implement chopper movement using Spooner's suggestion.

I have the heli moving properly on dedi now.

My problem now is other commands to the chopper.

Do I have to create an addPublicVariableEventHandler for each type of action the heli will take?

For example, to do my insertion, I have these commands sent to the heli:

-  flyinheight
-  setspeedmode
-  land

What I am seeing happen now on dedi is the heli will fly to location clicked on the map, but just stay there at altitude.

It doesn't seem to get the following command which tells it to land and unload the passengers.  Again, this works on non-dedi server.

If I need to just create addPublicVariableEventHandler for each of the above actions, please let me know, if there is another way to do this, again, I am all ears.

I guess my question is, do you only need to use addPublicVariableEventHandler when using onMapSingleClick, or is it needed for any AI unit movement?


See below for code snippet

Code: [Select]

if (local MH6_1) then
{
    // In case we are SP or host on non-dedicated MP
    driver MH6_1 flyinheight 50;
MH6_1 domove _pos;
driver MH6_1 setspeedMode "Full";
mh6_1 sidechat format ["Driver flying non-dedi: %1", getpos AlphaTarget];
}
else
{
    // Request the server to do the move from a remote player.
    moveAlphaHeloTo = _pos;
    publicVariable "moveAlphaHeloTo";
};

mh6_1 sidechat "INSIDE alphainsertion_3";


while {MH6_1 distance _pos > 500} do
{
mh6_1 sidechat format ["Distance: %1", MH6_1 distance _pos];
sleep 1.0;
};

//#Approach
MH6_1 SetSpeedMode "Limited";
MH6_1 sidechat "Alpha team! Get ready boys, approaching insertion point";

while {!unitReady driver MH6_1} do
{
sleep 1.0
};
MH6_1 sidechat "Alpha team! Get ready for quick deployment";
MH6_1 land "GET OUT";

_numcrew = count crew MH6_1;
while { _numcrew > 1 } do
{
   _numcrew = count crew MH6_1;
sleep 1.0;
MH6_1 sidechat format ["unloading: %1 ", _numcrew];
};

This is just part of the code, where it 'stops' working is that the 'Land' command doesn't happen.


Thanks!
Title: Re: Script Issue on Dedicated Server
Post by: Spooner on 10 Jan 2008, 03:03:06
All of those actions need to be performed locally for the helo. Once you get a more complex series of things going on, it can be easier to put them all inside a function and to pass the parameters as an array within the "event" we are creating (This also makes it easy to do by just calling the function if in SP):
Code: (init.sqf) [Select]
moveHeloHandler = compile preprocessFileLineNumbers "moveHelo.sqf";

// Just pass the array of moveHeloEvent "parameters" (second element of _this) to the handler:
"moveHeloEvent" addPublicVariableEventHandler { (_this select 1) call moveHeloHandler };

Code: (moveHelo.sqf) [Select]
_helo = _this select 0;
_height = _this select 1;
_pos = _this select 2;
   
(driver _helo) flyinheight _height;
_helo domove _pos;
(driver _helo) setspeedMode "Full";

_helo sidechat format ["Driver flying non-dedi: %1", getpos AlphaTarget];

_helo sidechat "INSIDE alphainsertion_3";

while {_helo distance _pos > 500} do
{
    _helo sidechat format ["Distance: %1", _helo distance _pos];
    sleep 1.0;
};

//#Approach
_helo SetSpeedMode "Limited";
_helo sidechat "Alpha team! Get ready boys, approaching insertion point";

while {!unitReady driver _helo} do
{
    sleep 1.0
};
_helo sidechat "Alpha team! Get ready for quick deployment";
_helo land "GET OUT";

_numcrew = count crew _helo;

// You should re-calculate _numcrew at the end of a while loop like this with a sleep in it. Not sure it really matters in this case, but in others this might mean that the while logic is using information that was calculated before the sleep, not calculated just as you are doing the check.
while { _numcrew > 1 } do
{
    sleep 1.0;
    _helo sidechat format ["unloading: %1 ", _numcrew];
    _numcrew = count crew _helo;
};

You actually want this new moveHeloHandler to run on every machine, rather than just on the machine that is local to the helo. The directions to the actual helicopter need to be run on the server and the sideChat commands need to be run on every client (since all these commands will be ignored if performed on the wrong machine, it is easier to just run a single function with both types of command in it):
Code: (to move the helo) [Select]
// So the local machine performs the function directly:
_params = [MH6_1, 50, _pos];
_params call moveHeloHandler;

// Request that every OTHER machine performs the function based on receiving the event:
moveHeloEvent = _params;
publicVariable "moveHeloEvent";
Title: Re: Script Issue on Dedicated Server
Post by: Nixer6 on 10 Jan 2008, 12:13:25
Once you get a more complex series of things going on

Now that was an understatement if I ever have read one.  :P

Spooner thanks so much for your helping me to slightly better grasp the whole locality thing in MP. I am working on a few different things with helos and it's just been driving me nuts.
So...I'd like to try another approach if possible.

Since I now know that OnMapSIngleClick works to at least move markers on a dedi, would it be possible to just use a helo with waypoints and simply move the waypoints with the setWPPos command? The only trouble is that when I checked the Comref here and at the Biki (http://community.bistudio.com/wiki/setWPPos) I found that the Biki tells me the effects of the command are local, again.

Title: Re: Script Issue on Dedicated Server
Post by: Case on 10 Jan 2008, 16:12:32
Thanks Spooner, this looks great.

I am modifying this post, as I have implemented this, but it isn't working correctly.

This is what I have.

Init.sqf
Code: [Select]
moveHeloHandler = compile preprocessFileLineNumbers "InsertionAlpha.sqf";

// Just pass the array of moveHeloEvent "parameters" (second element of _this) to the handler:
"moveHeloEvent" addPublicVariableEventHandler { (_this select 1) call moveHeloHandler };


Radio Trigger with following 'on act':

Code: [Select]
onmapsingleclick "[_pos] execvm ""HeloMoveTrigger.sqf""; true";

Script HeloMoveTrigger.sqf:

Code: [Select]

private ["_pos"];
hint "In helomove trigger";

_pos = _this select 0;

MH6_1 sidechat format ["click location: %1 ", _pos];
OnMapSingleClick "";

if (local MH6_1) then
{
// So the local machine performs the function directly:
_params = [MH6_1, 50, _pos];
_params call moveHeloHandler;
}
else
{
// Request that every OTHER machine performs the function based on receiving the event:
moveHeloEvent = _params;
publicVariable "moveHeloEvent";
};

Script InsertionAlpha.sqf (I have pasted the start of this script for now).
Code: [Select]
hint "IN InsertionAlpha.SQF";

private "_pos";
_helo = _this select 0;
_height = _this select 1;
_pos = _this select 2;   


(driver _helo) flyinheight _height;
_helo domove _pos;
(driver _helo) setspeedMode "Full";

_helo sidechat "Moving";


What happens is this:

1.  Initiate Radio Trigger
2.  Click on Map
3.  Get hint text "In Helo Move Trigger"
4.  Get sidechat "click location....."

Helo doesn't move, and no further sidechats.

It looks like it isn't entering into the InsertionAlpha.sqf file, can you see why this is?

Thanks!!!
Title: Re: Script Issue on Dedicated Server
Post by: Spooner on 10 Jan 2008, 19:12:53
I'm a bit confused now, since you both seem to be asking for quite different solutions to the same problem and moving in quite different design directions, in spite of the fact that you have said that you are collaborating. This is meaning that I am having to make two solutions to every problem and is wasting a lot of time unnecessarily for all of us. Make up your mind which of you is actually doing the implementation, because I'm getting very confused!

@Case:
Bear in mind that if you use an editor radio trigger that ANY player can use it and that when ANY player uses the trigger then EVERY machine runs the code (so if I use the radio in this case, then every player then gains the map-clicking effect next time they click on the map). This is crazy and leads to a real mess in MP, but is fine in SP. In MP you should be creating radio triggers with createTrigger so that they only have a local effect, so that you can tell who has clicked and you can also limit who can click very easily (for example, to just squad leaders).

You've merged two versions of example scripts without full understanding so you've messed them up a bit. I gave one example that worked in one situation, then you redefined the situation so I changed the example. I wasn't meaning that you use a little bit of both examples and hope that then they still worked ;P You have to remember that in the example with "if (local MH6_1) then" in, the script was just acting on the helo, so you just want it acting locally Once the script has hints and chats in it, you actually want it running on the server (so the helo is given commands) and on ALL of the clients so that they see the text appear. Thus, you should use the example code I gave last and forget the original code that was appropriate in different circumstances.

Regardless, the actual reason your code was failing (though there may have been other issues, this was the most obbvious to me) was due to a variable scope issue (_params was undefined in the else clause).
Code: [Select]
_params = [MH6_1, 50, _pos]; // Need to define this here so that it is visible in both if and else blocks.
if (local MH6_1) then
{
    // So the local machine performs the function directly:
    _params call moveHeloHandler;
}
else
{
    // Request that every OTHER machine performs the function based on receiving the event:
    moveHeloEvent = _params;
    publicVariable "moveHeloEvent";
};
Title: Re: Script Issue on Dedicated Server
Post by: Case on 10 Jan 2008, 20:35:54
Spooner,

Thanks again for the reply.

To clarify, Nixer and I aren't working on the same project, we were just dealing with similiar problems (moving a heli through script), and were discussing the problem elsewhere.

Nixer, maybe you could break out from this thread with a new one with your specific problems?? :)

I will fix up the code later so that multiple people can't click on the map in MP, I understand what you are saying with this.

I updated my script and I am still having problems.

It looks like my 'InsertionAlpha.sqf' script is not being entered.

I updated my code as follows:
Code: [Select]
private ["_pos"];
hint "In helomove trigger";

_pos = _this select 0;

MH6_1 sidechat format ["click location: %1 ", _pos];
OnMapSingleClick "";
_params = [MH6_1, 50, _pos];

if (local MH6_1) then
{
// So the local machine performs the function directly:
MH6_1 sidechat "in local mh6_1";
_params call moveHeloHandler;
}
else
{
// Request that every OTHER machine performs the function based on receiving the event:
MH6_1 sidechat "In else";
moveHeloEvent = _params;
publicVariable "moveHeloEvent";
};

When it executes, I get the sidechats:  "in helo move trigger", then "in local mh6_1", but it looks like it isn't calling my MoveHeloHandler.

The first line of the MoveHeloHandler (which is the InsertionAlpha.sqf script) is to display a sidechat for "In InsertionAlpha", and this isn't showing.

Heli just stays on the ground.

Thanks again for any input on this.

Cheers!!
Title: Re: Script Issue on Dedicated Server
Post by: Nixer6 on 11 Jan 2008, 17:50:14
Yeah. Sorry for the FUD.

Still lots of good stuff here, thanks.
Title: Re: Script Issue on Dedicated Server
Post by: Case on 13 Jan 2008, 22:05:22
I did some more testing, and I think I figured out one of the problems.

Spooner, I was looking at some of your post helping some other guys on the new AddPublicVariableEventHandler.
From one of your suggestions there, I did the following change:

I changed my init.sqf line from:
Code: [Select]
"moveHeloEvent" addPublicVariableEventHandler { (_this select 1) call moveHeloHandler };
To:
Code: [Select]
"moveHeloEvent" addPublicVariableEventHandler moveHeloHandler;
This works great now on non-dedi.

On dedi server the following happens: 

1. Initiate the trigger and click the map.
2. hint's show that it is in 'helomovetrigger.sqf'
3. second hint show that it is 'in else', i added this debug, and it is in my previous post. 

So the next command that should be executing are:
Code: [Select]
moveHeloEvent = _params;
publicVariable "moveHeloEvent";

Is this the correct syntax that should be executing on a dedi-server?  Nothing is happening after this point...  heli doesn't move, and the 'InsertionAlpha.sqf' script doesn't get entered, so, to me, this seems like I have a problem with my command trying to initiate the event call from a dedi-server.

Thanks!
Title: Re: Script Issue on Dedicated Server
Post by: Spooner on 13 Jan 2008, 23:12:54
Those two lines are not equivalent, and will definitely cause the code to fail in MP (in SP, this line is ignored). It depends what moveHeloHandler expects to receive; In your case, it expects to receive only the second element of the _this array (_this select 1), rather than both elements (the first is the name of the variable that changed, the second is the new value).

These two lines are equivalent though (though the former is slightly more efficient):
Code: [Select]
"moveHeloEvent" addPublicVariableEventHandler moveHeloHandler;
"moveHeloEvent" addPublicVariableEventHandler { _this call moveHeloHandler };
Title: Re: Script Issue on Dedicated Server
Post by: Case on 14 Jan 2008, 00:21:05
Ya,

I am using the former of your two samples now, and it works better, although, as I mentioned in the thread, there seems to be a problem still.

In SP, I am using this to call the event:

Code: [Select]
_params call moveHeloHandler;
This works properly.

In MP I use:

Code: [Select]
moveHeloEvent = _params;
publicVariable "moveHeloEvent";

This MP call doesn't seem to work properly as the script I compiled as the event isn't entered (according to some debug 'hints' and sidechats).

UPDATE:

I did some more testing and I am still having problems.  What it appears to me is that the dedi-server isn't executing the precompiled .sqf file.

Let me explain.

I used Spooner's first sample where the action for the heli was explicit in the init.sqf.  This worked great (dedi and non).

I used the second example, where a precompiled script is assigned to the publicvariable handler (see above, in my instance, preprocessFileLineNumbers "alphainsertion.sqf").

When I use this method, in dedi, this precompiled script isn't executed.  I have a hint in the first line of this script, that never displays.

I am wondering if someone can confirm for sure if they know that this method works in dedi-server?

I want to know if it is a problem with my code or not, so I can try to make some more progress here.  If nobody has actually made this work in dedi, then I will move on and make several eventhandlers doing smaller things for now.

Thanks again for everyone's help with this!

Cheers!

p.s. If someone wants a copy of my scripts to have a look at, please let me know, I would be more than happy to send them to you to take a look at. 

ANOTHER UPDATE:

To clarify, and make a long story short.

When calling an event handler, is this the proper syntax: (making this up for simplicity's sake)

Init.sqf
Code: [Select]
moveHeloHandler = compile preprocessFileLineNumbers "Insertion.sqf";
"moveHeloEvent" addPublicVariableEventHandler moveHeloHandler;


Insertion.sqf
Code: [Select]
stuff... doesn't matter for my question, as what is happening to me on dedi, this doesn't ever get called
HeloMoveTrigger.sqf  - i only left the section that calls the event handler... This is the sqf called from my radio trigger.
Code: [Select]

_params = [_heli, 50, _pos, _team];

if (local _heli) then
{
// So the local machine performs the function directly:
_heli sidechat "in local";
_params call moveHeloHandler;
}
else
{
// Request that every OTHER machine performs the function based on receiving the event:
_heli sidechat "In else";
moveHeloEvent = _params;
publicVariable "moveHeloEvent";
};

The above code, is where my question REALLY is.  Is this syntax correct?

Basically, if it is local, it runs it using a call to the handler name defined in the init.sqf, and if it is remote (ie on dedi-server), it calls it by passing the parameters into the publicvariable?

Is this correct? 

If it is, I can't for the life of me see what I am doing wrong.

Again, thanks for your consideration on this problem.

Cheers!