Kolmain 6 Posted July 15, 2011 private ["_car","_man","_id","_animation","_timer"]; _car = _this select 0; _man = _this select 1; _id = _this select 2; _animation = "ActsPercSnonWnonDnon_carFixing2"; if (isNil (_man getVariable "UnlockTime")) then { _man SetVariable ["UnlockTime",60, true]; }; fSetNewSkill_UnlockTime = { private ["_man","_currentTime","_newTime","_sleeptimer"]; _man = _this select 0; _currentTime = _man getVariable "UnlockTime"; _newTime = (_currentTime * 0.90) max 10; _man setVariable ["UnlockTime", _newTime, true]; _sleeptimer = _man getVariable "UnlockTime"; _sleeptimer }; [nil, nil, "per", rSpawn, _car, {_car removeAction _id;}] call RE; _timer = [_man] call fSetNewSkill_UnlockTime; _man switchMove _animation; hint "Unlocking the vehicle..."; //_car say3D "car"; sleep _timer; if (animationState _man == _animation) then { hint format["You succesfully unlocked the vehicle! It only took you %1 seconds.", _timer]; _car lock false; //_car say3D "beep"; _man playMove ""; } else { [nil, nil, "per", rSpawn, _car, {_car addAction ["Unlock/Hotwire Car","ambience\modules\crb_civilians\hotwire.sqf"];}] call RE; }; So when the script gets to hint format["You succesfully unlocked the vehicle! It only took you %1 seconds.", _timer]; It displays the message, but instead of displaying _timer, it displays <Null> and the vehicle is still locked. Any ideas anyone? Share this post Link to post Share on other sites
Q1184 0 Posted July 15, 2011 On line 6, instead of if (isNil (_man getVariable "UnlockTime")) then { Use if (isNil {(_man getVariable "UnlockTime")}) then { You need the {} brackets for isNil to evaluate a piece of code. Share this post Link to post Share on other sites
riouken 15 Posted July 15, 2011 What does _timer return, a string or number? Share this post Link to post Share on other sites
kylania 568 Posted July 15, 2011 I am not a number, I am a free typeOf "man"! Share this post Link to post Share on other sites
Kolmain 6 Posted July 15, 2011 Thanks Q, it works now! Share this post Link to post Share on other sites
Kolmain 6 Posted July 19, 2011 Well the script works now, but the player wont play the animation, so the animation check doesnt work. How can I force the player to play the animation? Share this post Link to post Share on other sites
KC Grimes 79 Posted July 19, 2011 The check isn't working as in the if/then is skipped so the final hint isn't displayed? Share this post Link to post Share on other sites
Kolmain 6 Posted July 19, 2011 if (animationState _man == _animation) then { </SPAN> That line, the animation of the player doesnt match because the animation isnt played... Share this post Link to post Share on other sites
riouken 15 Posted July 19, 2011 This is being run on the clients computer right? Because I belive switchmove is a local command. Share this post Link to post Share on other sites
Kolmain 6 Posted July 19, 2011 Um, it should be executed on... all/the server? Share this post Link to post Share on other sites
KC Grimes 79 Posted July 19, 2011 Take out the check and see what it does. If it were working as it should it technically wouldn't need the check anyway. Maybe throw some hints in to find the error and make sure it is actually an animation error. Double check to make sure the animation is right. Everything else works right? Vehicle is unlocked and hotwired, just no animation? Edit: How/where is the script executed? Share this post Link to post Share on other sites
Kolmain 6 Posted July 20, 2011 The script is an addAction on the vehicle. Taking out the check and it works anyway, but the idea is that the player can walk away and do something else and then come back and the vehicle is unlocked :( Share this post Link to post Share on other sites
Kolmain 6 Posted July 21, 2011 Should I use the RE function to broadcast it? Share this post Link to post Share on other sites
Kolmain 6 Posted July 22, 2011 My questions are always the tricky ones :( Share this post Link to post Share on other sites