Jump to content
Sign in to follow this  
silentx3ro

Restricting access to vehicles

Recommended Posts

Hello all,

First let me apologise if this is in the wrong place or a repost but I've been searching various forums for litterally most of the day (started at 12pm its now 1am o_O) and haven't found anthing that has helped.

What I am aiming to do is to restrict access to vehicles (specifically Jets and attack choppers) to only allow members of my clan. the server is running Domination 2.10 and basicaly were sick of coming into the server to find attack aircraft wrecked overnight and wrecks lying all over the map.

I found a few posts relating to restricting access but all they've done so far is confuse me further.

I am a complete scripting novice and have little to no idea what im doing.

Ideally it would be scripted to apply to all starting attack aircraft AND any spawned as side mission rewards. Also I would like to have it work of Player UID or our squad xml but have no idea how to do either.

This is what I've been trying to get to work using player names (adapted from Franze's post in this thread here) but so far have been unable to get it to work, most likely because I've naffed up something in the code I've changed.

 in vehicle init: RestrictAccess = this addEventHandler ["getin", {_this execvm 'crewcheck.sqf'}] 

array = _this;
_vehicle = _this select 0;
_position = _this select 1;
_man = _this select 2;
_crewarray = [PLAYERNAME];

if (!(_man in crewarray)) then
{
hint format ["%1, you are not authorised to use this vehicle",name _man];
_man action ["eject",_vehicle];
};

Any help that anyone can give would be hugely appreciated, I have honestly never been more annoyed and confused by anything in my life (with the exception of reality TV!).

Thanks

silentx3ro

Share this post


Link to post
Share on other sites

Most likely...i'm not.

I can't emphasize enough how little I know what I'm doing. :eek:

Basically i'm doing this cause no one else wanted to :p

The reason that I put that array there...most likely because from what I could decipher from faq's that seemed like as good a place as any :confused:

Honestly though anything you can see in what I've posted that looks wrong almost certainly is!

So...how should I populate that array?

Share this post


Link to post
Share on other sites

_crewarray = [unit1, unit2, unit3];

In the editor, set the units names to unit1 etc, and report back on progress. Domination and Domino both uses restriction to vehicles. Currently unable to test this though, and seeing you're at post #2, I don't expect you to have ventured into the multiplayer editing realm yet.

Share this post


Link to post
Share on other sites

Ok new day new attempt to get my head around this.

Thanks for your reply. I'll give that a try in single player to get to grips with the code but i take it populating the array like that would be no use in multiplayer?

Thing is I understand the logic behind what needs to be done I just dont know how to word it so the the game knows too (or where abouts to put it for that matter!).

Here is, the way I see it, what needs to happen. I know that the syntax is wrong but its just to give a clearer idea of what I'm trying to do on my clan's public server.

Player A enters vehicle which triggers the following;

Check vehicle type
if vehicle type != AH1Z, AH64D, A10, AV8B, F35B 
then stop script
else (get Player A's UID) 
        if (Player A's UID != UID on clan list)
            then eject Player A
                    hint "You are not authorised to use that vehicle!"
             else
                    hint "Clan member confirmed - Good Hunting!"

I'm off to read the Arma 2 scripting faq again in the hope that overnight all the words have moved around and now somehow make sense to me!

Any help on this is appreciated.

Thanks

silentx3ro

Share this post


Link to post
Share on other sites

First, you will need to establish a list of UIDs for your whole clan. Put each UID in quotes, and separate each one with a comma. Now put that list in brackets, and voila, you have the master array to check against. Establish this array in the init.sqf file of your mission (if you don't have such a file, create one). You can put it anywhere you'd like in that file; it should look something like this:

masterUIDArray = ["xxxxxxx","yyyyyyy","zzzzzzz"];

Now, copy and paste the following line into the initialization field of each vehicle for which you want access to be restricted:

this addEventHandler ["GetIn",{if (getPlayerUID (_this select 2) in masterUIDArray) then {hint "Clan member confirmed -- Good Hunting!"} else {(_this select 2) action ["getOut",(_this select 0)];hint "You are not authorized to use that vehicle!"}}]

And that should do it.

Edited by ST_Dux

Share this post


Link to post
Share on other sites

awesome, I'll give it a go.

EDIT: Works like a charm!

Thanks so much, I cant tell you how much grief this has given me!!

Thanks to everyone who helped out.

Cheers

silentxero

---------- Post added at 07:55 PM ---------- Previous post was at 07:43 PM ----------

One question. Will this work on vehicles that respawn or will that require something different?

Edited by silentx3ro

Share this post


Link to post
Share on other sites
One question. Will this work on vehicles that respawn or will that require something different?

You'll have to readd the eventhandler when the vehicle respawns. Off the top of my head I probably can't give you a working way of doing that, maybe someone who's more familiar with using respawning vehicles.

Share this post


Link to post
Share on other sites

Messed arround with it a little but no matter what I do I cant get the eventhadler to reapply when the vehicle respawns.

Anyone got any ideas how to make this happen?

Share this post


Link to post
Share on other sites

Yes, make your own vehicle respawn script. Should be easy enough to attach your own event handlers. I've given up using vanilla respawn system long time ago, as I felt I couldn't be in charge over what was going on.

Share this post


Link to post
Share on other sites

i guess i can give it a shot...I'll be back when I break something.

Edited by silentx3ro

Share this post


Link to post
Share on other sites

If you need to run this check for dynamically-created vehicles (respawned vehicles fall into this category), then simply taking a different approach would probably be easier than attempting to reinvent the wheel and write a custom vehicle respawn script. Try this:

1. Accumulate a list of vehicle class names for which you want access to be restricted. Like your UID list, make this list into an array.

2. Declare this array alongside your UID array in init.sqf. Call it masterClassArray.

3. Nix the event handler method altogether; instead...

4. Create a repeatedly-activated trigger with the following fields:

Condition:

vehicle player != player

On Activation:

if (typeOf (vehicle player) in masterClassArray) then {if (getPlayerUID player in masterUIDArray) then {hint "Clan member confirmed -- Good Hunting!"} else {player action ["getOut",(vehicle player)];hint "You are not authorized to use that vehicle!"}}

As the reserved variable "player" returns something different on every client in a multiplayer game, this single trigger should be automatically customized for each person that joins the server.

Share this post


Link to post
Share on other sites

wow...you could leave me on an island for a million years and I would never work out how to do that!

I'll give this a shot and let you know.

Edit:Works perfectly, thanks alot! :)

---------- Post added at 10:03 PM ---------- Previous post was at 08:57 PM ----------

One other thing i hope you folks could help with,

I'm using the following so that my clan members can spawn in with their prefered weapon loadouts addapted from this thread;

In init.sqf

null=[] execVM "clankits.sqf";  //Runs Clan Gear Loader

clankits.sqf

// Spawns clan members in with prefered kits
WaitUntil{not isNull player};
waitUntil {(getPlayerUID player) != ""};

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

#include "kitlist.sqf";

sleep 1;
hint parseText (_title + _text);

and finally kitlist.sqf

//clan member kit list
sleep 35;
switch(_uid)do 
{ 
case "xxxxxxx": // silentx3ro
{                 
	removeAllWeapons player;
	{player addmagazine "100Rnd_556x45_BetaCMag";} forEach [1,2,3,4,5,6];
	player addWeapon "G36K"; 
	{player addmagazine "SMAW_HEAA";} forEach [1,2,3,4];
	player addWeapon "SMAW";
	{player addmagazine "pipebomb";} forEach [1,2];
               {player addmagazine "Laserbatteries";} forEach [1,2];
	player addweapon "Laserdesignator"; player addweapon "NVGoggles";
               hint "Gear Loaded"


};

};

Everything works as planned except when a player respawns they have the same gear they died with. I would like to make the above script run again after respawn so the player has full ammo on respawn.

What would I need to change so that it does?

Edited by silentx3ro

Share this post


Link to post
Share on other sites

For every player, either a killed EH or a script that goes waitUntil {!alive _unit}; store weapons and ammo into arrays local to each unit. Then waitUntil {alive _unit}; add back wepons and ammo from arrays local to each unit. For more advanced handling if items, check out Domination code, deals with plenty of stuff you should be aware of.

Share this post


Link to post
Share on other sites

With ref to post #6. I wonder is it possible to have your own AI in the same vehicle? If so how could I achieve it without grouping them to me in the editor. I have tried the scripting example but only human clan members can get in the vehicles. Any help is much appreciated.

Share this post


Link to post
Share on other sites

@GeeBee:

At the beginning of the "else" block in the event handler code, add:

if (!isPlayer) exitWith {};

Share this post


Link to post
Share on other sites
For every player, either a killed EH or a script that goes waitUntil {!alive _unit}; store weapons and ammo into arrays local to each unit. Then waitUntil {alive _unit}; add back wepons and ammo from arrays local to each unit. For more advanced handling if items, check out Domination code, deals with plenty of stuff you should be aware of.

awsome will do, thanks

Share this post


Link to post
Share on other sites

@ST Dux

Not sure what you mean! Im using the exact line as in post #6 and I tried putting it in the Int field B4 the else statement and after but it wont let me use that line! Any chance that you can show me exactley!

Thanks for the help by the way.

Share this post


Link to post
Share on other sites

My problem is I want to limit access to a vehicle (clan members and AI only) now by using this code post #6 I can limit it to clan members only and yes it does work but any AI that I recruit cannot get in!

When I try to enter this line in the int part of the editor for the vehicle all I get is a box that says OK and it will not let me enter the code!

Code:

this addEventHandler ["GetIn",{if (getPlayerUID (_this select 2) in masterUIDArray) then {hint "Clan member confirmed -- Good Hunting!"} if (!isPlayer) exitWith {}; else {(_this select 2) action ["getOut",(_this select 0)];hint "You are not authorized to use that vehicle!"}}]

Can anyone throw some light on it please as I’m not in the big league regarding scripting (still a beginner). Thanks in anticipation.

Gaza

Share this post


Link to post
Share on other sites

Just off the top of my head. Kicks out any unit that belongs to a player (or the player himself) that is not in your list of UIDs, allows everyone else in.

Edit: Fixed a typo in the code.

getIn.sqf

_unit = _this select 2;
_veh = _this select 0;

_array = whatever your array of UIDs is

_grp = group _unit;
_ldr = leader _grp;

if((isPlayer _ldr) && !((getPlayerUID _ldr) in _array))then{
_unit action ["GETOUT",_veh];
if(local _unit)then{hint "You don't have access to this vehicle"};
};

Edited by Big Dawg KS

Share this post


Link to post
Share on other sites

@GeeBee:

this addEventHandler ["GetIn",{if (getPlayerUID (_this select 2) in masterUIDArray) then {hint "Clan member confirmed -- Good Hunting!"} if (!isPlayer) exitWith {}; else {(_this select 2) action ["getOut",(_this select 0)];hint "You are not authorized to use that vehicle!"}}]

You're putting the "isPlayer" check in the wrong place. Use this:

this addEventHandler ["GetIn",{if (getPlayerUID (_this select 2) in masterUIDArray) then {hint "Clan member confirmed -- Good Hunting!"} else {if (!isPlayer) exitWith {};(_this select 2) action ["getOut",(_this select 0)];hint "You are not authorized to use that vehicle!"}}]

Share this post


Link to post
Share on other sites

Sorry ST Dux the editor still wont allow me to put that line in fella!

Im pulling my hair out now! Ouch!

Share this post


Link to post
Share on other sites
Sorry ST Dux the editor still wont allow me to put that line in fella!

Im pulling my hair out now! Ouch!

Look at my above post. Did you try that?

Share this post


Link to post
Share on other sites

Shure did the editor returns a value in the OK box with nothing in it and it wont allow a save. Sorry!

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  

×