Treelor 0 Posted July 20, 2010 This code: waitUntil {alive player}; gives "Error generic error in expression," originating from "alive." The frustrating part is that that is THE ONLY line in the script. I'm calling it via this: player addEventHandler ["killed", {_handler = _this execVM "functions\handlers\respawn.sqf"}]; from init.sqf. What the hell is going wrong? The BIKI tells me that getting the generic expression error means there's a datatype mismatch, but afaik, the command player returns an object, and the command alive looks for an object. What am I doing wrong? Share this post Link to post Share on other sites
Andy455 11 Posted July 20, 2010 Maybe instead of player you could try: _unit = _this select 0; waitUntil {alive _unit}; Share this post Link to post Share on other sites
f2k sel 161 Posted July 20, 2010 no problems here at least in single play. Share this post Link to post Share on other sites
Treelor 0 Posted July 20, 2010 Doing Andy's suggestion returns "type array, expected object," since that's actually the _first_ thing I did. Using the player object directly was my second resort. Last time I checked, the player wasn't an array D: Share this post Link to post Share on other sites
CarlGustaffa 4 Posted July 20, 2010 No, but _this in the killed eventhandler contains two parameters when sent; [unit who got killed, the killer who killed]. So _this select 0 should get the killed unit. Does it make a difference if you use waitUntil {player==player}; ? Share this post Link to post Share on other sites
shuko 58 Posted July 20, 2010 I just tested this: this addEventHandler ["killed", {_this execVM "respawn.sqf"}]; waituntil {alive player}; hint "its alive!"; Worked fine. Share this post Link to post Share on other sites
Treelor 0 Posted July 20, 2010 That's the confusing part Shk - I'm doing _exactly_ that. There shouldn't be anything wrong with it, yet its telling me that _this select 0 is an array. Using player==player allows the script to run, but doesn't wait for the player to come back to life. Share this post Link to post Share on other sites
shuko 58 Posted July 20, 2010 Where are you adding the eventhandler? init.sqf? unit init field? If something says that it's an array and was expecting something else, just print it out and see what it actually has inside. Share this post Link to post Share on other sites
Treelor 0 Posted July 20, 2010 Was doing it from init.sqf. Rewriting the script seemed to solve the problem. Maybe its better to sweep this weird one under the rug as a quirk in the system. Share this post Link to post Share on other sites
shuko 58 Posted July 20, 2010 There are "quirks", but less than what people think. I'm going to go and take a guess. You did "player addeventhandler..." in init.sqf without "waituntil {!isnull player}"? Share this post Link to post Share on other sites
CarlGustaffa 4 Posted July 21, 2010 Sorry, my bad. With my player==player (or "local player" in an MP environment) I actually was referring to the !isnull player thingie, not what was going on in the actual script, sorry about that. There are things that should wait until the player is an actual object in the game. To test against these things (I never know for sure what they are, they always strike apparently random). To test, make sure you have a working briefing (setting the required steps in description.ext and supplying an empty briefing.html), and try the mission with and without the briefing kicking in (hit Shift preview from the editor). If something differ in how things work, the player "getting things" before he is an actual player is usually the root of the problem - yet oh o hard to find some times. Share this post Link to post Share on other sites