cougarxr7 1 Posted July 3, 2014 Hello, I need help trying to write a script that will allow you to see when a specified position is taken. I am learning. Example: if Player == driver then {hint "Pilot is on board"; }; if player == gunner then {hint "Gunner is on port Minigun"; }; I know my syntax is incorrect, again I am still learning. Also at one time I remember there was a tool that showed you what the positions were called on the vehicles, yet I cannot find it! Thanks for the help! Share this post Link to post Share on other sites
IT07 10 Posted July 3, 2014 So you want to show a hint when a position is taken? Then what are you going to use to give that hint? The option to get in as driver is disabled anyway if there is someone in the driver seat. (unless it's an AI) Share this post Link to post Share on other sites
cougarxr7 1 Posted July 3, 2014 Thanks for replying! It is not so much to show a hint as it is to run some scripting code. The hint is just a way to confirm that position is being taken and that the script code should run. You said, The option to get in as driver is disabled Not sure what you mean that option has been disabled. Being disabled or not, that would not be the first thing that does not work in arma! To me, it is common for things to not work in arma! I had found this, and yes I know it is for arma 2, thought it might work for 3. Door Gunner Crew Chief this moveInTurret [ch ,[1]] this moveInTurret [ch ,[0]] Pilot Co-Pilot/Cargo this moveInDriver ch this moveInCargo [ch, 0] I would like to be able to run a different scripts for all 4 of those positions when they are taken. I just need to get the syntax correct. This was for arma 2, hoping there was some syntax for 3! if((vehicle player) == driver vehicle _unit) then {}; if((vehicle player) == gunner vehicle _unit) then {}; if((vehicle player) == commander vehicle _unit) then {}; Thanks for the help. Share this post Link to post Share on other sites
IT07 10 Posted July 4, 2014 So let me get this straight: You want a script that tells you what positions are taken of a certain vehicle? If so, what purpose do you have for that? Remote check or a check if you are standing next to a vehicle and execute the check? Share this post Link to post Share on other sites
cougarxr7 1 Posted July 4, 2014 IT07, thanks for replying! Not so much as what positions are taken but when they are taken. You jump in a helo as a pilot, if ( (Vehicle Player) == Vehicle Driver) then {a script will run only for you, the pilot and not some ground pounder 5 km away from your position.}; Same goes for all other positions, Copilot, Crew Chief, Door Gunner, Cargo positions too. I am not sure why this seems to be such a confusing question. Thanks for helping! Hope I cleared up what had you confused! Share this post Link to post Share on other sites
IT07 10 Posted July 5, 2014 this should work: if (driver _nameOfVehicle == Player) then { hint"you are the driver"; }; Share this post Link to post Share on other sites
Lala14 135 Posted July 5, 2014 if you want you could also do something like if ((driver _VehName) isKindOf "B_crew_F") then { hint "you are are crew man, you are qualified to drive" }; Share this post Link to post Share on other sites
cougarxr7 1 Posted July 5, 2014 Thanks guys, I will give those a try! Will post results! Again thanks! Share this post Link to post Share on other sites
cougarxr7 1 Posted July 6, 2014 IT07 I tested what you recommended and here are the results. publicVariable "_nameofvehicle"; publicVariable "b_heli_transport_01_f"; _nameOfVehicle = b_heli_transport_01_f; if (driver _nameOfVehicle == Player) then { hint"You are the Pilot"; }; From RPT file. Error in expression <heli_transport_01_f"; _nameOfVehicle = b_heli_transport_01_f; if (driver _name> Error position: <b_heli_transport_01_f; if (driver _name> Error Undefined variable in expression: b_heli_transport_01_f No matter what I tried I could not get it to work. Always keep getting that undefine variable error. I am sure it is on my end, just not sure what I am doing wrong. Lala14 Here are you results. publicVariable "_VehName"; publicVariable "b_heli_transport_01_f"; publicVariable "B_crew_F"; if ((driver _VehName) isKindOf "B_crew_F") then { hint "you are are crew man, you are qualified to drive" }; From RPT, if ((driver _VehName) isKindOf "B_crew_F") then { hi> Error position: <_VehName) isKindOf "B_crew_F") then { hi> Error Undefined variable in expression: _vehname As far as both of those, that undefined variable error is constant. I do not know what to do, but I will keep on trying until I figure out! Thanks for your help! Share this post Link to post Share on other sites
Lala14 135 Posted July 6, 2014 you put the classname of the vehicle, thats not the name. ---------- Post added at 15:13 ---------- Previous post was at 14:56 ---------- actually what I think you should do is put this in a script call it something and then put this in it This would be for helicopters, also notice how it is B_Helipilot_F, this is the blufor heli pilot. while {true} do { waitUntil {sleep 0.5; alive player}; if (typeOf player != "B_Helipilot_F") then { private "_veh"; waitUntil {sleep 0.5; vehicle player != player}; _veh = vehicle player; if (_veh isKindOf "Helicopter" && !(_veh isKindOf "ParachuteBase")) then { if (driver _veh == player) then { player action ["Eject", _veh]; waitUntil {sleep 0.5; vehicle player == player}; player action ["EngineOff", _veh]; hint "You must be a pilot to fly!"; }; }; } else { waitUntil {sleep 0.5; !alive player}; }; }; Share this post Link to post Share on other sites
cougarxr7 1 Posted July 6, 2014 Lala14, I used a script like that to eject players from helos who were not pilots. So I know that is doable, however I am working on below; hint "CREW SQF IS UP AND RUNNING!"; SLEEP 4; // _helo1 = UH-80 Ghost Hawk ; for [{_loop=0}, {_loop<1}, {_loop=_loop}] do { if(player == vehicle player) then { hint "You are not in the Helo"; }else{ hint "You are in a Helo!"; }; _dr = _helo1 emptyPositions "driver"; _gu = _helo1 emptyPositions "gunner"; _co = _helo1 emptyPositions "copilot"; _ch = _helo1 emptyPositions "crewchief"; if (_dr > 0)|| (_gu > 0) || (_co > 0) || (_ca > 0)) then { hint "Someone is on Board Helo1!"; }; sleep 1; hint format["%1 %2 %3 %4 %5 %6 %7 %8","Pilot =",_dr,"CoPilot =",_co," Crew Chief =",_ch,"DoorGunner =",_gu]; sleep 4; }; This works, when I am not in the helo, it hints me I am not in. When I am in the helo, it hints me I am in. I am getting scallar on the hint of dr, co, ch, gu, and I am also getting undefined variables on them too. now when I unblock the // _helo1 = UH-80 Ghost Hawk ; it kills the script for some reason. I get the hint "CREW SQF IS UP AND RUNNING!";, but that is all, the rest is dead. Thanks for the info about the name UH-80 Ghost Hawk, I was hoping that would solve my problems. I am back to testing! Thanks for your help! Share this post Link to post Share on other sites
Lala14 135 Posted July 6, 2014 that is still not the name! when you place the vehicle in the editor there will be a field called NAME Share this post Link to post Share on other sites
cougarxr7 1 Posted July 6, 2014 Lala14 , it was never stated earlier the name was from the editor. community.bistudio.com/wiki/Arma_3_CfgVehicles_WEST Shows that to be the name as that helicopter. Now I know name means from the editor, that might help me get this to work. Now I understand there is a, "classname", B_Heli_Transport_01_F "gamename", UH-80 Ghost Hawk "fieldname", helo1 <(or whatever I want to call it!) I bet if we look hard enough we might find a fourth description we can call that helicopter. Thanks for your help! Share this post Link to post Share on other sites
Lala14 135 Posted July 6, 2014 FIELDNAME is the name Share this post Link to post Share on other sites
IT07 10 Posted July 6, 2014 If using the Editor, you can put something in the NAME field or give a vehicle a name via sqf: https://community.bistudio.com/wiki/setName Share this post Link to post Share on other sites
Larrow 2821 Posted July 6, 2014 May be i will confuse things a little :/ but is this the sort of info your looking for?? Load up the editor and place down the player and then any number of empty vehicles so that you can get in them and test out their positions. Preview the mission and run the below code from the debug console. terminate h; h = [] spawn { while {true} do { _positionName = ""; waitUntil {player != vehicle player }; _position = assignedVehicleRole player; switch (_position select 0) do { case "Turret" : { _numTurrets = count (_position select 1); _turretCFG = (configfile >> "cfgvehicles" >> typeof (vehicle player) >> "turrets"); for "_i" from 0 to (_numTurrets - 1) do { if (_i > 0 ) then { _turretCFG = _turretCFG >> "turrets"; }; _turret = (_position select 1) select _i; _turretCFG = _turretCFG select _turret; }; _positionName = "the\n" + (gettext(_turretCFG >> "gunnerName")); }; case "Cargo" : { _positionName = "a\n Passenger" }; default { _positionName = "the\n" + (_position select 0); }; }; _vehDesc = getText( configFile >> "cfgVehicles" >> typeOf (vehicle player) >> "displayName"); hintSilent format ["You have got in a\n %1 \nas %2", _vehDesc, _positionName]; waitUntil { (player == vehicle player) || !( (assignedVehicleRole player) isEqualTo _position) }; hintSilent ""; }; }; Commented code (as comments will throw errors if in code run from the console). terminate h; h = [] spawn { //loop for ever while {true} do { //clear the position name _positionName = ""; //wait for the player to get into a vehicle waitUntil {player != vehicle player }; //get the vehicle position the player is in _position = assignedVehicleRole player; //what type of position are we in switch (_position select 0) do { //if in a turret case "Turret" : { //number of positions within this turret _numTurrets = count (_position select 1); //default config for this vehicles turret info _turretCFG = (configfile >> "cfgvehicles" >> typeof (vehicle player) >> "turrets"); //loop through turret info for "_i" from 0 to (_numTurrets - 1) do { //are we in a secondary turret if (_i > 0 ) then { //get config for secondary turret _turretCFG = _turretCFG >> "turrets"; }; //get turret position _turret = (_position select 1) select _i; //get turret config _turretCFG = _turretCFG select _turret; }; //get the name of the turret position _positionName = "the\n" + (gettext(_turretCFG >> "gunnerName")); }; //if in cargo case "Cargo" : { //meh just make the hint grammatically correct :) i am a man not a box _positionName = "a\n Passenger" }; //if anything other than turret or cargo default { //get the name of the position as passed back from assigned vehicle role _positionName = "the\n" + (_position select 0); }; }; //get the description of the vehicle we are in _vehDesc = getText( configFile >> "cfgVehicles" >> typeOf (vehicle player) >> "displayName"); //hint the vehicle descripton and position we currently occupy hintSilent format ["You have got in a\n %1 \nas %2", _vehDesc, _positionName]; //waituntil we leave the vehicle or change position waitUntil { (player == vehicle player) || !( (assignedVehicleRole player) isEqualTo _position) }; //clear the hint hintSilent ""; }; }; Share this post Link to post Share on other sites
cougarxr7 1 Posted July 7, 2014 IT07 , Larrow wow thanks! I will give it a test run! Post results asap! Share this post Link to post Share on other sites
cougarxr7 1 Posted July 7, 2014 IT07, I followed your link and it says; "Sets the name of a location or a person. In Arma 3 this can be used to set name of a person but only in single player." That fieldname has been the source of scripting problems. But I now know when someone ask or brings up name, it is what we named it, not much as in game name. Thanks for helping me get that correct! Also, fnc_MySystem = { Private [ ]}; < I remember when that was introduced in arma 2, but being old and full of meds it was easy to forget! Larrow, you script functioned flawless! I plan on really studying it, thanks for explaining each line! However what I was hoping for was more of the in game name return of the turret, example; the "moveInTurret" command gives the name of the turret. https://community.bistudio.com/wiki/moveInTurret You take the pilot position in the helo. The hint returns the turret. "You are in turret [0]! I have an idea I am going to try. Please feel free to post any and all scripts you want! Thanks for you help! Share this post Link to post Share on other sites
Larrow 2821 Posted July 7, 2014 If you just want the turret path (e.g [0,0]) just use the assignedVehicleRole command as this is actually what it returns in select 1. I went a step further and took this turret path and converted it to the actual display name as shown in the action when getting in a vehicle (e.g get in left door gunner, is actually turret [#] not at home at the moment to provide actual number but hopefully you get the idea ). Share this post Link to post Share on other sites
IT07 10 Posted July 7, 2014 Wait a minute..... that code about fnc_MySystem is my signature. LOL That was not code you should have used xD Share this post Link to post Share on other sites
cougarxr7 1 Posted July 7, 2014 IT07, lol, I know. I used; Private [ "_unit", "_helo1","_dr", "gu", "_co", "_ch", "_unitname"]; Larrow, It would be great if it could be like a switch. Please understand I know my scripting sucks! However I do like to trial and error things With the correct syntax I know this can work! switch (Param1) do { case 0: { if(pilot) then {_handle = [] execVM "pilot.sqf"}; }; case 1: { if(copilot) then {_handle = [] execVM "copilot.sqf"}; }; case 2: { if(leftgunner) then {_handle = [] execVM "crewchief.sqf"}; }; case 3: { if(rightgunner) then {_handle = [] execVM "doorgunner.sqf"}; }; case 4: { if(cargo) then {_handle = [] execVM "cargo.sqf"}; }; case 5: { }; }; Again thank you so very much for your help! Granddaughter is waking up gotogo! If I can be of any help to you, (Electrical, Automotive, Computers) just ask, be glad to help! Share this post Link to post Share on other sites
Larrow 2821 Posted July 7, 2014 (edited) It would be great if it could be like a switch.Well with a little bit of modification that is exactly what i gave you.Change my hint in the previous code for hintSilent format ["You have got in a \n %1 \n as %2 \n which is position type\n %3 \n and has a turret path of \n %4", _vehDesc, _positionName, _position select 0, if !(isNil {_position select 1}) then [{_position select 1}, {"no turret path"}] ]; This will give you the position type and the turret path for the position the player is occupying. Then use this instead terminate h; h = [] spawn { while {true} do { waitUntil {player != vehicle player }; _position = assignedVehicleRole player; _positionType = _position select 0; _turretPath = _position select 1; switch (_positionType) do { case "Turret" : { switch (_turretPath) do { case [0] :{ hint "Run my code here for copilot"; }; case ? :{ hint "Run my code here for door gunner left"; }; case ? :{ hint "Run my code here for door gunner right"; }; } }; case "Driver" : { hint "Run my code here for the pilot"; }; case ? : { hint "Run my code here for a passenger"; }; default { hintSilent "tis all FUBAR if we get this"; }; }; waitUntil { (player == vehicle player) || !( (assignedVehicleRole player) isEqualTo _position) }; hintSilent ""; }; }; Notice the similarities to the previous code! I have left you a little work todo Using the previous code with the new hint to work out the turret paths for left and right door gunners and the position type for the passengers then replace the ? in the case statements. I have given you the CoPilot turret path [0] and the Pilot position type "Driver" so you have some idea what you are looking for. This is all specifically for the ghost hawk as that is what has been mentioned several times in this thread. Other vehicles will have different turrets to account for so this is not a solution for every vehicle. Edited July 7, 2014 by Larrow Share this post Link to post Share on other sites
cougarxr7 1 Posted July 8, 2014 Larrow, It works! I have screen shots, but I could not figure out how I could upload them. Thank you for the home work, that was fun to figure out! Even though it worked, not sure why it had these errors in the RPTs, Sever and client. terminate h; h = [] spawn { while {true} do { wait> Error Undefined variable in expression: h and Error in expression <ition select 0; _turretPath = _position select 1; switch (_positionType) do { > 1:05:10 Error position: <select 1; switch (_positionType) do { > 1:05:10 Error Zero divisor Just curious how it still worked even with those errors? Thank you! Share this post Link to post Share on other sites
Larrow 2821 Posted July 8, 2014 Even though it worked, not sure why it had these errors in the RPTs, Sever and client.Thats due to...1. It being test code to run from the debug console, Error Undefined variable in expression: h As i may repeatedly want to change my test code and just run it from the debug console without having to restart the scenario, the terminate h; cancels my previous spawned code. On first running my code, h does not exist so it will throw the undefined error as there is no such thing as h. When you put this code into use in your mission there will be no need for the terminate line so you can delete it. 2. I was being lazy, knowing that assignedVehicleRole does not always return a turret path (e.g if you are the driver then assignedVehicleRole just returns ["Driver"] where as a position like a door gunner will return ["Turret", [1]] ) so when i say _turretPath = _position select 1; there is a possibility that there is no information at select 1. This then throws the Zero divisor error. To fix that replace _turretPath = _position select 1; with _turretPath = [_position, 1, nil, [ [] ] ] call BIS_fnc_param; Glad you got it working and thanks for the PM much appreciated. Larrow Share this post Link to post Share on other sites
cougarxr7 1 Posted July 8, 2014 You told me to run it from the db console, wow it sucks getting old! Any links that you know of that are for scripting for dummies, please post them for me. Thanks! Share this post Link to post Share on other sites