Jump to content
davidoss

[SOLVED]BIS_fnc_ObjectVar

Recommended Posts

Hi.

I encountered an strange behaviour of  BIS_fnc_ObjectVar.

I would like to knew what cause this.

This is about map building objects called on BIS_fnc_ObjectVar.
 

In SP:

buildingobject call BIS_fnc_ObjectVar // is returning variable like bis_o6 which is ok

in MP

buildingobject call BIS_fnc_ObjectVar // is returning variable like bis_o1_-2046404426 which is wrong ,causing errors

It is normal situation or i am doing something wrong?

 

Quote

Identifiers may consist of any ASCII text characters (a-z, A-Z), numbers (0-9) and underscores (_)

Identifiers must not start with a number (f.i. "9myVariable")

Identifiers of local variables must start with an underscore

 

Quote

16:27:43 Error in expression <iag_log str XZJNjl; diag_log str bis_o1_-2046404426;[XZJNjl,bis_o1_-2046404426] >
16:27:43   Error position: <-2046404426;[XZJNjl,bis_o1_-2046404426] >
16:27:43   Error -: Type Nothing, expected Number,Array,Not a Number

 

In addition i need to say when the object is for example dead body, no problem at all

Share this post


Link to post
Share on other sites

Its normal, BIS_fnc_objectVar uses the objects NetID in MP to create its vehicleVarName and map objects as you describe have a NetID of #:-# where # are numbers and the function replaces the : with an underscore, leaving the minus symbol in place to create something like bis_o1_-1750935547.

 

Using this as a reference like

getPos bis_o1_-1750935547;

will cause you problems due to the minus symbol but you can always refer to it as a string in missionNamespace ..

getPos ( missionNamespace getVariable "bis_o1_-1750935547" );

 

You also do not have to rely on the NetID for the object var name if you supply it with a unique vehicleVarName first e.g

_object setVehicleVarName "MyObject";

_object call BIS_fnc_objectVar;

Will use the var name as supplied and the function will just take care of making it a global(missionNamespace) variable across all connected machines and add a Local EH and object variable of #var for if it changes locality which is most likely unneeded for map objects.

 

Or you can handle it yourself by..

_object setVehicleVarName "MyHouse";
missionNamespace setVariable [ "MyHouse", _object, true ];

Without the Local EH and its accompanying object variable #var as explained above, is likely of no use for map objects.

 

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for dazzle the darkness a little bit.

 

Quote

 

_object setVehicleVarName "MyHouse";

missionNamespace setVariable [ "MyHouse", _object, true ];

 

 

I do exactly the same using your setvehicleVarname function and i realize that  the map buildings will not get set variable at all

only spawned object works

checked with

vehiclevarname cursortarget; // ""

The ( missionNamespace getVariable "bis_o1_-1750935547" ) could work but

the problem is i cant (or do not knew how) use any string in expression which is already a string.

_expression = format ["<br /><execute expression='[%1,%2] call fnc_createObjTask'>Read the documents</execute><br />",_targetObj,_intelholder call BIS_fnc_objectVar];

//_targetObj has globalvariable set.
//_intelholder is a building, map object. 
//I failed  setting up global variable in missionnamespace for map buildings, no errors just no variable

 

Share this post


Link to post
Share on other sites

The vehicleVarName will only be set locally (AG,EL) where the command was run. On other clients you reference it by using the missionNamespace variable.

 

Client 1 before command

Client 1 after command

Notice the vehicleVarName is correct as it was set using this client

Client 2 after command has been run on client 1

Notice client 2 has been able to destroy the house (setDamage 1) by using the missionNamespace reference to the building "MyHouse" even thought the vehicleVarName is ""

 

What are you trying to do exactly? Is this still about that other thread of yours about formatting objects into intel?

  • Like 1

Share this post


Link to post
Share on other sites

Yes. This is still that job. After i run this in MP i got those errors as above an i  am trying to pickup this together again.

The whole workaround is  to do random:

 

 store object which will be an objective for current intel

store building object where the intel file is spawned

 

or

 

store object which will be an objective for current intel

store enemy unit near where the intel file will be spawned after the unit gets killed

 

pass that objects into client side function which is called after client click intel expression link

 

The whole intel event is spawned by trigger after all objects of operation area are spawned:

 

[_thisTrigger] call fnc_createIntel;

 

fnc_createObjTask

Spoiler

fnc_createObjTask = {

	params [
	["_targetObj",objNull,[objNull]],
	["_intelholder",objNull,[objNull]]
	];
	if (isNull _targetObj) exitWith {hint "Objective allready destroyed"};
	if !(isnil {_targetObj getVariable "online"}) exitWith {hint "IED allready destroyed"};
	if !(isNil {_targetObj getVariable "curtask"}) exitWith {hint "Documents already known"};
	if (isNull _intelholder) exitWith {hint "Document is indecipherable"};

	private _string = [5] call fnc_randomStringCL;
	_targetObj setVariable ["curtask",_string,true];
	private _intel = _intelholder getVariable "inteltype";

	switch _intel do {

		case "drblk": {

			[
				
					WEST,
					[_string],
					["Intel says about roadblock position, put some charges and blew it up", "Destroy Roadblock", "Destroy Roadblock"],
					_targetObj,
					"AUTOASSIGNED",
					0,
					true,
					"destroy",
					false
					
			] remoteExecCall ["BIS_fnc_taskCreate",2,false];
		};

		case "died": {

			[
				
					WEST,
					[_string],
					["Intel says about IED position, disarm it carefully", "Disarm IED", "Disarm IED"],
					 _targetObj,
					 "AUTOASSIGNED",
					 0,
					 true,
					 "mine",
					 false
				
			] remoteExecCall ["BIS_fnc_taskCreate",2,false];
		};

		case "dbox": {

			[
				
					WEST,
					[_string],
					["Intel says about ammo cache position, destroy it", "Destroy Ammo Cache", "Destroy Cache"],
					 _targetObj,
					 "AUTOASSIGNED",
					 0,
					 true,
					 "box",
					 false
				
			] remoteExecCall ["BIS_fnc_taskCreate",2,false];
		};

		case "dstatic": {

			[
				
					WEST, 
					[_string],
					["Intel says about static gun position, destroy it", "Destroy Mounted Gun", "Destroy Gun"],
					 _targetObj,
					 "AUTOASSIGNED",
					 0,
					 true,
					 "destroy",
					 false
				
			] remoteExecCall ["BIS_fnc_taskCreate",2,false];
		};
		
		default {};
	};
};

 

 

fnc_createIntel

Spoiler

fnc_createIntel = {

	params ["_triggobj"];

	private _boxes = (entities [["O_TI_TKINS_Ammo_F","O_TI_TKINS_Wps_F","O_TI_TKINS_WpsLaunch_F","Box_IED_Exp_F","Box_East_Grenades_F"],[],false,true]) select {
			
		_x inArea _triggobj
	};
	
	private _statics = (entities [["O_TI_DSHKM_F","O_TI_Mortar_01_F","O_TI_M2MG_F","O_TI_KORD_F"],[],false,true]) select {
		
		isNil {_x getVariable "roadblkgun"} &&
		_x inArea _triggobj
	}; 
		
	private _roadblock = _triggobj getVariable "roadblock";
	private _ieds = _triggobj getVariable "iedpiles";
	
	if !(_boxes isEqualTo []) then {
	
		{
		
			[_x ,"dbox", _triggobj] call fnc_spawnIntel;
			
		} foreach _boxes;
	
	};
	
	
	if !(_statics isEqualTo []) then {
	
		{
		
			[_x ,"dstatic", _triggobj] call fnc_spawnIntel;
			
		} foreach _statics;
	
	};
	
	if !(_ieds isEqualTo []) then {
	
		{
		
			[_x ,"died", _triggobj] call fnc_spawnIntel;
			
		} foreach _ieds;
	
	};
	
	if !(_roadblock isEqualTo "") then {
	
		_flag = ((([_roadblock] call LARs_fnc_getCompObjects) select {_x isKindOf "Flag_TKINS_F"}) select 0);
		[_flag ,"drblk", _triggobj] call fnc_spawnIntel;

	};
};

 

 

fnc_spawnIntel

Spoiler

fnc_spawnIntel = {

params ["_object", "_inteltype", "_trig"];
private ["_intelholderman", "_houses", "_housesall", "_intelholderhouses", "_intelholders", "_intelholder"];

	_intelholderman =  (entities [["SoldierEB"], [], false, false]) select {_x inArea _trig && side _x == EAST && isnil {_x getVariable "targetobject"}};
	_houses = [position _trig, 300] call fnc_findbuildings;
	_housesall = _houses select {isnil {_x getVariable "targetobject"}};
	_intelholderhouses = [_housesall, count _intelholderman] call fnc_ArrRandSeq;
	_intelholders = _intelholderman + _intelholderhouses;
	_intelholders = _intelholders call BIS_fnc_arrayShuffle;
	_intelholder = selectRandom _intelholders;
	_intelholder setVariable ["targetobject", _object, true];
	_intelholder setVariable ["inteltype",_inteltype,true];
	
	switch (true) do {
		
		case (_intelholder isKindOf "Man"): {
					
			_intelholder addEventHandler ["Killed",{
						
				params ["_courpse"];
				private ["_docclass", "_doc", "_targetObj", "_intel", "_expression"];
				
				_docclass = selectRandom ["EvDogTags","EvMoscow","EvKobalt","EvMap","EvPhoto"];
				_doc = _docclass createVehicle (_courpse modelToWorld [0,-0.5,0]);
				_targetObj = _courpse getVariable "targetobject";
				_targetObj setVariable ["thisintel",_doc,false];
				_intel = _courpse getVariable "inteltype";
				_expression = format ["<br /><execute expression='[%1,%2] call fnc_createObjTask'>Read the documents</execute><br />",_targetObj,_courpse call BIS_fnc_objectVar];
				
				
				switch _intel do {
				
					case "drblk": {
					
						_doc setVariable ["RscAttributeDiaryRecord_texture","pics\roadblockintel.paa", true];
						[
							_doc,"RscAttributeDiaryRecord",
							["Intel found",_expression,""]
						] call bis_fnc_setServerVariable;
						_doc setVariable ["recipients", west, true];
						null = [_doc,"init"] remoteExec ["bis_fnc_initIntelObject",[0,-2] select isDedicated,_doc];
					};
					
					case "died": {
		  
						_doc setVariable ["RscAttributeDiaryRecord_texture","pics\iedsintel.paa", true];
						[
							_doc,"RscAttributeDiaryRecord",
							["Intel found",_expression,""]
						] call bis_fnc_setServerVariable;
						_doc setVariable ["recipients", west, true];
						null = [_doc,"init"] remoteExec ["bis_fnc_initIntelObject",[0,-2] select isDedicated,_doc];		
					
					};
					
					case "dbox": {
					
						_doc setVariable ["RscAttributeDiaryRecord_texture","pics\cacheintel.paa", true];
						[
							_doc,"RscAttributeDiaryRecord",
							["Intel found",_expression,""]
						] call bis_fnc_setServerVariable;
						_doc setVariable ["recipients", west, true];
						null = [_doc,"init"] remoteExec ["bis_fnc_initIntelObject",[0,-2] select isDedicated,_doc];
						
					};
					case "dstatic": {
					
						_doc setVariable ["RscAttributeDiaryRecord_texture","pics\staticintel.paa", true];
						[
							_doc,"RscAttributeDiaryRecord",
							["Intel found",_expression,""]
						] call bis_fnc_setServerVariable;
						_doc setVariable ["recipients", west, true];
						null = [_doc,"init"] remoteExec ["bis_fnc_initIntelObject",[0,-2] select isDedicated,_doc];
					};
					
					default {};
				};
			}];
		};
	
		case (_intelholder isKindOf "Building"): {
	
			private ["_binpos", "_selrandpos", "_docclass", "_doc", "_targetObj","_expression"];
			
			_binpos = [_intelholder] call BIS_fnc_buildingPositions;
			_selrandpos = floor (random (count _binpos));
			_docclass = selectRandom ["EvDogTags","EvMoscow","EvKobalt","EvMap","EvPhoto"];
			_doc = _docclass createVehicle (_intelholder modelToWorld [0,-8,0]);
			_doc setPos [
				
				(_intelholder buildingPos _selrandpos) select 0,
				(_intelholder buildingPos _selrandpos) select 1,
				(_intelholder buildingPos _selrandpos) select 2
					
			];
			
			_targetObj = _intelholder getVariable "targetobject";
			_targetObj setVariable ["thisintel",_doc,false];
			_expression = format ["<br /><execute expression='[%1,%2] call fnc_createObjTask'>Read the documents</execute><br />",_targetObj,_intelholder call BIS_fnc_objectVar];
		
			switch _inteltype do {
		
				case "drblk": {
				
					_doc setVariable ["RscAttributeDiaryRecord_texture","pics\roadblockintel.paa", true];
					[
						_doc,"RscAttributeDiaryRecord",
						["Intel found",_expression,""]
					] call bis_fnc_setServerVariable;
					_doc setVariable ["recipients", west, true];
					null = [_doc,"init"] remoteExec ["bis_fnc_initIntelObject",[0,-2] select isDedicated,_doc];
				};
				
				case "died": {
	  
					_doc setVariable ["RscAttributeDiaryRecord_texture","pics\iedsintel.paa", true];
					[
						_doc,"RscAttributeDiaryRecord",
						["Intel found",_expression,""]
					] call bis_fnc_setServerVariable;
					_doc setVariable ["recipients", west, true];
					null = [_doc,"init"] remoteExec ["bis_fnc_initIntelObject",[0,-2] select isDedicated,_doc];		
				
				};
				
				case "dbox": {
				
					_doc setVariable ["RscAttributeDiaryRecord_texture","pics\cacheintel.paa", true];
					[
						_doc,"RscAttributeDiaryRecord",
						["Intel found",_expression,""]
					] call bis_fnc_setServerVariable;
					_doc setVariable ["recipients", west, true];
					null = [_doc,"init"] remoteExec ["bis_fnc_initIntelObject",[0,-2] select isDedicated,_doc];
					
				};
				case "dstatic": {
				
					_doc setVariable ["RscAttributeDiaryRecord_texture","pics\staticintel.paa", true];
					[
						_doc,"RscAttributeDiaryRecord",
						["Intel found",_expression,""]
					] call bis_fnc_setServerVariable;
					_doc setVariable ["recipients", west, true];
					null = [_doc,"init"] remoteExec ["bis_fnc_initIntelObject",[0,-2] select isDedicated,_doc];
				};
				
				default {};
		
			};
		};
	
		default {};

	};
};

 

 

 

Share this post


Link to post
Share on other sites

fnc_createObjTask = {
    params[ "_target", "_objectVar" ];
    
    [
        _target,
        "task1",
        [ "Destroy House", "Destroy House", "" ],
        missionNamespace getVariable _objectVar,
        true,
        1,
        true,
        "destroy"
    ] call BIS_fnc_taskCreate;
};

player addAction[ "Create Obj Task", {
    player createDiaryRecord [ "Diary", format ["<br /><execute expression='[%1,%2] call fnc_createObjTask'>Read the documents</execute><br />",west,str(cursorTarget call BIS_fnc_objectVar)] ];
}];

I realise im using _target differently from what you want but example still shows how to format objectVar as a string into a diary expression which is all the intel is doing.

Then i retrieve the object using missionNamespace getVariable.

If I placed this example in initPlayerLocal.sqf any player could use the action and the house they are pointing to would become the target of the task. No need to remoteExec taskCreate as it already propagates to all clients.

 

Or as KK shows above you can also use objects NetID


fnc_createObjTask = {
    params[ "_target", "_objectID" ];
    
    [
        _target,
        "task1",
        [ "Destroy House", "Destroy House", "" ],
        objectFromNetId _objectID,
        true,
        1,
        true,
        "destroy"
    ] call BIS_fnc_taskCreate;
};

player addAction[ "Create Obj Task", {
    player createDiaryRecord [ "Diary", format ["<br /><execute expression='[%1,%2] call fnc_createObjTask'>Read the documents</execute><br />",west, str ( netId cursorTarget )] ];
}]

  • Like 1

Share this post


Link to post
Share on other sites

Tried with missionnamespace no luck in MP

 

Quote

23:24:39 Error in expression <[vneypFwTj,<null>] call fnc_createObjTask>
23:24:39   Error position: <<null>] call fnc_createObjTask>
23:24:39   Error Invalid number in expression

 

first argument works the second one is not, and is not null -  is a building in which i am standing

 

_expression = format ["<br /><execute expression='[%1,%2] call fnc_createObjTask'>Read the documents</execute><br />",
missionNamespace getVariable (format ["%1",_targetObj]),missionNamespace getVariable (format ["%1",_intelholder])];

I do not knew what is going about, cursortarget on _intelholder is returning variable, why this is not working for expression?

 

Tried with

_expression = format ["<br /><execute expression='[%1,%2] call fnc_createObjTask'>Read the documents</execute><br />",
objectFromNetId (_targetObj  call BIS_fnc_netId),objectFromNetId (_intelholder  call BIS_fnc_netId)];

Which cause error in SP

Quote

23:47:25 Error in expression <[<NULL-object>,<NULL-object>] call fnc_cr>
23:47:25   Error position: <<NULL-object>,<NULL-object>] call fnc_cr>
23:47:25   Error Invalid number in expression

 

 

Tried with:

_expression = 
	format [
		"<br /><execute expression='[%1,%2] call fnc_createObjTask'>Read the documents</execute><br />",
		if !(local _targetObj) then {objectFromNetId (_targetObj  call BIS_fnc_netId)} else {_targetObj},
		if !(local _intelholder) then {objectFromNetId (_intelholder  call BIS_fnc_netId)} else {_intelholder}
	];

which is working in SP  but in MP gives the same problem.

 

As follows:

http://steamcommunity.com/sharedfiles/filedetails/?id=828589743

http://steamcommunity.com/sharedfiles/filedetails/?id=828589919

http://steamcommunity.com/sharedfiles/filedetails/?id=828590024

 

Quote

 0:16:48 Error in expression <[LlsPPzl,2f380f00# 201318: house_l_3_ep1.p3d] call>
 0:16:48   Error position: <f380f00# 201318: house_l_3_ep1.p3d] call>
 0:16:48   Error Missing ]

 

 

Its not working because the expression is formated by server?

Please, i really  need help with this madness

Share this post


Link to post
Share on other sites

Stop trying to format the Object into the expression and either pass the object as its missionNamespace variable name as a STRING or the object NetID which is a STRING representing it netID numbers, then get the object in fnc_createObjectTask by using either missionNamespace on the STRING or objectFromNetID on the STRING if a NetID, as per my previous two examples.

 

I gave you two clear examples and you have not followed either, this...

missionNamespace getVariable (format ["%1",_targetObj]),missionNamespace getVariable (format ["%1",_intelholder])

I have no idea what you are doing here. I presume _targetObj/_intelHolder is a vehicleVarName ? If so getting the missionNamespace reference will just turn it back into a object.

If its a reference to the object itself then the missionNamespace  var of "612c7900# 69065: i_house_big_02_v1_f.p3d" wont exist and should be Nil.

 

objectFromNetId (_intelholder call BIS_fnc_netId)

Makes absolutley zero sense, why turn an object into a string of it netID BIS_fnc_netID which you immediately turn back into a object objectFromNetID when you know from your previous examples an object will not format properly in a usable way into your text.

Also NetID is only a valid way of doing it if you are in MP, unless you use the BI functions which are SP compatible.

 

 

_targetObj setVehicleVarName "MyTarget";                        //Give Object vehicleVarName
missionNamespace setVariable[ "MyTarget", _targetObj, true ];    //Point missionNamespace var of same STRING to reference the object, and PVed

_intelholder setVehicleVarName "MyIntelHolder";                            //Give Object vehicleVarName
missionNamespace setVariable[ "MyIntelHolder", _intelholder, true ];    //Point missionNamespace var of same STRING to reference the object, and PVed

//The above STRINGs can be anything if you are randomising stuff
//just make sure the same string is used for both the vehicleVarName and the missionNamespace Var of each object
//and each objects string is unique

_expression = format ["<br /><execute expression='[%1,%2] call fnc_createObjTask'>Read the documents</execute><br />",
str vehicleVarName _targetObj,str vehicleVarName _intelholder];        //Format variable names into text as STRINGs, str will wrap them in ""


fnc_createObjTask = {
    params[ "_targetObj", "_intelholder" ];
    
    _targetObj = missionNamespace getVariable _targetObj;        //Retrieve object from missionNamespace variable
    _intelholder = missionNamespace getVariable _intelholder;    //Retrieve object from missionNamespace variable
};

Same thing as my first example just written a different way, maybe this will help.

  • Like 1

Share this post


Link to post
Share on other sites

Short before you wrote above i just understand your previous post. The next one is even better. 

I will print it on paper and stick to my stupid head!

I was running around  the point looking for something pointless.

Sorry and thank you Larrow..

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

×