Jump to content
Haymaker

Event Handler Troubles

Recommended Posts

Trying to get a killed unit to drop intel once killed. Script is executed on random spawned units. Take a look below but note that I am well aware that there are some variables changed for testing purposes. My issue is that for whatever reason, I get "type any, expected string" on the _spawnIntel line, which has been used prior successfully. I've tried using the position of "_unit", "killer", and "unit", each with no luck.

 

Any help is much appreciated! Thanks!

_unit = _this select 0;
_intelPool = ["Land_Wallet_01_F","EvPhoto","EvMoney","EvMap","EvKobalt","EvMoscow","EvDogTags","Intel_File2_F","Leaflet_05_Old_F","Leaflet_05_New_F","Leaflet_05_F","Land_Camera_01_F","Land_HandyCam_F","Land_Laptop_F","Land_MobilePhone_smart_F","Land_MobilePhone_old_F","Land_PortableLongRangeRadio_F","Land_SatellitePhone_F","Land_Tablet_01_F"];

if (1 > .5) then
{
	_unit addEventHandler ["killed", 
	{	
	// Get position of the killed unit
	_position = position killer;

	// Create intelligence at the position of the unit
	_intel = selectRandom _intelPool;
	_spawnIntel = createVehicle [_intel, _position, [], 0, "NONE"];

	// Execute script on intel
	_spawnIntel execVM "scripts\hm_hardIntel\hm_checkIntel.sqf";
	}
	];
};

 

Share this post


Link to post
Share on other sites

A few things,  _intelPool is only available when you apply the eventhandler, thus it is unavailable inside the eventhandler. Second "killer" is not really a variable like this,  it is passed as an argument inside the "_this" object. I do believe you also wanted the killed unit and not the unit that killed them.

_unit addEventHandler ["killed", 
{	
	params["_unit","_killer","_instigator","_useEffects"];
	_intelPool = ["Land_Wallet_01_F","EvPhoto","EvMoney","EvMap","EvKobalt","EvMoscow","EvDogTags","Intel_File2_F","Leaflet_05_Old_F","Leaflet_05_New_F","Leaflet_05_F","Land_Camera_01_F","Land_HandyCam_F","Land_Laptop_F","Land_MobilePhone_smart_F","Land_MobilePhone_old_F","Land_PortableLongRangeRadio_F","Land_SatellitePhone_F","Land_Tablet_01_F"];
	
	// Get position of the killed unit
	_position = position _unit;

	// Create intelligence at the position of the unit
	_intel = selectRandom _intelPool;
	_spawnIntel = createVehicle [_intel, _position, [], 0, "NONE"];

	// Execute script on intel
	_spawnIntel execVM "scripts\hm_hardIntel\hm_checkIntel.sqf";
}];

 

Share this post


Link to post
Share on other sites
2 hours ago, Haymaker said:

Any help is much appreciated! Thanks!

 

Hello there Haymaker!

 

I tested and it's working now.

Just write the exec to your script location

and i don't know if you are connecting this intel somehow.

 

i test the

_spawnIntel execVM "Intel.sqf";

with: hint"working";

 

addMissionEventHandler ["EntityKilled", 
{
	params ["_killed", "_killer"];	
	if (_killed isKindOf "CAManBase"  
) then
	{
	//systemChat format ["killed"];
		
			_unit = _this select 0;
			
_intel = [
			"Land_Wallet_01_F","EvPhoto","EvMoney","EvMap","EvKobalt","EvMoscow","EvDogTags","Intel_File2_F","Leaflet_05_Old_F",
			"Leaflet_05_New_F","Leaflet_05_F","Land_Camera_01_F","Land_HandyCam_F","Land_Laptop_F","Land_MobilePhone_smart_F",
			"Land_MobilePhone_old_F","Land_PortableLongRangeRadio_F","Land_SatellitePhone_F","Land_Tablet_01_F"
			];
_Random_intel = selectRandom _intel;

_spawnIntel = createVehicle [_Random_intel, _unit, [], 0, "NONE"];
			//if (1 > .5) then{

// Execute script on intel
	_spawnIntel execVM "Intel.sqf";
	
	[[
		["intel dropped","align = 'center' size = '1' font='PuristaBold'","#FBFCFE"]
	]]spawn BIS_fnc_typeText2;	
		//};
	};
}];

 

 

Share this post


Link to post
Share on other sites

i have just comment the

//if (1 > .5) then{

for test reasons

 

_3IfmmSxSbOA8bBLz9D9wA.png

 

It's not appearing everything as intel (i don't know this!)

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

×