Jump to content
Sign in to follow this  
dragonsyr

only pilots with specific names can fly

Recommended Posts

private ["_AirVehicle","_position","_enterer"];
_Reserved=["DragonSyr"];
_AirVehicle = _this select 0;
_enterer = _this select 2;
__notlocalexit(_enterer);

PARAMS_2(_AirVehicle,_position);

if (_position == "driver") then {
if (_enterer == player) then {
	if (_PlayerName in _Reserved) then {
		hintSilent format ["Pilot %1 Good Luck!", _PlayerName]; else {hintSilent "Only for Pilot Member.";
		_Player action["eject", _AirVehicle];
	};
};
};

i need to make a script that checks playernames for the driver only. With this script i get error in line 3

someone can help me? is something like that allready working?

Share this post


Link to post
Share on other sites

Would anybody mind explaining what __notlocalexit and PARAMS_2 means here? It doesn't make much sense to me personally. _position etc doesn't seem to be defined.

Share this post


Link to post
Share on other sites

PARAMS is a CBA macro

https://dev-heaven.net/docs/cba/files/extended_eventhandlers/script_macros_common-hpp.html#PARAMS_n

The other one is a type of macro as well, though I'm not sure from where. Maybe domination.

To op, I'm pretty sure you copied that from somewhere, please post the whole code as you have it in your mission, or just search the forum for one of the working examples, this has been answered a lot here.

Share this post


Link to post
Share on other sites

i edit the x_checkhelipilotout.sqf from my domi mission

// by Xeno
#define THIS_FILE "x_checkhelipilotout.sqf"
#include "x_setup.sqf"
private ["_vehicle","_position","_enterer"];

_enterer = _this select 2;
__notlocalexit(_enterer);

PARAMS_2(_vehicle,_position);

if (_position == "driver") then {
if (_enterer == player) then {
	if (__pGetVar(GVAR(hud_id)) != -1000) then {
		_vehicle removeAction __pGetVar(GVAR(hud_id));
		__pSetVar [QGVAR(hud_id), -1000];
	};
};
};

with this script only pilots can fly when you select the only pilots in mission parameters.

I dont want nothing from params , just a script that only check the driver name and if is true then fly or false then eject from pilot.

Edited by dragonsyr

Share this post


Link to post
Share on other sites

IIRC The problem with getIn eventHandlers is that they are never triggered if you first jump into ride in back and then switch to pilot.

Share this post


Link to post
Share on other sites

i have also this veh.fsm that run from vehicle int with this code

this addeventhandler[""getin"", {[(_this select 0),(_this select 2)] execFSM ""veh.fsm""}];_veh = [""this addeventhandler['getin', {[(_this select 0),(_this select 2)] execFSM 'veh.fsm'}]""]; veh = [this, 1, 1200, 0, FALSE, FALSE] execVM ""scripts\vehicle.sqf""

is working , but this script lock all positions (pilot,gunner etc) so noone can board the heli except me. i need only driver lock and all others can board in

veh.fsm

/*%FSM<COMPILE "C:\Program Files (x86)\Bohemia Interactive\Tools\FSM Editor Personal Edition\scriptedFSM.cfg, HeliKick">*/
/*%FSM<HEAD>*/
/*
item0[] = {"Start",0,4346,-40.348839,-141.279068,49.651161,-91.279068,0.000000,"Start"};
item1[] = {"_",8,218,-40.697674,-216.279068,49.302326,-166.279068,0.000000,""};
item2[] = {"Ende",1,250,-39.534885,-293.604706,50.465145,-243.604675,0.000000,"Ende"};
link0[] = {0,1};
link1[] = {1,2};
globals[] = {8.000000,1,0,0,0,640,480,1,4,6316128,1,-218.017914,290.381317,34.001205,-536.556274,548,615,1};
window[] = {0,-1,-1,-1,-1,785,25,1317,25,1,566};
*//*%FSM</HEAD>*/
class FSM
{
 fsmName = "HeliKick";
 class States
 {
   /*%FSM<STATE "Start">*/
   class Start
   {
     name = "Start";
     init = /*%FSM<STATEINIT""">*/"if (!isDedicated) then" \n
      "{" \n
      "	_AirVehicle = _this select 0;" \n
      "	_Player = _this select 1;" \n
      "	_PlayerName = name _Player;" \n
      "" \n
      "	_Reserved=[""DragonSyr""];" \n
      "" \n
      "	if (_PlayerName in _Reserved) then " \n
      "	{" \n
      "		hintSilent format [""Pilot %1 Good Luck!"", _PlayerName];" \n
      "	}" \n
      "	else" \n
      "	{" \n
      "		hintSilent ""Only for Pilots \n"";" \n
      "		_Player action[""eject"", _AirVehicle];" \n
      "	}" \n
      "}"/*%FSM</STATEINIT""">*/;
     precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
     class Links
     {
       /*%FSM<LINK "_">*/
       class _
       {
         priority = 0.000000;
         to="Ende";
         precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
         condition=/*%FSM<CONDITION""">*/""/*%FSM</CONDITION""">*/;
         action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
       };
       /*%FSM</LINK>*/
     };
   };
   /*%FSM</STATE>*/
   /*%FSM<STATE "Ende">*/
   class Ende
   {
     name = "Ende";
     init = /*%FSM<STATEINIT""">*/""/*%FSM</STATEINIT""">*/;
     precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
     class Links
     {
     };
   };
   /*%FSM</STATE>*/
 };
 initState="Start";
 finalStates[] =
 {
   "Ende",
 };
};
/*%FSM</COMPILE>*/

i think that this code is the right one but how can define this code inside ?


if (_position == "driver") then {
if (_enterer == player) then {
	if (_PlayerName in _Reserved) then {
		hintSilent format ["Pilot %1 Good Luck!", _PlayerName]; else {hintSilent "Only for Pilot Member.";
		_Player action["eject", _AirVehicle];

Edited by dragonsyr

Share this post


Link to post
Share on other sites

Can't help with the other scripts, This works in SP not tested in MP.

_vehlist is a list of locked vehicles

_reserved is the list of allowed drivers.

// place the next line in an init.sqf
// null=[] execvm "Lock_Driver.sqf"
//
_vehlist = ["HMMWV_M998_crows_M2_DES_EP1","HMMWV_Ambulance","CH_47F_EP1","CH_47F_BAF","UH60M_MEV_EP1","BAF_Merlin_HC3_D","M1A2_US_TUSK_MG_EP1"];

_Reserved=["DragonSyr","sel"];

_PlayerName = name Player;

while {alive player} do {

waituntil {vehicle Player  != Player};
  _vehicle = vehicle player;
    _current = assignedVehicleRole player select 0;
        if (!( _PlayerName in _Reserved) and _current == "driver") then {
         if (typeof _vehicle in _vehlist) then {
        //   moveout player;
            player moveinCargo _vehicle;  // you can change these lines to eject
             Hint "You don't have permission to drive this vehicle";
   };

   };

sleep 0.1;
 waituntil {(assignedVehicleRole player) select 0 != _current or vehicle Player  != Player};


};

It doesn't kick you from the vehicle if there are cargo slots.

You can't get into driver seat from inside the vehicle either.

Share this post


Link to post
Share on other sites

Thank you Sel.... in a few hours i test this and i post the results :-)

Share this post


Link to post
Share on other sites

Sel, i love you man! thank you! i edit the code for my needs and working perfect. here it is

// place the next line in an init.sqf
// null=[] execvm "Lock_Driver.sqf"
//
_vehlist = ["HMMWV_M998_crows_M2_DES_EP1","HMMWV_Ambulance","CH_47F_EP1","CH_47F_BAF","UH60M_MEV_EP1","BAF_Merlin_HC3_D","M1A2_US_TUSK_MG_EP1","UH60M_EP1"];

_Reserved=["DragonSyr"];

_PlayerName = name Player;

while {alive player} do {

waituntil {vehicle Player  != Player};
  _vehicle = vehicle player;
    _current = assignedVehicleRole player select 0;
        if (!( _PlayerName in _Reserved) and _current == "driver") then {
            if (typeof _vehicle in _vehlist) then {
           //   moveout player;
               player action ["eject", _vehicle];  // you can change these lines to any action
                hintSilent format ["%1 ...You need a Permission to Fly this Heli", _PlayerName]; 

   };



      };



   sleep 0.1;
    waituntil {(assignedVehicleRole player) select 0 != _current or vehicle Player  != Player};
 if (( _PlayerName in _Reserved) and _current == "driver") then {
		hintSilent format ["Welcome Aboard Commander %1 .Good Luck!", _PlayerName];} else {
		if (!( _PlayerName in _Reserved)) then {
		hintSilent format ["Welcome Aboard %1 .Good Luck!", _PlayerName];
		};
		};
		};

one more thing. i want to put addactions on the vehicle . i think that the place is after the commander welcome hint , as

fr= _vehicle addaction ['<t color="#133674">' + "Fastroping", "scripts\fastrope.sqf",["1"],1,false];

if this is true , i need also on exit from the pilot seat to remove the addaction above. can i? like this

on exit _vehicle removeaction fr;

Share this post


Link to post
Share on other sites

Yes after commander , you had a syntax error in the colour, I just took it out for testing and there was some missing code in the addaction that is needed to limit it to driver only.

I thought you could also try locking the driver seat, that may stop other players from even getting the action to move into your seat while flying as they may be able to force you out other wise even though they can't fly. IT may or may not work. I don't know if the not alive driver bit will work or !(alive player).

hintSilent format ["Welcome Aboard Commander %1 .Good Luck!", _PlayerName];

FR =_vehicle addaction ["Fastroping", "scripts\fastrope.sqf",["1"],1,false,true,"","( driver _target == _this)"];

_vehicle lockdriver true;

waituntil {(assignedVehicleRole player) select 0 != _current or !(alive player)};//

_vehicle removeAction FR;

_vehicle lockdriver false;

} else {

Share this post


Link to post
Share on other sites

thanks again for your big help sel....

the script working like a charm in MP , iv not tested the last part for the addaction (in a few hours i can tell you that)

but on dedicated server i notice that the script running from the beggining of the mission without the need to be in the vehicle. And if i m in the vehicle, the script working but i see the hint for ever (its seems like endless loop . You must get out of the vehicle for hint dessapear)

i try to change the code like this

sleep 0.1;
    waituntil {(assignedVehicleRole player) select 0 != _current or vehicle Player  != Player};
 if (( _PlayerName in _Reserved) and _current == "driver") exitWith {
		hintSilent format ["Welcome Aboard Commander %1 .Good Luck!", _PlayerName];};
		if (!( _PlayerName in _Reserved)) exitWith {
		hintSilent format ["Welcome Aboard %1 .Good Luck!", _PlayerName];
					};
		};

with this setup the script working the first time you enter the vehicle and after that nothing happened (stop working)

how can i reset the script after the exit of the vehicle?

edit: i run this

null=[] execvm "Lock_Driver.sqf"

on heli init line (mission editor) Edited by dragonsyr

Share this post


Link to post
Share on other sites

Use an eventhandler

heloname addEventhandler ["GetIn","[] execVM ""lock_driver.sqf"""];

If you're not removing it at any point it will always trigger when somebody enters the vehicle.

Share this post


Link to post
Share on other sites

The continuing hint I noticed and in the modified script I fixed that with a wait until.

As for MP I' don't know try tryteyker's answer or, you'll have to try the isserver /isdedicated commands.

Share this post


Link to post
Share on other sites

ok .... working perfect with the solution of tryteyker.

the conclusion is ....

for sp or mp you can use this script with this in init of the vehicle

null=[] execvm "Lock_Driver.sqf"

// Lock_Driver.sqf
// place the next line in vehicle init.sqf
// null=[] execvm "Lock_Driver.sqf"  for sp and mp and replace the last 2 exitWith , with command then
//or for dedicated run => vehiclename addEventhandler ["GetIn","[] execVM ""lock_driver.sqf"""];
//
_vehlist = ["HMMWV_M998_crows_M2_DES_EP1","HMMWV_Ambulance","CH_47F_EP1","CH_47F_BAF","UH60M_MEV_EP1","BAF_Merlin_HC3_D","M1A2_US_TUSK_MG_EP1","UH60M_EP1"];

_Reserved=["DragonSyr"];

_PlayerName = name Player;

while {alive player} do {

waituntil {vehicle Player  != Player};
  _vehicle = vehicle player;
    _current = assignedVehicleRole player select 0;
        if (!( _PlayerName in _Reserved) and _current == "driver") then {
            if (typeof _vehicle in _vehlist) then {
           //   moveout player;
               player action ["eject", _vehicle];  // you can change these lines to any action
                hintSilent format ["%1 ...You need a Permission to Fly this Heli", _PlayerName]; 

   };




      };



   sleep 0.1;
    //waituntil {(assignedVehicleRole player) select 0 != _current or vehicle Player  != Player};
 if (( _PlayerName in _Reserved) and _current == "driver") then {
		hintSilent format ["Welcome Aboard Commander %1 .Good Luck!", _PlayerName];
		sleep 0.1;};
		if (!( _PlayerName in _Reserved)) then {
		hintSilent format ["Welcome Aboard %1 .Good Luck!", _PlayerName];
		sleep 0.1;
		};

		};

and for dedicated this script with this in init of the vehicle

vehiclename addEventhandler ["GetIn","[] execVM ""lock_driver.sqf"""];

// Lock_Driver.sqf
// place the next line in vehicle init.sqf
// null=[] execvm "Lock_Driver.sqf"  for sp and mp and replace the last 2 exitWith , with command then
//or for dedicated run => vehiclename addEventhandler ["GetIn","[] execVM ""lock_driver.sqf"""];
//
_vehlist = ["HMMWV_M998_crows_M2_DES_EP1","HMMWV_Ambulance","CH_47F_EP1","CH_47F_BAF","UH60M_MEV_EP1","BAF_Merlin_HC3_D","M1A2_US_TUSK_MG_EP1","UH60M_EP1"];

_Reserved=["DragonSyr"];

_PlayerName = name Player;

while {alive player} do {

waituntil {vehicle Player  != Player};
  _vehicle = vehicle player;
    _current = assignedVehicleRole player select 0;
        if (!( _PlayerName in _Reserved) and _current == "driver") then {
            if (typeof _vehicle in _vehlist) then {
           //   moveout player;
               player action ["eject", _vehicle];  // you can change these lines to any action
                hintSilent format ["%1 ...You need a Permission to Fly this Heli", _PlayerName]; 

   };




      };



   sleep 0.1;
    //waituntil {(assignedVehicleRole player) select 0 != _current or vehicle Player  != Player};
 if (( _PlayerName in _Reserved) and _current == "driver") exitWith {
		hintSilent format ["Welcome Aboard Commander %1 .Good Luck!", _PlayerName];
		sleep 0.1;};
		if (!( _PlayerName in _Reserved)) exitWith {
		hintSilent format ["Welcome Aboard %1 .Good Luck!", _PlayerName];
		sleep 0.1;
		};

		};

thank you both guys.

I spent up to 10 hours only for testings , because my mission is a domination edited for my island , and the proccess for editing , makepbo , run a server , connect with game , starting ,disconnecting , closing game , closing server , edit again then the same again and again is despair. i m wonder if there is a program like debugger or something to check the code for errors before the test in game.

Thank you again!!!

Edited by dragonsyr

Share this post


Link to post
Share on other sites

If you learn about locality you won't have to pbo everytime, a simple preview is enough.

Squint is a text editor for SQF, you could try it.

Share this post


Link to post
Share on other sites

cuel thank you for squint . i ll try it. btw , im noob to this. My knowledge is very limited. i m learning from other scripts and make experiments .... I hope to avoid blowing up something :-)))))))))))

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  

×