Jump to content
Sign in to follow this  
mantls

JIP Marker Function help.

Recommended Posts

Hello,

i wrote these 2 little functions in order to handle markers for JIP's.

Even though they seem to be workimg (tested them on a localy hosted dedicated) i'm getting an undefined variable error.

setMarkerJIP =
{
private ["_marker","_pos","_type","_size","_text","_color","_brush","_shape","_markerArray","_JIPArray"];
_marker = _this select 0;

_pos = getMarkerPos _marker;
_type = getMarkerType _marker;
_size = getMarkerSize _marker;
_text = _this select 1;
_color = getMarkerColor _marker;
_brush = markerBrush _marker; 
_shape = markerShape _marker; 

_markerArray = [_marker,_pos,_type,_size,_text,_color,_brush,_shape];

JIPArray = JIPArray + [_markerArray];
//server setVariable ["JIPMarks",_JIPArray,true]; 
publicVariable "JIPArray";

};


createMarkerJIP =
{
/* [_marker,_pos,_type,_size,_text]; */

private ["_array","_marker","_pos","_type","_size","_text","_color","_brush","_shape","_mrk","_unit","_JIPArray"];
_unit = _this select 0;

if !(local _unit) exitWith {};
if (!isNil "JIPArray") then 
{


 for "_i" from 0 to (count JIPArray) do
 {
  _array = JIPArray select _i;
  _marker = _array select 0;
  _pos = _array select 1;
  _type = _array select 2;
  _size = _array select 3;
  _text = _array select 4;
  _color = _array select 5;
  _brush = _array select 6; 
  _shape = _array select 7;

  _mrk = createMarkerlocal [_marker,_pos];
  _mrk setMarkerTypelocal _type;
  _mrk setMarkerSizelocal _size;
  _mrk setMarkerTextlocal _text;
  _mrk setMarkerColorlocal _color;
  _mrk setMarkerbrushlocal _brush;
  _mrk setMarkershapeLocal _shape;  

 };

};

if (true) exitWith {}; 
};


it's called like this in the init.sqf

if (!isServer && isNull player) then {isJIP=true;} else {isJIP=false;};

[Other Code]...

if (isJIP) then 
{
[player] call createMarkerJIP;
};

and i'm getting this Error

 for "_i" from 0 to (count JIPArray) do
 {
  _array = JIPArray select _i;
  _marker = #_array select 0;
ERROR: Undefined Variable in Expression: _array

Like i said, it seems to be working non the less. But i'd still like to fix this.

Cheers, help is much appreciated!

Share this post


Link to post
Share on other sites

i see that you have declared a private var of "_JIPArray" and a public var of "JIPArray"

not sure why the names are so similar? i would do a rewrite personally.

try this to get ride of the error:

cuzz your trying to Count JIPArray which is nil or was that intentional lol?

if (isNil "JIPArray") then {JIPArray = //what you want it to equal here};

then do your for i from x code etc

Edited by falconx1

Share this post


Link to post
Share on other sites

Ok, think i got it fixed now. _JIParray was a leftover from earlier versions.

since arrays start at 0 the last iteration of the code was always undefined, duh! :D

So here's the updated code:

setMarkerJIP =
{
private ["_marker","_pos","_type","_size","_text","_color","_brush","_shape","_markerArray","_JIPArray"];
_marker = _this select 0;

_pos = getMarkerPos _marker;
_type = getMarkerType _marker;
_size = getMarkerSize _marker;
_text = _this select 1;
_color = getMarkerColor _marker;
_brush = markerBrush _marker; 
_shape = markerShape _marker; 

_markerArray = [_marker,_pos,_type,_size,_text,_color,_brush,_shape];

JIPArray = JIPArray + [_markerArray];
//server setVariable ["JIPMarks",_JIPArray,true]; 
publicVariable "JIPArray";

};


createMarkerJIP =
{
/* [_marker,_pos,_type,_size,_text]; */

private ["_array","_marker","_pos","_type","_size","_text","_color","_brush","_shape","_mrk","_unit"];
_unit = _this select 0;

if !(local _unit) exitWith {};
if (isNil "JIPArray") then 
{
 JIPArray = [];
};

  if (count jiparray == 0) exitWith {};

 for "_i" from 0 to ((count JIPArray) - 1) do
 {
  //_array = JIPArray select _i;
  _marker = (JIPArray select _i) select 0;
  _pos = (JIPArray select _i) select 1;
  _type = (JIPArray select _i) select 2;
  _size = (JIPArray select _i) select 3;
  _text = (JIPArray select _i) select 4;
  _color = (JIPArray select _i) select 5;
  _brush = (JIPArray select _i) select 6; 
  _shape = (JIPArray select _i) select 7;

  _mrk = createMarkerlocal [_marker,_pos];
  _mrk setMarkerTypelocal _type;
  _mrk setMarkerSizelocal _size;
  _mrk setMarkerTextlocal _text;
  _mrk setMarkerColorlocal _color;
  _mrk setMarkerbrushlocal _brush;
  _mrk setMarkershapeLocal _shape;  

 };



if (true) exitWith {}; 
};

init.sqf

if (!isServer && isNull player) then {isJIP=true;} else {isJIP=false;};

[Other Code]...

if (isJIP) then 
{
[player] call createMarkerJIP;
};

NOTE: setMarkerJip has to be called like this:

 ["[b]markerName[/b]","[b]MarkerText[/b]"] call setMarkerJip; 

feel free to use it, afaik there's no function for that so far (suprisingly, maybe i just didn't search properly).

cheers

Edited by mantls
Fixed code, added description

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×