Warning: include(/var/www/html/forum/Sources/../../../includes/depot_files/OFPEC_get_header_image.inc.php): failed to open stream: No such file or directory in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 146

Warning: include(): Failed opening '/var/www/html/forum/Sources/../../../includes/depot_files/OFPEC_get_header_image.inc.php' for inclusion (include_path='.:/usr/local/lib/php') in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 146

Notice: Undefined index: OFPEC in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 152

Notice: Trying to access array offset on value of type null in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 152

Notice: Trying to access array offset on value of type null in /var/www/html/forum/Sources/Load.php(2272) : eval()'d code on line 152
    Home   Help Login Register  

Author Topic: Script Issue on Dedicated Server  (Read 18027 times)

0 Members and 1 Guest are viewing this topic.

Offline Case

  • Members
  • *
Re: Script Issue on Dedicated Server
« Reply #15 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.
« Last Edit: 05 Sep 2007, 00:50:25 by Case »

Offline Nixer6

  • Members
  • *
Re: Script Issue on Dedicated Server
« Reply #16 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.
« Last Edit: 06 Sep 2007, 11:01:24 by Nixer6 »
Why do I have to be a Rocket Scientist to make a good mission?

SyB

  • Guest
Re: Script Issue on Dedicated Server
« Reply #17 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?

« Last Edit: 06 Sep 2007, 14:46:10 by Sy »

Offline Case

  • Members
  • *
Re: Script Issue on Dedicated Server
« Reply #18 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!

SyB

  • Guest
Re: Script Issue on Dedicated Server
« Reply #19 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 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...
« Last Edit: 06 Sep 2007, 17:20:48 by Sy »

Offline Case

  • Members
  • *
Re: Script Issue on Dedicated Server
« Reply #20 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!
« Last Edit: 08 Sep 2007, 01:22:17 by hoz »

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re: Script Issue on Dedicated Server
« Reply #21 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
Xbox Rocks

Offline Nixer6

  • Members
  • *
Re: Script Issue on Dedicated Server
« Reply #22 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.





Why do I have to be a Rocket Scientist to make a good mission?

Offline Case

  • Members
  • *
Re: Script Issue on Dedicated Server
« Reply #23 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.


Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re: Script Issue on Dedicated Server
« Reply #24 on: 09 Sep 2007, 06:08:24 »
np, good luck. :)
Xbox Rocks

Offline Nixer6

  • Members
  • *
Re: Script Issue on Dedicated Server
« Reply #25 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
Why do I have to be a Rocket Scientist to make a good mission?

Offline Case

  • Members
  • *
Re: Script Issue on Dedicated Server
« Reply #26 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
« Last Edit: 13 Sep 2007, 18:35:42 by Case »

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Script Issue on Dedicated Server
« Reply #27 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.

urp!

Offline Case

  • Members
  • *
Re: Script Issue on Dedicated Server
« Reply #28 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.
« Last Edit: 17 Sep 2007, 05:55:11 by Case »

Offline Case

  • Members
  • *
Re: Script Issue on Dedicated Server
« Reply #29 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!
« Last Edit: 21 Sep 2007, 00:45:09 by Case »