Nutzgo 15 Posted December 14, 2019 So I'm trying to make a zone restriciton area with this script:https://www.tacticalgamer.com/forum/simulation/armed-assault/arma-development/script-bin/1797607-zone-restriction-version-2 zoneRestrictor.sqf: Quote //usage: zoneR = [nameOfTrigger]execVM "Unk\zoneRestrictor.sqf"; _triggerActivated = _this select 0; if !(player in (list _triggerActivated)) exitWith {}; systemChat "RETURN TO YOUR ASSIGNED AREA IMMEDIATELY!"; playSoundWarning = true; cutText ["YOU HAVE 7 SECONDS TO LEAVE THIS AREA", "plain", 0]; titleFadeout 5; sleep 7; if (player in (list _triggerActivated)) then { player setDamage 1; systemChat "YOU HAVE BEEN KILLED FOR LEAVING YOUR AREA"; } else { if (side player == west || side player == independent) then {systemChat "YOU HAVE CLEARED THE UNAUTHORIZED ZONE";}; }; I have a trigger with conditon Quote this and on activation Quote zoneR = [thisTrigger]execVM "zoneRestrictor.sqf"; It works perfectly for infantry. But whenever I drive a vehicle or a helicopter in the zone, it wont activate. I've tried changing the condition to "this && (vehicle player) in thislist" but that didn't to the trick at all. Share this post Link to post Share on other sites
pierremgi 4881 Posted December 15, 2019 this & thisList refer to the pre-condition of the trigger like BLUFOR PRESENT or DETECTED BY BLUFOR or ANY PLAYER PRESENT... A trigger detects units on foot and vehicles. So, thisList is made of infantry or vehicles but never units in vehicles (any player detects the player's vehicle). What you need: a trigger working for player(s) only. In SP just use any player present and your code (here spawned or use an sqf): 0 = thisTrigger spawn { _triggerActivated = _this; systemChat "RETURN TO YOUR ASSIGNED AREA IMMEDIATELY!"; playSoundWarning = true; cutText ["YOU HAVE 7 SECONDS TO LEAVE THIS AREA", "plain", 0]; titleFadeout 5; sleep 7; if (player inArea _triggerActivated) then { player setDamage 1; systemChat "YOU HAVE BEEN KILLED FOR LEAVING YOUR AREA" } else { systemChat "YOU HAVE CLEARED THE UNAUTHORIZED ZONE" }; }; For MP, It's better to use a local trigger, so a scripted one, and you don't want to activate the trigger for any player but the player entering the area: In initPlayerLocal.sqf: _trg = createTrigger ["EmptyDetector",<position>,FALSE]; // on your position _trg setTriggerArea [500, 500, 0, false]; // your area _trg setTriggerActivation ["ANYPLAYER", "PRESENT", true]; _trg setTriggerStatements ["thisList findIf {local _x} >-1", " 0 = thisTrigger spawn { _triggerActivated = _this; systemChat 'RETURN TO YOUR ASSIGNED AREA IMMEDIATELY!'; playSoundWarning = true; cutText ['YOU HAVE 7 SECONDS TO LEAVE THIS AREA', 'plain', 0]; titleFadeout 5; sleep 7; if (player inArea _triggerActivated) then { player setDamage 1; systemChat 'YOU HAVE BEEN KILLED FOR LEAVING YOUR AREA' } else { systemChat 'YOU HAVE CLEARED THE UNAUTHORIZED ZONE' }; }; ", ""]; 1 1 Share this post Link to post Share on other sites
Nutzgo 15 Posted December 15, 2019 Hey, thanks. That worked perfectly! Now, I'm trying to keep my initplayerlocal clean, so I thought I could execute that in a separate script from InitPlayerLocal. So I copy/pasted into a seperate script, and called it zoneRestrictor.sqf. In Initplayerlocal, I added the line Quote []ExecVM "zoneRestrictor.sqf"; But now, nothing happens. 😅 If I keep the whole text in initplayerlocal, it works though. Share this post Link to post Share on other sites
pierremgi 4881 Posted December 15, 2019 thisTrigger execVM "zoneRestrictor.sqf" Then _triggerActivated = _this; at start of this sqf. (you don't need to pass an array). 1 Share this post Link to post Share on other sites
Larrow 2821 Posted December 15, 2019 11 hours ago, pierremgi said: For MP, It's better to use a local trigger, so a scripted one All set trigger commands are EL ( effect local ), so you can make a trigger that is placed in the editor behave differently on each client. It does not have to be a fully scripted trigger (created). Spoiler //initPlayerLocal.sqf _nul = [] execVM "zoneRestrictor.sqf"; //zoneRestrictor.sqf //trigger placed and sized in editor to cover assigned area _trg = nameOfTriggerPlacedInEditor; //replace with given name //Attach the player as the object associated with this trigger locally _trg triggerAttachVehicle[ player ]; //Set attached vehicle(player) as the object to monitor locally _trg setTriggerActivation[ "VEHICLE", "NOT PRESENT", true ]; _trg setTriggerStatements[ "this", " TAG_triggerAOWarning = [] spawn { systemChat 'RETURN TO YOUR ASSIGNED AREA IMMEDIATELY!'; 'TAG_triggerAOWarning' cutText[ 'YOU HAVE 7 SECONDS TO LEAVE THIS AREA', 'PLAIN', 0 ]; titleFadeout 5; sleep 7; player setDamage 1; systemChat 'YOU HAVE BEEN KILLED FOR LEAVING YOUR ASSIGNED AREA' }; ", " if ( !isNil 'TAG_triggerAOWarning' ) then { if !( isNull TAG_triggerAOWarning ) then { terminate TAG_triggerAOWarning; }; 'TAG_triggerAOWarning' cutText[ '', 'PLAIN' ]; systemChat 'YOU HAVE CLEARED THE UNAUTHORIZED ZONE'; }; TAG_triggerAOWarning = nil; " ]; Share this post Link to post Share on other sites
pierremgi 4881 Posted December 15, 2019 2 hours ago, Larrow said: All set trigger commands are EL ( effect local ), so you can make a trigger that is placed in the editor behave differently on each client. It does not have to be a fully scripted trigger (created). Reveal hidden contents //initPlayerLocal.sqf _nul = [] execVM "zoneRestrictor.sqf"; //zoneRestrictor.sqf //trigger placed and sized in editor to cover assigned area _trg = nameOfTriggerPlacedInEditor; //replace with given name //Attach the player as the object associated with this trigger locally _trg triggerAttachVehicle[ player ]; //Set attached vehicle(player) as the object to monitor locally _trg setTriggerActivation[ "VEHICLE", "NOT PRESENT", true ]; _trg setTriggerStatements[ "this", " TAG_triggerAOWarning = [] spawn { systemChat 'RETURN TO YOUR ASSIGNED AREA IMMEDIATELY!'; 'TAG_triggerAOWarning' cutText[ 'YOU HAVE 7 SECONDS TO LEAVE THIS AREA', 'PLAIN', 0 ]; titleFadeout 5; sleep 7; player setDamage 1; systemChat 'YOU HAVE BEEN KILLED FOR LEAVING YOUR ASSIGNED AREA' }; ", " if ( !isNil 'TAG_triggerAOWarning' ) then { if !( isNull TAG_triggerAOWarning ) then { terminate TAG_triggerAOWarning; }; 'TAG_triggerAOWarning' cutText[ '', 'PLAIN' ]; systemChat 'YOU HAVE CLEARED THE UNAUTHORIZED ZONE'; }; TAG_triggerAOWarning = nil; " ]; Yes, but: - this kind of area doesn't need to attach a trigger; - creating a local trigger (scripted) will not "stack" triggers locally. To be more precise: * a server only trigger will not work easily for this aim (local hint, local kill) >> not a solution here (OK everybody). * a not server only and global one (scripted or edited) will "stack" triggers locally, even if the condition I wrote will filter the local player entering the area. That works but you have more triggers than necessary. Test, the global syntax (or edited trigger), with several players of course: Spoiler _trg = createTrigger ["EmptyDetector",getpos thisTrigger,false]; _trg setTriggerArea [50, 50, 0, false]; _trg setTriggerActivation ["ANYPLAYER", "PRESENT",TRUE]; _trg setTriggerStatements ["thisList findIf {local _x} >-1", " 0 = thisTrigger spawn { _triggerActivated = _this; systemChat 'RETURN TO YOUR ASSIGNED AREA IMMEDIATELY!'; playSoundWarning = true; hint str (count (getpos _triggeractivated nearObjects ['emptydetector',20])); cutText ['YOU HAVE 7 SECONDS TO LEAVE THIS AREA', 'plain', 0]; titleFadeout 5; sleep 7; if (player inArea _triggerActivated) then { player setDamage 1; systemChat 'YOU HAVE BEEN KILLED FOR LEAVING YOUR AREA' } else { systemChat 'YOU HAVE CLEARED THE UNAUTHORIZED ZONE' }; }; ", ""]; then the local one: Spoiler _trg = createTrigger ["EmptyDetector",getpos thisTrigger,false]; _trg setTriggerArea [50, 50, 0, false]; _trg setTriggerActivation ["ANYPLAYER", "PRESENT",FALSE]; _trg setTriggerStatements ["thisList findIf {local _x} >-1", " 0 = thisTrigger spawn { _triggerActivated = _this; systemChat 'RETURN TO YOUR ASSIGNED AREA IMMEDIATELY!'; playSoundWarning = true; hint str (count (getpos _triggeractivated nearObjects ['emptydetector',20])); cutText ['YOU HAVE 7 SECONDS TO LEAVE THIS AREA', 'plain', 0]; titleFadeout 5; sleep 7; if (player inArea _triggerActivated) then { player setDamage 1; systemChat 'YOU HAVE BEEN KILLED FOR LEAVING YOUR AREA' } else { systemChat 'YOU HAVE CLEARED THE UNAUTHORIZED ZONE' }; }; ", ""]; As you can see, the result is the same of the aim, but the trigger's count (locally) is absolutely not the same (one trigger for each connected players in case of global syntax). It's useless. Share this post Link to post Share on other sites
Larrow 2821 Posted December 16, 2019 5 hours ago, pierremgi said: doesn't need to attach a trigger Not attaching a trigger to anything. 5 hours ago, pierremgi said: a not server only and global one (scripted or edited) will "stack" triggers locally No, an editor trigger that is made to do different things on each client is not going to stack. One trigger, different settings per client. I also didn't say anything about creating a global trigger from init Player. Place a trigger in the editor, set its position and size. On mission load for each client (initPlayer) attach the clients player to the trigger, this player will activate it. One trigger, globally, made to do different things on each client. Same outcome just visually simpler to setup. TEST Share this post Link to post Share on other sites
pierremgi 4881 Posted December 16, 2019 Roger for your method. A little bit complicated, imho. - If you're speaking about editor, precise that you can't link several players to a single trigger if these players don't belong to the same group. - If you're speaking about using a trigger in editor then modifying the "set trigger owner" (editor term) by _trg triggerAttachVehicle[ player ] in initPlayerLocal.sqf, then all the stuff to make it work , it's just a mix of edited/scripted trigger... Well, I'd rather create a complete trigger locally (local syntax), in initPlayerLocal.sqf. Less visible in editor, more consistent in script. Anyway, it's fine to add an handle in on act. field and terminate the code on deact. Share this post Link to post Share on other sites
Larrow 2821 Posted December 17, 2019 22 hours ago, pierremgi said: A little bit complicated, imho. it's just a mix of edited/scripted trigger Well, I'd rather create a complete trigger locally (local syntax), in initPlayerLocal.sqf. Less visible in editor, more consistent in script. Well that was the whole point, a easier visual setup for those who do not script. No questions of, where do i set the location. Where do I set its size/area etc. Just a straight forward place an area trigger visually in the editor and set its area. Then add this code just replacing the name of the trigger, no other scripting knowledge needed. Share this post Link to post Share on other sites
mrcurry 499 Posted December 17, 2019 An alternate solution for those that want dabble as little as possible in script files and only use the editor: 1. Set the trigger to detect "Any", "present" 2. Use condition: vehicle player in thisList Since player refers to a different object on each client and trigger conditions are evaluated locally there's no need to mess about with script files if you don't want to. If you have a lot of these triggers might be better perf-wise to use "Any player" instead. Haven't investigated if that's viable or indeed better. But then again if you have that many triggers... What the heck are you doing!? 1 Share this post Link to post Share on other sites