Trying to create a hook link to an SQF which tells me (ingame hint) what unit was deleted, unit returns as null.
Description
Details
- Legacy ID
- 2627374814
- Severity
- None
- Resolution
- No Bug
- Reproducibility
- Always
- Category
- Zeus - General
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];
The other hooks work fine (curatorObjectPlaced, curatorObjectSelected).
Corrected my copypaste error thanks to Killzone_Kid pointing it out!
Event Timeline
_object = _this select 1;
should it be
_object = _this select 0;
in scripts\hooks\objectDeleted.sqf?
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 :)
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.
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.
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.