Jump to content
  • 0

(Solved) Safe Zone boundary markers


Coda

Question

So, I have done practically everything I can think of to get this script to work, it's modified off of the infistar safe zones. I use CAGN (mostly for the tag friendly back pack stuff). So I tried using the following script...

 

// SETTINGS:
_zonegz =
[
        [[11463.747,317.3078,11349.89],150],        //klen
        [[4053.8501,364.76645,11668.645],150],        //bash
        [[6325.6772,304.99033,7807.7412],150],        //stary
        [[1606.6443,289.70795,7803.5156],150],        //bandit
        [[12944.227,12766.889,12766.889],150],        //hero
        [[12060.471,158.85699,12638.533],100]        //aircraft
];
{
_ctrgz01 = _x select 0;
_rdigz01 = _x select 1;    
_cntgz01 = round((2 * 3.14592653589793 * _rdigz01) / 2);
_angz01 = 0;
for "_i" from 0 to _cntgz01 do {
    _ag = (_ctrgz01 select 0) + (sin(_angz01)*_rdigz01);
    _bg = (_ctrgz01 select 1) + (cos(_angz01)*_rdigz01);
    _pos01 = [_ag, _bg, 1];
    _dirp01 = ((_ctrgz01 select 0) - (_ag)) atan2 ((_ctrgz01 select 1) - (_bg));
    _objt = createVehicle ["Sign_sphere100cm_EP1", _pos01, [], 0, "CAN_COLLIDE"];
    _objt setDir _dirp01;
    _angz01 = _angz01 + (360/_cntgz01);
    diag_log ( "getPos" );
    diag_log (getPos _objt);
    };
} forEach _zonegz;

And have it activated in the server_functions with the typical

execVM "\z\addons\dayz_server\path\file.sqf"

 

with diag_log, it shows the positions of everything in the RPT log. I even tossed in >> diag_log (_objt) and it shows the vehicle. But when I log into the server....I can't see any of the spheres around safe zones.

No errors in server RPT, when I had it running client side, no errors in client RPT.

 

Still, no luck with it actually spawning any of the "Sign_sphere100cm_EP1" vehicles.

 

-edit-

in the RPT it shows the third position at about -130 (When I check it against other structures I see a third position of 0.3 - .0.8)

 

-edit 2-

Ok so I modified the script to the following

// SETTINGS:
_zonegz =
[
        [[11463.747,317.3078,11349.89],150],        //klen
        [[4053.8501,364.76645,11668.645],150],        //bash
        [[6325.6772,304.99033,7807.7412],150],        //stary
        [[1606.6443,289.70795,7803.5156],150],        //bandit
        [[12944.227,12766.889,12766.889],150],        //hero
        [[12060.471,158.85699,12638.533],100]        //aircraft
];
if (isServer) then {
{
_ctrgz01 = _x select 0;
_rdigz01 = _x select 1;    
_cntgz01 = 90;
//_cntgz01 = round((2 * 3.14592653589793 * _rdigz01) / 2);
_angz01 = 0;
for "_i" from 0 to _cntgz01 do {
    _agz01 = (_ctrgz01 select 0) + (sin(_angz01)*_rdigz01);
    _bgz01 = (_ctrgz01 select 1) + (cos(_angz01)*_rdigz01);
    _pos01 = [_agz01, _bgz01, 0.5];
    diag_log ( "getPos A" );
    diag_log (_pos01);
    _dirp01 = ((_ctrgz01 select 0) - (_agz01)) atan2 ((_ctrgz01 select 1) - (_bgz01));
    _objt = createVehicle ["Sign_sphere100cm_EP1", _pos01, [], 0, "CAN_COLLIDE"];
    _objt setPos _pos01;
    _objt setDir _dirp01;
    _angz01 = _angz01 + (360/_cntgz01);
    diag_log ( "getPos B" );
    diag_log (getPos _objt);
    };
} forEach _zonegz;
  _thisGZ01 = createVehicle ["Sign_sphere100cm_EP1", [11345.555, 11428.116, 1], [], 0, "CAN_COLLIDE"];
  _thisGZ01 setPos [11345.555, 11428.116, 1];
};

 

All I get is _thisGZ01 to spawn, all the _objt wont.

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

At one point I was running...

// SETTINGS:
_zonegz =
[
        [[11463.747,317.3078,11349.89],150],        //klen
        [[4053.8501,364.76645,11668.645],150],        //bash
        [[6325.6772,304.99033,7807.7412],150],        //stary
        [[1606.6443,289.70795,7803.5156],150],        //bandit
        [[12944.227,12766.889,12766.889],150],        //hero
        [[12060.471,158.85699,12638.533],100]        //aircraft
];
if (isServer) then {
{
_ctrgz01 = _x select 0;
_rdigz01 = _x select 1;    
//_cntgz01 = _rdigz01;
_cntgz01 = round((2 * 3.14592653589793 * _rdigz01) / 2);
_angz01 = 0;
for "_i" from 0 to _cntgz01 do {
    _pos01 = [(_ctrgz01 select 0) + (sin(_angz01)*_rdigz01), (_ctrgz01 select 1) + (cos(_angz01)*_rdigz01), 0.5];
    diag_log ( "get Pos A left to right of _pos01" );
    diag_log ( _agz01 );
    diag_log ( "get Pos B bottom to top of _pos01" );
    diag_log ( _bgz01 );
    diag_log ( "getPos A [A,B,0.5]" );
    diag_log (_pos01);
    _objtGZ01 = createVehicle ["Sign_sphere100cm_EP1", _pos01, [], 0, "CAN_COLLIDE"];
    _objtGZ01 setPos _pos01;
    _angz01 = _angz01 + (360/_cntgz01);
    diag_log ( "get Pos B which should match A" );
    diag_log (getPos _objtGZ01);
    diag_log ( "get _objt Class" );
    diag_log ( _objtGZ01 );
    diag_log ( "get angle, should change" );
    diag_log (_angz01);
    };
} forEach _zonegz;
    _thisGZ01 = createVehicle ["Sign_sphere100cm_EP1", [11345.555, 11428.116, 1], [], 0, "CAN_COLLIDE"];
    _thisGZ01 setPos [11345.555, 11428.116, 1];
    diag_log ( "get Pos of Test Item" );  
    diag_log (getPos _thisGZ01 );
};

 

All diag_logs were posting to .RPT

 

currently trying....

 

mkrsp =
[
//the long list of positions reported by the previous scripts >> diag_log (getPos _objtGZ01); in format of [" _pos A"," _pos B"]...
];
if (isServer) then {
_mkrspA = _x select 0;
_this = createVehicle ["Sign_sphere100cm_EP1", [_mkrspA select 0, _mkrspA select 1, 0.25], [], 0, "CAN_COLLIDE"];
diag_log (_mkrspA);
} forEach _mkrsp;

 

-edit- noticed the horrible errors in the second script and hopefully fixed them.

 

-edit 2-

Noticed I had an extra }; at the end of the second script and snipped it off

-edit 3-

that last bit of code is all junk working on getting something else to work. I feel like it's an issue with the whole for "_i" from 0... part.

-edit 4-

changed the code to...

_mkrsp =
[
//[123,456],[234,567].....
];
if (isServer) then
{
    {
    _mkrspA = _x select 0;
    _mkrspB = _x select 1;
    _thismkr = createVehicle ["Sign_sphere100cm_EP1", [_mkrspA, _mkrspB, 0.25], [], 0, "CAN_COLLIDE"];
    _thismkr setPos [_mkrspA, _mkrspB, 0.25];
    diag_log (getPos _thismkr);
    } forEach _mkrsp;
};

 

And a little bit of my RPT log shows....

 4:27:29 [11368.1,201.731,0.25]
 4:27:29 [11375.6,195.955,0.25]
 4:27:29 [11383.4,190.658,0.25]
 4:27:29 [11391.5,185.862,0.25]
 4:27:29 [11399.9,181.584,0.25]
 4:27:29 [11408.5,177.841,0.25]
 4:27:29 [11417.4,174.649,0.25]
 4:27:29 [11426.4,172.02,0.25]
 4:27:29 [11435.6,169.965,0.25]
 4:27:29 [11444.9,168.491,0.25]
 4:27:29 [11454.3,167.604,0.25]
 4:27:29 [11463.7,167.308,0.25]
 4:27:29 [11473.2,167.604,0.25]
 4:27:29 [11482.5,168.491,0.25]
 4:27:29 [11491.9,169.965,0.25]

 

The only thing I can think of is for some reason using the forEach causes them not to spawn?

Link to comment
Share on other sites

  • 0

Sorry for bumping, but after four edits to my last post I felt that I needed to create a new one.

 

After running this script:

// SETTINGS:
_zonegz =
[
        [[11463.747,317.3078,11349.89],150],        //klen
        [[4053.8501,364.76645,11668.645],150],        //bash
        [[6325.6772,304.99033,7807.7412],150],        //stary
        [[1606.6443,289.70795,7803.5156],150],        //bandit
        [[12944.227,12766.889,12766.889],150],        //hero
        [[12060.471,158.85699,12638.533],100]        //aircraft
];
if (isServer) then {
{
_ctrgz01 = _x select 0;
_rdigz01 = _x select 1;    
//_cntgz01 = _rdigz01;
_cntgz01 = round((2 * 3.14592653589793 * _rdigz01) / 2);
_angz01 = 0;
for "_i" from 0 to _cntgz01 do {
    _pos01 = [(_ctrgz01 select 0) + (sin(_angz01)*_rdigz01), (_ctrgz01 select 1) + (cos(_angz01)*_rdigz01), 0.5];
    diag_log ( "get Pos A left to right of _pos01" );
    diag_log ( _agz01 );
    diag_log ( "get Pos B bottom to top of _pos01" );
    diag_log ( _bgz01 );
    diag_log ( "getPos A [A,B,0.5]" );
    diag_log (_pos01);
    _objtGZ01 = createVehicle ["Sign_sphere100cm_EP1", _pos01, [], 0, "CAN_COLLIDE"];
    _objtGZ01 setPos _pos01;
    _angz01 = _angz01 + (360/_cntgz01);
    diag_log ( "get Pos B which should match A" );
    diag_log (getPos _objtGZ01);
    diag_log ( "get _objt Class" );
    diag_log ( _objtGZ01 );
    diag_log ( "get angle, should change" );
    diag_log (_angz01);
    };
} forEach _zonegz;
    _thisGZ01 = createVehicle ["Sign_sphere100cm_EP1", [11345.555, 11428.116, 1], [], 0, "CAN_COLLIDE"];
    _thisGZ01 setPos [11345.555, 11428.116, 1];
    diag_log ( "get Pos of Test Item" );  
    diag_log (getPos _thisGZ01 );
};

 

Of course, this didn't work for me (This script should run PERFECTLY, just remove diag_log lines to shave off the size.)

So I thought maybe it's something to do with "for (_i) to (_blah) do" or maybe _objtGZ01 is being re used for the variable, so that the last position created by "forEach" is where all the red spheres should be.

 

So I ran the following...

 

_mkrsp =
[
//long list of coords formatted as [_x,_y]
];
if (isServer) then
{
    {
    _mkrspA = _x select 0;
    _mkrspB = _x select 1;
    _thismkr = (_mkrspA + _mkrspB);
    diag_log (_thismkr);
    _thismkr = createVehicle ["Sign_sphere100cm_EP1", [_mkrspA, _mkrspB, 0], [], 0, "CAN_COLLIDE"];
    _thismkr setPos [_mkrspA, _mkrspB, 0.25];
    diag_log (getPos _thismkr);
    } forEach _mkrsp;
};

 

I was able to rule out:

1) Something interfering with the script - I was able to get the "Test Item" from the first script to spawn after the "forEach" completed. No errors in RPT.

2) Items spawning in the same spot (Issue with _thisGZ01 being re-used) - Checked all areas of the safe zones, not a single red sphere.
 

The only problem I can guess is there's something I'm doing wrong with forEach?

Link to comment
Share on other sites

  • 0

Ok sorry I may have typed that wrong.

What I meant to say is that "No spheres are spawning, at all. Except when I ran the first script, the last sphere spawned. The one that was labeled as (_thisGZ01)"

 

When I ran the second script none of them spawned. I looked at every trader and the airfield.

 

Im currently fine tuning this script, which I hope will work without using "forEach"

 

_mkrsp = [
//blah blah blah
];
if (isServer) then
{
    _cntmkr = count _mkrsp;
    for "_i" from 0 to _cntmkr do
    {
    _posmkr =_mkrsp select (_i);
    diag_log (_posmkr);
    _mkrspA = _posmkr select 0;
    diag_log (_mkrspA);
    _mkrspB = _posmkr select 1;
    diag_log (_mkrspB);
    _posmkrB = [_mkrspA, _mkrspB, 0.25];
    diag_log (_posmkrB);
    _thismkr = ((_mkrspA / 2) + (_mkrspB / 2));
    diag_log (_thismkr);
    _thismkr = createVehicle ["Sign_sphere100cm_EP1", _posmkrB, [], 0, "CAN_COLLIDE"];
    _thismkr setPos _posmkrB;
    diag_log (_thismkr);
    };
};

 

Im hoping this scipt will work correctly with the usage of (_i), if I can get the spheres to spawn then I can try to use part of the previous script to set an array I hope, where this bit of code here can pull from the recently filled array.

 

-edit-

 

Tried running...

_mkrsp=[
//  format: [X,Y],[X,Y], ....
];
if (isServer) then
{
    _cntmkrA = count _mkrsp;
    _cntmkrB = (_cntmkrA - 1);
    for "_i" from 0 to _cntmkrB do
    {
    _posmkr =_mkrsp select (_i);
    diag_log (_posmkr);
    _mkrspA = _posmkr select 0;
    diag_log (_mkrspA);
    _mkrspB = _posmkr select 1;
    diag_log (_mkrspB);
    _posmkrB = [_mkrspA, _mkrspB, 0.25];
    diag_log (_posmkrB);
    _thismkr = ((_mkrspA / 2) + (_mkrspB / 2));
    diag_log (_thismkr);
    _thismkr = createVehicle ["Sign_sphere100cm_EP1", _posmkrB, [], 0, "CAN_COLLIDE"];
    _thismkr setPos _posmkrB;
    diag_log (_thismkr);
    };
    diag_log ("Marker Task Finished")
};

 

Shows the diag logs, everything is fine. Even the "Marker Task Finished"

Still, no spheres will show up around any safe zone. Zero spheres. None.

 

I don't know what else I can do but set each position to create it's own vehicle and spam thousands of lines of near identical code.

 

-edit 2-

After finding the spheres around the hero trader I realized what the problem was and....

SOLVED!!!!!!!!

SchwEde, thank you for your time and effort. I found the error and am very ashamed of it. There was a reason I didn't find the locations...

[
        [[11463.747,317.3078,11349.89],150],        //klen
        [[4053.8501,364.76645,11668.645],150],        //bash
        [[6325.6772,304.99033,7807.7412],150],        //stary
        [[1606.6443,289.70795,7803.5156],150],        //bandit
        [[12944.227,12766.889,12766.889],150],        //hero
        [[12060.471,158.85699,12638.533],100]        //aircraft
];

 

I was using select 1 for the Y pos. If you look at those, they are ordered x,z,y, except hero which is x,y,y...

 

so much shame.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...