BullyBoii 10 Posted May 1, 2013 (edited) Hello everyone, with some help from others I have made my first fully functioning vehicle driver checker thingy.. this is used to check for a vehicle driver and eject them if they do not meet the requirements of the parameters in the script. Features: -check driver against a set unit class -apply ranks requirements Coming soon (hopefully) -multiple unit classes -custom vehicle entry messages Here is the link to download the script: https://www.dropbox.com/s/et8mwrxy0ejwyak/fn_vehicleDriver.rar if you cannot or do not wish to download, i have posted the script below: ////////////////////////////////////////////////////////////////////// // Function file for Armed Assault // Created by: Adam Bullock - SOF // Path = "f\fn_vehicleDriver.sqf"; ////////////////////////////////////////////////////////////////////// //Thankyou for downloading my vehicle driver checker script thingy... //I hope this is as useful to you as it is to me ///////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////// //How to use the script ///////////////////////////////////////////////////////////////////////// //To use the script you need to save a mission file. then you need to //find the mission file directory e.g. MyDocuments\Arma3Alpha\missions //place this file into the mission you have just saved. Once that is //done load up the Arma 3 Alpha mission editor. Place an empty vehicle //on the map. then into its init field type the following //_nul = [] execVM "fn_vehicleDriver.sqf" This will launch the script. //in the [] you need to put your parameters, look below on how to do this ///////////////////////////////////////////////////////////////////////// //Parameters ///////////////////////////////////////////////////////////////////////// //the first parameter is the vehicle name. Therefore you can type //[this] if the unit the script id for, is the unit that you are calling //the script from, however, I recommend typing in the units name //e.g. [Heli_1] //the second parameter is the unit type available to drive the vehicle //you find this out from the config viewer e.g. [Heli_1, "B_Helipilot_f"] //finally to assign a minimum rank you need to type in the rank that a player //will be allowed to drive the vehicle at. The list is below //"PRIVATE", "CORPORAL", "SERGEANT", "LIEUTENANT", "CAPTAIN", "MAJOR", "COLONEL" //variables _veh = _this select 0; _driverType = _this select 1; _minRank = _this select 2;//has to be _rank = 0; _driverrankNum = 0; _driverPresent = 0; _timer = 1; //checks for driver type and if none input, selects default if (_driverType == "") then { _vehType = typeof _veh; switch _vehType do { ////////////////////////////////////////////////////////////////////////////////// //this is where you add new vehicles //this format ////////////////////////////////////////////////////////////////////////////////// //case "//vehicle class name//" : //{ // _driverType = "//unit type that can be driver//"; //}; case "B_AH9_F" : { _driverType = "B_Helipilot_F"; }; case "B_MH9_F" : { _driverType = "B_Helipilot_F"; }; }; ////////////////////////////////////////////////////////////////////////////////// } else {_driverType = _this select 1;}; //checks rank if (_minRank == "") then {_minRank = "PVT";} else {_minRank = _minRank}; //assigns rank number switch _minRank do { case "PRIVATE" : {_rank = 0;}; case "CORPORAL" : {_rank = 1;}; case "SERGEANT" : {_rank = 2;}; case "LIEUTENANT" : {_rank = 3;}; case "CAPTAIN" : {_rank = 4;}; case "MAJOR" : {_rank = 5;}; case "COLONEL" : {_rank = 6;}; }; while {alive _veh} do { { _driverVeh = driver _veh;//vehicle driver if (isNull _driverVeh) then {_driverPresent = 0; _timer = 1;} else { _driverClass = typeOf _driverVeh; _driverPresent = 1; if (_driverClass != _driverType) then { moveOut _driverVeh; TitleText ["YOU ARE NOT ALLOWED TO DRIVE/PILOT THIS VEHICLE", "PLAIN"]; } else { _driverRank = rank _driverVeh; switch (_driverRank) do { case "PRIVATE" : {_driverRankNum = 0;}; case "CORPORAL" : {_driverRankNum = 1;}; case "SERGEANT" : {_driverRankNum = 2;}; case "LIEUTENANT" : {_driverRankNum = 3;}; case "CAPTAIN" : {_driverRankNum = 4;}; case "MAJOR" : {_driverRankNum = 5;}; case "COLONEL" : {_driverRankNum = 6;}; }; //hint format ["%1\n\n%2", _driverRankNum,_rank]; if (_driverRankNum < _rank) then { moveOut _driverVeh; TitleText ["YOU ARE NOT OF SUFFICIEENT RANK TO DRIVE THIS VEHICLE", "PLAIN"]; } else { if (_driverPresent == 1) then { switch _vehType do { case "B_AH9_F" : {_txt = "Welcome to the AH-9 Littbird Attack Chopper";}; case "B_MH9_F" : {_txt = "Welcome to the MH-9 Littbird Transport Chopper";}; }; while {_timer >= 0} do { titleCut ["WELCOME", "PLAIN"]; sleep 4; _timer = _timer - 1; titleCut ["", "PLAIN FADED"]; }; }; }; }; }; sleep 0.3; } forEach _driverType; }; Edited May 1, 2013 by BullyBoii Share this post Link to post Share on other sites
killzone_kid 1329 Posted May 1, 2013 (edited) You have to understand how isNil works. It simply checks if the variable was or wasn't defined. In your script you define both variables _driverType = _this select 1; _minRank = _this select 2; which you test if their values are undefined or not later. If you do not pass second and third parameter to the script ( _this select 1 _this select 2) you will get error. if your script has no errors means these 2 variables are always defined. isNil _driverType will check if the value of _driverType is undefined variable for example, and since you pass on a class or "" it will always be true unless there is a variable with the same name as class and is defined. Since they are strings you want to check them if they are empty or not instead if (_driverType == "")... or if (_driverType != "") if (_minRank == "") ...or if (_minRank != "") isNil will only be true is the variable you test is nil myvar = nil; if (isNil "myvar") //true Edited May 1, 2013 by Killzone_Kid Share this post Link to post Share on other sites
BullyBoii 10 Posted May 1, 2013 You have to understand how isNil works. It simply checks if the variable was or wasn't defined. In your script you define both variables _driverType = _this select 1; _minRank = _this select 2; which you test if their values are undefined or not later. If you do not pass second and third parameter to the script ( _this select 1 _this select 2) you will get error. if your script has no errors means these 2 variables are always defined. isNil _driverType will check if the value of _driverType is undefined variable for example, and since you pass on a class or "" it will always be true unless there is a variable with the same name as class and is defined. Since they are strings you want to check them if they are empty or not instead if (_driverType == "")... or if (_driverType != "") if (_minRank == "") ...or if (_minRank != "") isNil will only be true is the variable you test is nil myvar = nil; if (isNil "myvar") //true ah right, cheers mate. yeh i thought isnil would return return a boolean value of true in no driver was selected thanks for the help, ill edit this post once i have tested it ---------- Post added at 03:21 PM ---------- Previous post was at 01:51 PM ---------- **BUMP**, reason new script download available. **I didnt want to start a new thread** Share this post Link to post Share on other sites