Arma 3
Cryonic Jul 3, 2017 @ 5:16am
How do I create a safe zone?
I am creating a multiplayer mission and I do not want players or vehicles to take damage in their deployment area. I have already tried creating a trigger and including "player allowDamage false;" and "player allowDamage true;" but it doesn't work very well. I have very little experience in scripting so if you can help me, please be detailed in your explanation. Thanks!
< >
Showing 1-15 of 26 comments
NobodysLaw Jul 3, 2017 @ 5:43am 
You could place a marker in the area, let's called it "mrk_safe_zone". Code would be then in your init.sqf

0 = [] spawn { while{true} do { { if(_x distance (getMarkerPos "mrk_safe_zone") < 100) then {_x allowDamage false} else {_x allowDamage true}; } forEach allUnits + vehicles; sleep 1; }; };
If a unit or vehicle is within 100 meters of the marker, thy cannot be damaged. When they move out, they can be killed/destroyed again
Cryonic Jul 3, 2017 @ 5:50am 
Originally posted by Nobody:
You could place a marker in the area, let's called it "mrk_safe_zone". Code would be then in your init.sqf

0 = [] spawn { while{true} do { { if(_x distance (getMarkerPos "mrk_safe_zone") < 100) then {_x allowDamage false} else {_x allowDamage true}; } forEach allUnits + vehicles; sleep 1; }; };
If a unit or vehicle is within 100 meters of the marker, thy cannot be damaged. When they move out, they can be killed/destroyed again
Where can I find the init.sqf?
NobodysLaw Jul 3, 2017 @ 5:54am 
you create that file in the mission folder.

1. open notepad
2. put the code from above into it
3. go to "Save as.."
4. type "init.sqf" (WITH the quotes around it)
5. save it in the mission folder you are currently working on
Cryonic Jul 3, 2017 @ 6:12am 
Originally posted by Nobody:
you create that file in the mission folder.

1. open notepad
2. put the code from above into it
3. go to "Save as.."
4. type "init.sqf" (WITH the quotes around it)
5. save it in the mission folder you are currently working on
Nobody, you are a life saver my dude. I've been looking for a solution for 2 hours. This will work for all players in multiplayer correct? Is there any way to make it to where only a specific side is affected in the area?
Last edited by Cryonic; Jul 3, 2017 @ 6:19am
NobodysLaw Jul 3, 2017 @ 8:41am 
just change
if(_x distance (getMarkerPos "mrk_safe_zone") < 100) to if(side _x == WEST && _x distance (getMarkerPos "mrk_safe_zone") < 100)
WEST for Blufor
EAST for Opfor

and yes, it works in Multiplayer and on dedicated servers
Last edited by NobodysLaw; Jul 3, 2017 @ 8:42am
Cryonic Jul 3, 2017 @ 11:55am 
I appreciate your help Nobody.
Cryonic Jul 3, 2017 @ 12:10pm 
Originally posted by Nobody:
just change
if(_x distance (getMarkerPos "mrk_safe_zone") < 100) to if(side _x == WEST && _x distance (getMarkerPos "mrk_safe_zone") < 100)
WEST for Blufor
EAST for Opfor

and yes, it works in Multiplayer and on dedicated servers

0 = [] spawn { while{true} do { { if(side _x == WEST && _x distance (getMarkerPos "bluefor_safe_zone") < 200) then {_x allowDamage false} else {_x allowDamage true}; } forEach allUnits + vehicles; sleep 1; { if(side _x == EAST && _x distance (getMarkerPos "opfor_safe_zone") < 200) then {_x allowDamage false} else {_x allowDamage true}; } forEach allUnits + vehicles; }; };

I dont believe that I did it correctly.
I have two different safe zones.
My player is invincible but the vehicles are not.
Last edited by Cryonic; Jul 3, 2017 @ 12:41pm
ScotLionGaming Jul 3, 2017 @ 5:49pm 
Could try a protection zone. Not really a script but its in the editor. Makes bullets into blanks.
Cryonic Jul 3, 2017 @ 5:51pm 
Originally posted by Raven:
Could try a protection zone. Not really a script but its in the editor. Makes bullets into blanks.

I appreciate your help. I'm gonna look more into it now. Thanks!
ScotLionGaming Jul 3, 2017 @ 5:54pm 
Originally posted by CryonicWand:
Originally posted by Raven:
Could try a protection zone. Not really a script but its in the editor. Makes bullets into blanks.

I appreciate your help. I'm gonna look more into it now. Thanks!
Just use the yellow marker it makes on the map as a guide to how big it is. Also works to protect houses from explosives.
Cryonic Jul 3, 2017 @ 5:54pm 
Originally posted by Raven:
Originally posted by CryonicWand:

I appreciate your help. I'm gonna look more into it now. Thanks!
Just use the yellow marker it makes on the map as a guide to how big it is. Also works to protect houses from explosives.

Alright, I'll check it out rn.
ScotLionGaming Jul 3, 2017 @ 5:57pm 
Originally posted by CryonicWand:
Originally posted by Raven:
Just use the yellow marker it makes on the map as a guide to how big it is. Also works to protect houses from explosives.

Alright, I'll check it out rn.
Give me a message if thats what you wanted.
Squatchin Apr 15, 2018 @ 4:47pm 
Can you limit the size of the safe zone? Like, height wise?
Last edited by Squatchin; Apr 15, 2018 @ 4:47pm
IM SORRY BUFFALO Apr 15, 2018 @ 5:03pm 
Originally posted by Squatchin:
Can you limit the size of the safe zone? Like, height wise?
i havent read the above posts but yes, mine uses a trigger as the zone so just adjust the trigger in the editor and its done. name trigger safeTrigger
put this in trigger condition, set anyplayer present as well and repetable
this && player in thisList
in activation
null = [] execVM "zone\inSafeZone.sqf";
in deactivation
null = [] execVM "zone\leftSafeZone.sqf";

in inSafeZone.sf
hint "In Safe Zone"; player allowDamage false; isSafe = true; while {isSafe} do { derp = player action ["SwitchWeapon", player, player, 100]; sleep 1; };
in leftSafeZone.sqf
isSafe = false; hint "Leaving Safe Zone"; player action ["SwitchWeapon", player, player, 0]; player allowDamage true;

and if you want to make a marker that spawns and sets itself to the triggers size automatically so players can see it on the map you can use this
_triggerArea = triggerArea safeTrigger; _triggerPos = getPos safeTrigger; _trgX = (_triggerArea select 0); _trgY = (_triggerArea select 1); "zoneMarker" setMarkerSize [_trgX, _trgY]; "zoneMarker" setMarkerPos _triggerPos;
Squatchin Apr 15, 2018 @ 6:00pm 
Originally posted by IM SORRY BUFFALO:
Originally posted by Squatchin:
Can you limit the size of the safe zone? Like, height wise?
i havent read the above posts but yes, mine uses a trigger as the zone so just adjust the trigger in the editor and its done. name trigger safeTrigger
put this in trigger condition, set anyplayer present as well and repetable
this && player in thisList
in activation
null = [] execVM "zone\inSafeZone.sqf";
in deactivation
null = [] execVM "zone\leftSafeZone.sqf";

in inSafeZone.sf
hint "In Safe Zone"; player allowDamage false; isSafe = true; while {isSafe} do { derp = player action ["SwitchWeapon", player, player, 100]; sleep 1; };
in leftSafeZone.sqf
isSafe = false; hint "Leaving Safe Zone"; player action ["SwitchWeapon", player, player, 0]; player allowDamage true;

and if you want to make a marker that spawns and sets itself to the triggers size automatically so players can see it on the map you can use this
_triggerArea = triggerArea safeTrigger; _triggerPos = getPos safeTrigger; _trgX = (_triggerArea select 0); _trgY = (_triggerArea select 1); "zoneMarker" setMarkerSize [_trgX, _trgY]; "zoneMarker" setMarkerPos _triggerPos;
Can this be applied to more than one trigger? or am i going to have to repeat this for each safe zone?
< >
Showing 1-15 of 26 comments
Per page: 1530 50