RonnieJ 10 Posted July 14, 2010 Hey guys im having some problems identifying what kind og type an AI is... _grp = [_pos, side, _units, [], [], skill] call BIS_fnc_spawnGroup; _grparray = units _grp; { _type = typeOf _x; _x addeventhandler ["killed",{[_type] execVM "cash.sqf"}]; _x moveInCargo _boat; } forEach _grparray; If I debug the _type at this point I get RU_Soldier_GL .. but when passed on in the [] to cash.sqf its "any" ?? A bit confused... so what to do to find out what type a unit is and if man what type of man... that is really the question and how to pass it on to other scripts as params. Thx Share this post Link to post Share on other sites
[frl]myke 14 Posted July 14, 2010 Forget about passing type at this point, just pass _this (no brackets). Check it in the cash.sqf instead: _type = typeof (_this select 0); This will give you the needed info inside cash.sqf Share this post Link to post Share on other sites
RonnieJ 10 Posted July 15, 2010 [GLT]Myke> Im pretty sure I tried that :S didnt give me any result either... thats why I tried this way insted... Share this post Link to post Share on other sites
CarlGustaffa 3 Posted July 15, 2010 I'd say go with [GLT]Myke's suggestion. I assume the _this parameter will be needed by that script anyway in order to obtain the killer (and the killed). Try a "hit" eventhandler instead. Try a landvehicle (maybe there is a problem with boats, I don't know). Try to not move him into anything. Does anything work? What does _this contain when it is hinted in cash.sqf? Share this post Link to post Share on other sites
RonnieJ 10 Posted July 16, 2010 Cant make it work... When I parse _this _x addeventhandler ["killed",{[_this] execVM "cash.sqf"}]; I get an error trying _type = typeof (_this select 0); Something about being an array insted of an object... ---------- Post added at 07:24 PM ---------- Previous post was at 07:20 PM ---------- Oh and _this in cash seems to be an array consisting of the player who was killed and last the person who killed him... ---------- Post added at 07:29 PM ---------- Previous post was at 07:24 PM ---------- Ah... there we go... it was a simple matter of getting the right stuff from the array... _type = typeof (_unit select 0); Share this post Link to post Share on other sites
[frl]myke 14 Posted July 16, 2010 It is a matter of getting arrays right. _x addeventhandler ["killed",{[_this] execVM "cash.sqf"}]; Putting _this in square brackets means putting a array in a array. Usually _this looks like this (PUN intended): [victim, killer] Putting square brackets around it, creates this (another PUN): [[victim, killer]] which is surely nonsense in this case. OBJECT addeventhandler ["killed",{_this execVM "cash.sqf"}]; and then in the script: _victim = _this select 0; _killer = _this select 1; Share this post Link to post Share on other sites