Jump to content
Sign in to follow this  
kocrachon

Only "name" can enter this vehicle

Recommended Posts

So, I was wondering if it is possible to make it so that only a person with a specific name or with a specific player ID are allowed to enter a specific vehicle, or type of vehicles.

Such as right now my squad runs a 24/7 Domination server that is locked for the Squad only. We have qualifications so that people who are qualified are the only ones who are allowed to. We also work this way in our coop missions.

So I want to make it so that if you aren't on "the list" that when you enter a vehicle it kicks you out and says "You are not qualified"

Right now we use a script that requires you to be a pilot to fly or a crewman to drive/gun, but that doesn't help too much because they can just take an empty pilot seat.

We don't have a lot of issues with people not obeying... but theres always some one who feels like being a funny guy once in a while, especially when booze are involved and no admins are on.

Share this post


Link to post
Share on other sites

Hi,

You could try something like:

_vehicle addEventHandler ["GetIn", 
{
private ["_veh", "_pos", "_unit", "_namesArray"];
_veh = _this select 0;
_pos = _this select 1;
_unit = _this select 2;
_namesArray = ["John", "_spiderMan_", "CowGirl"];

if !(name _unit in _namesArray) then
{
_unit action ["Eject", vehicle _unit];
};
}];

_neo_

Share this post


Link to post
Share on other sites

Better to use playerId as names can be botched if using special characters or even same name.

Player id you find in player profile ingame start menu.

7 numbers.

replace names in array with ids then only the player with the correct id will be able to enter without being ejected.

replace this line: if !(name _unit in _namesArray) then

with: if !((getPlayerUID _unit) in _namesArray) then

and this line: _namesArray = ["John", "_spiderMan_", "CowGirl"];

with: _namesArray = ["1234567", "1122334", "2222222"];

Share this post


Link to post
Share on other sites
Better to use playerId as names can be botched if using special characters or even same name.

Player id you find in player profile ingame start menu.

7 numbers.

replace names in array with ids then only the player with the correct id will be able to enter without being ejected.

replace this line: if !(name _unit in _namesArray) then

with: if !((getPlayerUID _unit) in _namesArray) then

and this line: _namesArray = ["John", "_spiderMan_", "CowGirl"];

with: _namesArray = ["1234567", "1122334", "2222222"];

Both ideas are great, thanks guys.

But my next question is, how do I call this script? As I said, I am using it on domination, and a lot of the aircraft are created upon doing missions.

Share this post


Link to post
Share on other sites

i meant to use what neokika posted, just use playerId instead of names, because of potential cheating, and the odd letters sometimes used in names.

well you have locked all vehicles to clan members, simply find same spot and run neokikas script on everyone of them.

fex:

save neokikas script as vehiclelock.sqf

_vehicle = _this select 0;  // i added this line.

_vehicle addEventHandler ["GetIn", 
{
private ["_veh", "_pos", "_unit", "_namesArray"];
_veh = _this select 0;
_pos = _this select 1;
_unit = _this select 2;
_namesArray = ["John", "_spiderMan_", "CowGirl"];

if !(name _unit in _namesArray) then
{
_unit action ["Eject", vehicle _unit];
};
}];  

and run this line on every vehicle that is currently unlocked for clan only.

_null = [_vehiclename] execVM "vehiclelock.sqf";

and switch out names for player id if you want as i posted above.

Share this post


Link to post
Share on other sites
i meant to use what neokika posted, just use playerId instead of names, because of potential cheating, and the odd letters sometimes used in names.

well you have locked all vehicles to clan members, simply find same spot and run neokikas script on everyone of them.

fex:

save neokikas script as vehiclelock.sqf

_vehicle = _this select 0;  // i added this line.

_vehicle addEventHandler ["GetIn", 
{
private ["_veh", "_pos", "_unit", "_namesArray"];
_veh = _this select 0;
_pos = _this select 1;
_unit = _this select 2;
_namesArray = ["John", "_spiderMan_", "CowGirl"];

if !(name _unit in _namesArray) then
{
_unit action ["Eject", vehicle _unit];
};
}];  

and run this line on every vehicle that is currently unlocked for clan only.

_null = [_vehiclename] execVM "vehiclelock.sqf";

and switch out names for player id if you want as i posted above.

So what do I do in Domination where the vehicles are created mid way through the game?

Is it possible to run a script server side that runs every minute or so, that checks for all helicopters, and applys this script to all helicopters? So that way every time I unlock one, or an AI one spawns and we shoot it down safely, it still applies the ruling to them?

Edited by HavocDemon

Share this post


Link to post
Share on other sites

you should be able to locate the spawned ones in the domi scripts somewhere, or the answer on how to is in the editing domination thread, probably along with a already complete lock system. remember there is a search button....

but yeah running a server side check will work, something like this:

a repeating 10 seconds trigger with:

cond: true

on act: paste this directly into trigger on act line, dont mind the spaces, use as is

{
if ((_x isKindOf "LandVehicle" OR _x iskindOf "Helicopter" OR _x isKindOf "Plane") AND _x getVariable ["locked", true]) then {
	_x setVariable ["locked", 123];
	_null = [_x] execVM "vehiclelock.sqf";
};
} foreach allUnits;

place this script in mission folder and save as vehiclelock.sqf:

_vehicle = _this select 0;  // i added this line.

_vehicle addEventHandler ["GetIn", 
{
private ["_veh", "_pos", "_unit", "_namesArray"];
_veh = _this select 0;
_pos = _this select 1;
_unit = _this select 2;
_namesArray = ["1234567", "1122334", "2222222"];

// added check to make sure it does not affect any AI, only players. but AI in any playable unit will be kicked as well.
if (!(getPlayerUID _unit) in _namesArray AND _unit in playableUnits) then
{
_unit action ["Eject", vehicle _unit];
};
}];

in theory it should check all units if they are landvehicle or staticweapon or heli or plane and if they have the script running then do nothing, else assign the script to it.

it will do this check every 10 seconds, i would recomend not using this as i think it will cause lag. but anywho, its something to check out.

It will only kick out playable units, wich means if AI is in playable units then those will be kicked as well, but script will run on server side only.

but again, search button, and search threads.

Note everything is untested, blind coded.

And not recomended as assigning it when a vehicle respawns or gets created is the best way, but it might work just fine, maybe tweak timer to 1 minute instead of 10 seconds etc..

Edited by Demonized

Share this post


Link to post
Share on other sites

replace names in array with ids then only the player with the correct id will be able to enter without being ejected.

...

_namesArray = ["1234567", "1122334", "2222222"];

Suppose I already have specific units (UIDs) belonging to a group "Pilot", where the group belongs to "f2f="";". Is there a way I can call them into the above array example?

To help clarify what I am trying to do, please view my code. I have a switch function system which checks for UIDs. I also give the IDs a designated group (f2f="pilot" for example). I also have another script that takes each group and by using another switch function, can apply specific code for that group. So everything is already defined... I need help figuring out how to apply a group of UIDs into the vehicle lock array.

Click the spoiler to view my code:

init.sqf

null=[] execVM "\f2f\f2f.sqf";

f2f.sqf

WaitUntil{not isNull player};
waitUntil {(getPlayerUID player) != ""};

_uid 	= getPlayerUID player;
_title  = "";
_text   = "";
f2f	="";

#include "f2fmembers.sqf";
#include "f2fgroups.sqf";


sleep 1;
hint parseText (_title + _text);

f2fmembers.sqf

switch(_uid)do 
{ 
case "111111": // Member 1
{
f2f = "Pilot"; 
_title  = "<t color='#ff0000' size='1.2' shadow='1' shadowColor='#000000' align='center'>Welcome Back</t><br />";
_text = format["<t color='#ffffff' size='1.2' shadow='1' shadowColor='#000000' align='left'>%1</t><t  align='right'> [%2]</t><br />", name player, f2f];
};

case "222222": // Member 2
{
f2f = "Tanker";
_title  = "<t color='#ff0000' size='1.2' shadow='1' shadowColor='#000000' align='center'>Welcome Back</t><br />";
_text = format["<t color='#ffffff' size='1.2' shadow='1' shadowColor='#000000' align='left'>%1</t><t  align='right'> [%2]</t><br />", name player, f2f];
};

default
   	{
_title = "<t color='#ff0000' size='1.2' shadow='1' shadowColor='#000000' align='center'>Welcome to TheFirst2Fight!</t><br />";
_text = format["%1, please take a second to read the rules, you cant fly aircraft unless you are an F2F pilot or on TeamSpeak", name player];
};
};

f2fgroups.sqf

switch(f2f)do 
{ 
case "Pilot":
{
                // additional group code goes here
};

case "Tanker":
{
                // additional group code goes here
};

default
   	{
                // additional group code goes here
};
};

Edited by VirusLIVED

Share this post


Link to post
Share on other sites

If you have a pilot who defaults to AI if no human player selects him, and he is the players group. It seems you cannot order him to get into a chopper, as he gets kicked too, even though his name is listed in the script.

So how can you modify the script to accept Ai pilot as well?

Cheers

Share this post


Link to post
Share on other sites

If you're playing with AI in a player group why are you limiting things by name? Only time you would want to limit access to specific players/units is if you're playing a bloaty public server mission with idiots who steal choppers since they are impatient. In a one off mission I can't think of why you'd want to do that, especially if it's a friendly AI units present mission.

Share this post


Link to post
Share on other sites
If you have a pilot who defaults to AI if no human player selects him, and he is the players group. It seems you cannot order him to get into a chopper, as he gets kicked too, even though his name is listed in the script.

So how can you modify the script to accept Ai pilot as well?

Cheers

Just make sure that the unit is a player, like:

//Old
if !(name _unit in _namesArray) then
{
_unit action ["Eject", vehicle _unit];
};

//New
if (!(name _unit in _namesArray) && isPlayer _unit) then
{
_unit action ["Eject", vehicle _unit];
};

Also you might want to check what Demonized wrote above, it would be much better that instead of using the player name to use the UID.

Share this post


Link to post
Share on other sites

I think the solution is to put a if (!player) exitWith {};

in the script, i put it inside the event handler as this what triggers the script right?

This will allow the Ai pilot to get into the chopper. (but i guess you could order any Ai soldier to do that too then) what about using Type of..command or is that more for vehicles themselves?

The reason to allow Ai pilots is if there is not enough players on the team (TvT Mission), the team leader can still order the Ai pilot to fly about and land (via dismount command).

This is what it looks like below, but i get a Error !type object expected boolean. So how do i rewrite it so the script will terminate if pilot is not player?

_vehicle = _this select 0;

_vehicle addEventHandler ["GetIn",

{

if (!player) exitWith {};

private ["_veh", "_pos", "_unit", "_namesArray"];

_veh = _this select 0;

_pos = _this select 1;

_unit = _this select 2;

_namesArray = ["Joe", "Joe2"];

if !(name _unit in _namesArray) then

{

titleText ["You are not the pilot.", "plain"]; titleFadeOut 8;

_unit action ["Eject", vehicle _unit];

};

}]; titleFadeOut 13;

Share this post


Link to post
Share on other sites

_vehicle addEventHandler ["GetIn",
{

   private ["_veh", "_pos", "_unit", "_namesArray"];
   _veh = _this select 0;
   _pos = _this select 1;
   _unit = _this select 2;
   _namesArray = ["Joe", "Joe2"];

   if (player != _unit) exitWith {};

Try that?

Share this post


Link to post
Share on other sites
_vehicle addEventHandler ["GetIn",
{

   private ["_veh", "_pos", "_unit", "_namesArray"];
   _veh = _this select 0;
   _pos = _this select 1;
   _unit = _this select 2;
   _namesArray = ["Joe", "Joe2"];

   if (player != _unit) exitWith {};

Try that?

Yes i did thanks. The script no longer gives me an error, but anyone still can hop in as the pilot now.

Share this post


Link to post
Share on other sites
you should be able to locate the spawned ones in the domi scripts somewhere, or the answer on how to is in the editing domination thread, probably along with a already complete lock system. remember there is a search button....

but yeah running a server side check will work, something like this:

a repeating 10 seconds trigger with:

cond: true

on act: paste this directly into trigger on act line, dont mind the spaces, use as is

{
if ((_x isKindOf "LandVehicle" OR _x iskindOf "Helicopter" OR _x isKindOf "Plane") AND _x getVariable ["locked", true]) then {
	_x setVariable ["locked", 123];
	_null = [_x] execVM "vehiclelock.sqf";
};
} foreach allUnits;

place this script in mission folder and save as vehiclelock.sqf:

_vehicle = _this select 0;  // i added this line.

_vehicle addEventHandler ["GetIn", 
{
private ["_veh", "_pos", "_unit", "_namesArray"];
_veh = _this select 0;
_pos = _this select 1;
_unit = _this select 2;
_namesArray = ["1234567", "1122334", "2222222"];

// added check to make sure it does not affect any AI, only players. but AI in any playable unit will be kicked as well.
if (!(getPlayerUID _unit) in _namesArray AND _unit in playableUnits) then
{
_unit action ["Eject", vehicle _unit];
};
}];

in theory it should check all units if they are landvehicle or staticweapon or heli or plane and if they have the script running then do nothing, else assign the script to it.

it will do this check every 10 seconds, i would recomend not using this as i think it will cause lag. but anywho, its something to check out.

It will only kick out playable units, wich means if AI is in playable units then those will be kicked as well, but script will run on server side only.

but again, search button, and search threads.

Note everything is untested, blind coded.

And not recomended as assigning it when a vehicle respawns or gets created is the best way, but it might work just fine, maybe tweak timer to 1 minute instead of 10 seconds etc..

ok, how i can use this script not especially for the specified vehicles placed per mission file. I mean how i can lock a few vehicles which have been placed over databank? Can someone help me with an LAV25?

Share this post


Link to post
Share on other sites

how can we change this to only pilot seat so all players can get in passanger and gunner seats but not pilots seat

Share this post


Link to post
Share on other sites
Yes i did thanks. The script no longer gives me an error, but anyone still can hop in as the pilot now.

That's because the script doesn't have an eject command/function...

---------- Post added at 20:08 ---------- Previous post was at 20:03 ----------

how can we change this to only pilot seat so all players can get in passanger and gunner seats but not pilots seat

this addEventHandler ["GetIn", { if ((_this select 1 == "driver") && (getPlayerUID (_this select 2) != "TYPEYOURPLAYERIDHERE")) then { (_this select 2) action ["EJECT", _this select 0] }; }]

Try that... not exactly what you are looking for though

---------- Post added at 20:14 ---------- Previous post was at 20:08 ----------

try this hog

if (typeof player != "USMC_Soldier_Pilot") then {
   private "_v";
   while {alive player} do {
     waituntil {vehicle player != player};
     _v = vehicle player;
     if (_v iskindof "Helicopter" && !(_v iskindof "ParachuteBase")) then {
       if (driver _v == player) then {
         player action ["eject",_v];
         waituntil {vehicle player == player};
         hint "We shall leave the piloting to those with the appropriate training.";
       };
     };
   };
 };

Share this post


Link to post
Share on other sites

this doesnt work at all


// called by _null = [] execVM "HOG_scripts\vehiclelock.sqf";  
_vehicle = _this select 0;  // i added this line.

_vehicle addEventHandler ["GetIn", 
{
//private ["_veh", "_pos", "_unit"];
_veh = _this select 0;
_unit = _this select 1;

if (!(name _unit in pilots) && isPlayer _unit) then 
{ 
_unit action ["Eject", vehicle _unit];
hint "Only Pilots are qualified to fly";
};
}];

Share this post


Link to post
Share on other sites
this doesnt work at all


// called by _null = [] execVM "HOG_scripts\vehiclelock.sqf";  
_vehicle = _this select 0;  // i added this line.

_vehicle addEventHandler ["GetIn", 
{
//private ["_veh", "_pos", "_unit"];
_veh = _this select 0;
_unit = _this select 1;

if (!(name _unit in [b][i]pilots[/i][/b]) && isPlayer _unit) then 
{ 
_unit action ["Eject", vehicle _unit];
hint "Only Pilots are qualified to fly";
};
}];

What is "Pilots"? Is that supposed to be an array of classnames? I don't see any array of pilots / classes. Or is the array defined somewhere else? :cool:

Share this post


Link to post
Share on other sites

thanks ice

i changed it to this


[color="#FF0000"]pilots = [s13,s14];// names of the units on the map
if (name player in pilots) then {[/color]
   private "_v";
   while {alive player} do {
     waituntil {vehicle player != player};
     _v = vehicle player;
     if (_v iskindof "Helicopter" && !(_v iskindof "ParachuteBase")) then {
       if (driver _v == player) then {
         player action ["eject",_v];
         waituntil {vehicle player == player};
         hint "We shall leave the piloting to those with the appropriate training.";
       };
     };
   };
 };

but doesnt work :(

---------- Post added at 16:32 ---------- Previous post was at 16:32 ----------

yeah sorry my fault pilots is an array of unit names in the editor its found in my common.sqf

Share this post


Link to post
Share on other sites

[color="#FF0000"]pilots = [s13,s14];// names of the units on the map
if (name player in pilots) then {[/color]
   private "_v";
   while {alive player} do {
     waituntil {vehicle player != player};
     _v = vehicle player;
     if (_v iskindof "Helicopter" && !(_v iskindof "ParachuteBase")) then {
       if (driver _v == player) then {
         player action ["eject",_v];
         waituntil {vehicle player == player};
         hint "We shall leave the piloting to those with the appropriate training.";
       };
     };
   };
 };

You are checking a name String against a Object.

if (player in pilots) then

Share this post


Link to post
Share on other sites

Trying to make this work with Arma 3

i meant to use what neokika posted, just use playerId instead of names, because of potential cheating, and the odd letters sometimes used in names.

well you have locked all vehicles to clan members, simply find same spot and run neokikas script on everyone of them.

fex:

save neokikas script as vehiclelock.sqf

_vehicle = _this select 0;  // i added this line.

_vehicle addEventHandler ["GetIn", 
{
private ["_veh", "_pos", "_unit", "_namesArray"];
_veh = _this select 0;
_pos = _this select 1;
_unit = _this select 2;
_namesArray = ["John", "_spiderMan_", "CowGirl"];

if !(name _unit in _namesArray) then
{
_unit action ["Eject", vehicle _unit];
};
}];  

and run this line on every vehicle that is currently unlocked for clan only.

_null = [_vehiclename] execVM "vehiclelock.sqf";

and switch out names for player id if you want as i posted above.

If I try to use:

_null = [_vehiclename] execVM "vehiclelock.sqf";

In the vehicle it gives me the error: Local variable in global space.

---------- Post added at 18:32 ---------- Previous post was at 18:04 ----------

If I try to use:

_null = [_vehiclename] execVM "vehiclelock.sqf";

In the vehicle it gives me the error: Local variable in global space.

I got it to work now, I changed this bit to:

veh = [this] execVM "vehiclelock.sqf";

But I also want the vehicles to keep there init after respawning so they are still locked after respawning.

Edited by MightyDutchLord

Share this post


Link to post
Share on other sites

I have been using this script for a long time now and it has performed as intended. As of the last update to version 1.36 it stopped working. I'm running an Invade & Annex mission on a dedicated server and use the script to restrict a Wipeout CAS jet to trusted members and others who will not misuse it.

vipOnly.sqf

waitUntil {!isNull player};

_vehicle = _this select 0;
_vehicle addEventHandler ["GetIn",
{
private ["_veh", "_pos", "_unit", "_namesArray"];
_veh = _this select 0;
_pos = _this select 1;
_unit = _this select 2;
_namesArray = ["name1","name2","name3","name4"];

if !(name _unit in _namesArray) then
{
_unit action ["getOut", vehicle _unit];
if (isEngineOn _veh) then {_veh engineOn false};
systemChat format ["You need to be a VIPilot to fly this aircraft. Check FAQ in the menu on the map, top left corner!"];
};
}];

if(true) exitWith{};

fn_vSetup02

//===== wipeout skin and VIP only

if(_t in _wipeout) then {
[_u] execVM "scripts\vehicle\vipOnly.sqf";
_u setObjectTextureGlobal [0,'media\images\desert_camo_1.paa'];
_u setObjectTextureGlobal [1,'media\images\desert_camo_1.paa'];
};

mission.sqf

init="0 = [this,600,FALSE,QS_fnc_vSetup02] spawn QS_fnc_vMonitor;";

It still works when I'm running it on my own computer. I'm stuck and cant figure out what is wrong so I would very much appreciate some help to make it work again.

Share this post


Link to post
Share on other sites
I have been using this script for a long time now and it has performed as intended. As of the last update to version 1.36 it stopped working. I'm running an Invade & Annex mission on a dedicated server and use the script to restrict a Wipeout CAS jet to trusted members and others who will not misuse it. .... It still works when I'm running it on my own computer. I'm stuck and cant figure out what is wrong so I would very much appreciate some help to make it work again.

vipOnly.sqf

[color="#FF0000"]waitUntil {!isNull player};[/color]

[color="#A9A9A9"]_vehicle = _this select 0;[/color]

It could be that you're having a dedicated server run a "player" query. There is no real player on a dedicated server. Is the code being run from server or client?

https://community.bistudio.com/wiki/hasInterface

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  

×