Jump to content
Sign in to follow this  
1para{god-father}

Block area from entry

Recommended Posts

Is there a way to block certain areas of the map form anyone entering unless a varible has been set to true ?

i.e

Can you place a marker and a trigger and if anyone enters that zone appart from say 2 players who are in the list they die ?

is that possible ?

Share this post


Link to post
Share on other sites

This is untested but should work fine as ive used similar on waypoints:

// execute with in trigger side desired, or anybody repeated.
// _null = [triggername] execVM "script.sqf"
Allowed_entry_units = [unit1,unit3,unit4];
if (isServer AND KeepPeopleOut) then {
_triggername = _this select 0;
_triggerSize = triggerArea _triggername;
_pushDist = ((((_triggerSize select 0) + (_triggerSize select 1)) / 2) + 5);

{
	_vector = ((((getPos _x select 0) - (getPos _triggername select 0)) atan2 ((getPos _x select 1) - (getPos _triggername select 1))) + 360) % 360;
	_offdir = 180;
	_compassDir = (_vector+_offdir) mod 360;

	_newX = (getPos _x select 0) + (sin _compassDir * _pushDist);
	_newY = (getPos _x select 1) + (cos _compassDir * _pushDist);
	_newPos = [_newX, _newY, (getPos _x select 2)];

	if (_x in Allowed_entry_units) then {} else {
		(vehicle _x) setPos _newPos;
	};
} foreach list _triggername;

};

Have this somewhere: KeepPeopleOut=true;

Now any units/vehicles not in the Allowed_entry_units array at top will be moved 5 meter out of the trigger area based on if they were facing directly at center trigger, and then theyll be moved backwards out of trigger area.

KeepPeopleOut setting this to false will cause it to stop blocking the area.

So if unit1,unit2,unit3,tarzan,jane,michael_jackson enters the above trigger, only unit1 and unit3 will be unaffected, all else will be teleported outside the trigger area 5 m, based on direction from them to center trigger, then moved directly backwards.

Having trigger spherical is important else strange things might happen.

so 500 x 500 y size, else if you have a rectangel or not 100% round trigger area, run a while loop inside and adding 5 meters to every attempt in pushDist and check if position is in list _triggername if not setPos there, else increase pushdist and retry.

Edited by Demonized

Share this post


Link to post
Share on other sites

Mate that is TOP!!!!!!! Love it thanks a million!

Trying to learn so hope you do not mind the question !

How is the script getting the players name ?

I was going to tweek it a little and try and use "name player" so i can list a few players i know that can enter the zone and not just anyone who is playing and selected the slot.

Is this possible ?

Edited by psvialli

Share this post


Link to post
Share on other sites

Wait, you sure you can setPos on the server vehicles that aren't local to the server? Make sure this actually works for clients in multiplayer...

Share this post


Link to post
Share on other sites
Mate that is TOP!!!!!!! Love it thanks a million!

Trying to learn so hope you do not mind the question !

Not at all, im still learning myself, and got most of the info i have on scripts the same way, from here from the community.

Not guaranteeing anything 100%, but trial and error gets you a long way, if you are new to scripting and have not checked out mr murrays editing guide, i can really recomend it, in fact i do that to all that want to learn more of scripting as it covers many many if not almost allaspects in some way.

I was going to tweek it a little and try and use "name player" so i can list a few players i know that can enter the zone and not just anyone who is playing and selected the slot.

Is this possible ?

not sure about how to get the profilename of the player, but once you do, just add it to the Allowed_entry_units array i think.......

How is the script getting the players name ?

the unit you place in editor just name that in the name field and add that name to the array.

Wait, you sure you can setPos on the server vehicles that aren't local to the server? Make sure this actually works for clients in multiplayer...

At first i just asumed this was an anti base rape thing or something so i did not think to hard on player AI group members.

Not 100% sure, i rechecked wiki on locality and it says AI in player groups are local to clients not server so those wont be affected, but any AI not in player group is local to server, any vehicle is local to server, also i hope players are local to bothe client and server, but heck im just guessing.

but i think it should work as ive setPosed myself on server in the past and i think that was inside a serverside script.

Only testing will prove it working or not, wich would be fairly easy if one had a dedicated server somewhere :)

Maybe the calculations could be done server side and end the server side there and spawn a setPos instead locally.. unsure of consequences of setPos locally if not needed.

Edited by Demonized

Share this post


Link to post
Share on other sites
Is there a way to block certain areas of the map form anyone entering unless a varible has been set to true ?

i.e

Can you place a marker and a trigger and if anyone enters that zone appart from say 2 players who are in the list they die ?

is that possible ?

you can create invisible wall and you can also delete it once the condition is met.

Share this post


Link to post
Share on other sites

@ FFur2007 How would you make an invisible wall ? just curious as that is something i wouldlike to use on somethig else !

@ Demonized - sorry should have asked the question a little better - In your script what part grabs the players name and checks it to the list? it looks like _x and if so how does x_ get the name ?

Cheers

Share this post


Link to post
Share on other sites

Vehicles are local to where the driver is local, or the server if there is no driver.

Share this post


Link to post
Share on other sites
@ Demonized - sorry should have asked the question a little better - In your script what part grabs the players name and checks it to the list? it looks like _x and if so how does x_ get the name ?

Cheers

_x is because of a foreach loop, _x means the one selected:

foreach selects all in an array and the one currently selected is always _x.

foreach goes through an array of anything and you can do anything to each of the things in the array.

array is basically [] wich you can enter stuff in.in the script in my first post you see the array Allowed_entry_units = [unit1,unit3,unit4]

i count the array (list trigername) wich is all units detected by that trigger, if trigger is blue detected, then list will return all blue units in that trigger area.

{_x setdammage 1} foreach playableunits; // will kill all units that are playable.

imagine what happens if you have 3 playable units in mission and does like above:

_x = 1st unit and setdammage to 1 for that unit.

_x = 2nd unit and setdammage to 1 for that unit.

_x = 3rd unit and setdammage to 1 for that unit.

end.

Another example:

{
if (_x == player) then 
{
	[_x] execVM "anyscript.sqf";
} else {
	_x setDammage 0;
};
} foreach playableunits;

imagine this happens if 3 playable units is in the mission:

_x = 1st unit, and if that unit is a player then run a script called anyscript.sqf for that unit and pass that players name(_x) to the new script, if not(else) a player setdammage 0 to that unit.

_x = 2nd unit, and if that unit is a player then run a script called anyscript.sqf for that unit and pass that players name(_x) to the new script, if not(else) a player setdammage 0 to that unit.

_x = 3rd unit, and if that unit is a player then run a script called anyscript.sqf for that unit and pass that players name(_x) to the new script, if not(else) a player setdammage 0 to that unit.

So you can see that you can pass or do simple commands or combine various commands inside a foreach loop, _x is always current selected object in that array, it does what you have or check what you have and then does exactly the same for the next one.

Maybe a bad explanation, really take a look into the mr murrays editing guide deluxe, it says its for arma 1 but it works on arma2 for almost all the stuff.

It probably have a better explanation of _x in foreach as well.

Edited by Demonized

Share this post


Link to post
Share on other sites

Many thanks for the explination that does help me undestand a lot better !

Ill download the Manual now i think and start reading best way to learn !

Thanks again

Share this post


Link to post
Share on other sites
@ FFur2007 How would you make an invisible wall ? just curious as that is something i wouldlike to use on somethig else !

@ Demonized - sorry should have asked the question a little better - In your script what part grabs the players name and checks it to the list? it looks like _x and if so how does x_ get the name ?

Cheers

I used to find a invisible wall in cfgClasses but sorry to say I forget its class name.

Can you remember that when you're playing the Red Harvest, Your movement was limited on the aircraft carrier in the first mission, some parts of the deck are unavailable, I suggest you unpack this official mission and take a look.:D

Share this post


Link to post
Share on other sites

Hi Demonized,

Works great apart from if you run into the trigger it then teleports you to the other side of the trigger and not back 5 meters. i.e foward +5

I changed _compassDir = (_vector+_offdir) mod 360; to _compassDir = (_vector+_offdir) mod 180;

That seems to work - many thanks for your time on this!!!

Cheers

Edited by psvialli

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  

×