Jump to content
Sign in to follow this  
fdrph

BIS_fnc_MP isn't pulling my other function?

Recommended Posts

ok so I have this in the description.ext

class Extended_Init_EventHandlers {
    class CAManBase
    {
       init = " _this call (compile preprocessFileLineNumbers 'spawn_intel.sqf')";
    };
};

this in spawn_intel.sqf

_object = _this select 0;
if (side _object == EAST) then {

   _object addEventHandler ['killed',{ _suitcase = createVehicle ["Land_Suitcase_F",getpos (_this select 0), [], 0, "None"] }  ];
   [[_suitcase,"<t color='#FF0000'>Gather Intel</t>"],"addactionMP", true, true] spawn BIS_fnc_MP;
};

however it runs fine until the [[_suitcase,"..... part. I think it is not acessing addactionMP which is in "core\modules\cacheScript\functions\cacheFunctions.sqf" as

addactionMP = {
   private["_object","_screenMsg"];
   _object = _this select 0;
   _screenMsg = _this select 1;

   if(isNull _object) exitWith {};

   _object addaction [_screenMsg,"call intelPickup"];
};

I can check addactionMP is compiled by typing it into the console debugger ingame

Could it be that _suitcase isn't being assigned an object!? but that in unheard of... :O I checked with public variables and there

were weird timing issues where sometimes it worked sometimes it didn't

btw there is a #include for cachefunctions.sqf in the init.sqf

halp? :C

#EDIT1

Did some testing, turns out addactionMP is being called fine and the problem is that _suitcase isn't being assigned the object being created with that event handler.

if I do

_test1 = createVehicle ["Land_Suitcase_F",getpos player,[],0,"None"];
[[_test1,"<t color='#FF0000'>Pickup Intel</t>"],"addactionMP", true, true] spawn BIS_fnc_MP;

it works

dafuq? any ideas?

---------- Post added at 00:41 ---------- Previous post was at 22:51 ----------

#EDIT2

found something else while debugging...

if (side _object == EAST) then {

	_object addEventHandler ['killed',{
		_scase = createVehicle ["Land_Suitcase_F",getpos (_this select 0), [], 0, "None"];
		hint format ["%1",_scase]
	} ];
	sleep 5;
	hint format ["SECOND HINT: %1",_scase];

first hint displays object fine second hint displays SECOND HINT: any

so apparently local variables inside eventhandlers don't leave them! whaaat? but I don't wanna make a global variable :C

---------- Post added at 00:51 ---------- Previous post was at 00:41 ----------

#EDIT3

ISSUE FIXED

CAUSE: Local variables like _scase don't leave the event handler {} code area to the rest of the script for some reason

Is this behavior known/intended or I stumbled upon a bug?

anyway final script is:

	_object addEventHandler ['killed',{
		_scase = createVehicle ["Land_Suitcase_F",getpos (_this select 0), [], 0, "None"];
		[[_scase,"<t color='#FF0000'>Pickup Intel</t>"],"addactionMP", true, true] spawn BIS_fnc_MP;
	} ];

Edited by Fdrph

Share this post


Link to post
Share on other sites

You are creating the local variable in a different scope. Try adding private "_scase"; to the top of the script.

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  

×