Page MenuHomeFeedback Tracker

curatorObjectDeleted entity always null
Closed, ResolvedPublic

Description

Trying to create a hook link to an SQF which tells me (ingame hint) what unit was deleted, unit returns as null.

Details

Legacy ID
2627374814
Severity
None
Resolution
No Bug
Reproducibility
Always
Category
Zeus - General
Steps To Reproduce

initCurator.sqf

_curatorObjectDeleted = {
_object = _this select 1;
[_object] execVM "scripts\hooks\objectDeleted.sqf";
};

_curator addeventhandler ["curatorObjectDeleted", _curatorObjectDeleted];
[_curator, "curatorObjectDeleted", _curatorObjectDeleted] call bis_fnc_addScriptedEventHandler;

scripts\hooks\objectDeleted.sqf

_object = _this select 0;

hint format["%1 was deleted.", _object];

Additional Information

The other hooks work fine (curatorObjectPlaced, curatorObjectSelected).

Corrected my copypaste error thanks to Killzone_Kid pointing it out!

Event Timeline

h0rs edited Steps To Reproduce. (Show Details)Apr 21 2014, 8:11 AM
h0rs edited Additional Information. (Show Details)
h0rs set Category to Zeus - General.
h0rs set Reproducibility to Always.
h0rs set Severity to None.
h0rs set Resolution to No Bug.
h0rs set Legacy ID to 2627374814.May 7 2016, 6:27 PM

_object = _this select 1;

should it be

_object = _this select 0;

in scripts\hooks\objectDeleted.sqf?

h0rs added a subscriber: h0rs.May 7 2016, 6:27 PM
h0rs added a comment.Apr 21 2014, 9:39 AM

Sorry, copypaste error. Yes it still does not work as 0.

I had it at 1 because I was trying to figure out what the hell was wrong.

Modified my original report to reflect that :)

so scripts\hooks\objectDeleted.sqf is called but output is <null> ?

h0rs added a comment.Apr 21 2014, 12:44 PM

Correct :)

some guesswork:
At some point - probably after the eventhandler code has finished or in the next frame - the object gets deleted and all object references return null.
You're using execVM to execute "objectDeleted.sqf", i.e. it gets executed in scheduled space, so it's possible that its execution gets delayed and the object reference returns null.
Try to stay in unscheduled space (i.e. call your script) or pass a value (e.g. a string) and not an object reference to your spawned/execVM'ed script.

Im going to test this as soon as BIS fix server browser REMOTE button

Just tested. curatorObjectDeleted correctly returns the entity deleted.

h0rs added a comment.Apr 22 2014, 12:01 PM

Master85, I thought so as well. I was just a little curious as to why it works differently to the others.

Killzone_Kid, thanks for that. I guess I'll have to work around it. How did you go about implementing it?

Master85 is right. Object is returned correctly, but it's deleted before scripted executed by execVM starts. Use 'call' instead.

@h0rs deal with the deleted entity in the scope of event handler

MadDogX added a subscriber: MadDogX.May 7 2016, 6:27 PM

Mass closing tickets marked as resolved more than 1 month ago.

If the issue is in fact not resolved, please create a new ticket referencing this one and ask for it to be re-opened.