Jump to content
Sign in to follow this  
Kolmain

Local variable returning null

Recommended Posts

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

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

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

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
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

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

Um, it should be executed on... all/the server?

Share this post


Link to post
Share on other sites

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

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

Should I use the RE function to broadcast it?

Share this post


Link to post
Share on other sites

My questions are always the tricky ones :(

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×