zombov 11 Posted June 10, 2014 (edited) HI all, I am making a script that checks if my soldier is inside a vehicle before 20 seconds has passed. This is my script: _Soldier1 = _this select 0; _Vehicle1 = _this select 1; _MyTimer = 0; while { _MyTimer <= 20 } do { if ( _Soldier1 in _Vehicle1 ) then { hint "you are in to the vehicle"; } else hint format ["You must get in to the vehicle in less than %1 seconds", _MyTimer]; _MyTimer = _MyTimer + 1; sleep 1; }; hint "this is over"; The problem is that when I am inside the mission I only see the hint hint "You must get in to the vehicle in less than %1 seconds" even when I am inside it..I guess that since no error is displayed ( I am using the -showScriptErrors command) the problem would come from this condition "if ( _Soldier1 in _Vehicle1 ) " .I would like to know why this happens and how to fix it? :confused: I got that command from here: https://community.bistudio.com/wiki/in_vehicle btw: I am new to scripting and sorry for my not so good english. EDIT: The Problem got resolved, scroll down to see how the whole script ended. Edited June 10, 2014 by ZomboV Share this post Link to post Share on other sites
Lala14 135 Posted June 10, 2014 so I am summing your using execVM so it would be [player,Hunter1] execVM "script.sqf" _this select 0 represents the first part of the array which you defined as _Soidler1 and then _Vehicle1 is Hunter1.anyway one thing is that after the else there should be a { too other wise that bracket at the bottom is useless oh and also add another one at the bottom so example // player init null = [this,Hunter1] execVM "script.sqf"; _Soldier1 = _this select 0; _Vehicle1 = _this select 1; _MyTimer = 20; while { _MyTimer <= 20 } do { if ( _Soldier1 in _Vehicle1 ) then { hint "you are in to the vehicle"; } else { hint format ["You must get in to the vehicle in less than %1 seconds", _MyTimer]; _MyTimer = _MyTimer - 1; }; sleep 1; }; hint "this is over"; also I made it - 1 and defined _MyTimer at 20 since the script will only execute once My timer isEqualTo or less than 20. Share this post Link to post Share on other sites
zombov 11 Posted June 10, 2014 I had just tested it and it works great!!!... thank you for the help and the fast reply :) Share this post Link to post Share on other sites
zombov 11 Posted June 10, 2014 After the help of Lala14 and reading a lot more I perfected my old script and made this one.. fell free to do anything with it.:) This script obligates a unit to be inside a vehicle or die after 20 seconds( the time left will be displayed at the screen as a hint). ////////Put this in a SQF in your mission's folder and name the SQF as "MustInVehicle.sqf" /////Put this in the "init" of any unit: script1 = [_Soldier1,_Vehicle1] execVM "MustInVehicle.sqf" // _Soldier1 = here goes the name of the unit you want to die if out of the vehicle // _Vehicle1 = here goes the name of your vehicle _Soldier1 = _this select 0; _Vehicle1 = _this select 1; _Time = true; _TimeToGo = 20; while { _Time } do { If ( _TimeToGo <= 0 ) then { _Soldier1 setDammage 1; }; If ( _TimeToGo <= 0 ) then { _Time = False; }; If ( _Soldier1 in _Vehicle1 ) then { hint"The Soldier is in the vehicle"; _TimeToGo = 20; } else { hint format ["Get into the vehicle in %1", _TimeToGo]; _TimeToGo = _TimeToGo - 1; }; sleep 1; }; ////You can modify the hints to display anything you want or just delete them ///////////////////////////////////////////////////////////////////////// //You can also modify the _TimeToGO = 20; to any value you want.that will //change the time before the unit dies , (you will have to make the values //from the 4th line and from the 13th line equals to do so) ///////////////////////////////////////////////////////////////////////// As you can see I made some comments to help editing it at some parts. Share this post Link to post Share on other sites