Lockheed Martin 2 Posted May 3, 2021 Say you have a Dedicated Server: You would like to run a script which generates random triggers across the map activated by condition "play in thisList". You'd like to only run the script once however, so it doesn't keep generating more triggers for every single client JIP or at mission init. If I call the script in init.sqf like: Quote if (isServer) then { _scriptRandom = execVM "scripts\Random_Triggers.sqf"; waitUntil { scriptDone _scriptRandom }; }; It will generate the random triggers and only run the script once. However it is serverside, not Local/Global. Thus players do not activate the triggers! No success either even if I pass in player as a parameter when calling the .sqf. Would anyone know of a creative hack per say, to run a script only once when the server inits. But allow for its triggers to be accessed by all clients and JIPs? Thank you for your time. To be more specific, my init.sqf runs the script which generates my triggers. This is an example of one of the triggers conditions. Said conditions do not activate when a player is present on a dedicated server. Quote private _triggerRestricted = createTrigger ["EmptyDetector", [_posArea select 0, _posArea select 1, 0]]; _triggerRestricted setTriggerArea [200, 200, 200, false]; _triggerRestricted setTriggerActivation ["EAST", "PRESENT", true]; _triggerRestricted setTriggerStatements ["player in thisList", "[thisList] remoteExec ['execVM 'scripts\Restricted\Restricted_Area_Enter.sqf'', -2, true]", "remoteExec ['execVM 'scripts\Restricted\Restricted_Area_Exit'', -2, true]"]; Share this post Link to post Share on other sites
pierremgi 4739 Posted May 3, 2021 player has no sense for dedicated server. That can't work a server only trigger is easy to script... in initServer.sqf That doesn't mean a remote player (client) can't trigger it , just use "ANYPLAYER" "PRESENT" as preset condition. You can add conditions. a trigger is repeatable... or not . If repeatable, you can add a "cooldown" condition (timer). If you plan a deactivation code, that means REPEATABLE Don't remote execute (even by a correct code) an sqf. see remark here. (You don't need that anyway, creating something on server) in initServer.sqf private _triggerRestricted = createTrigger ["EmptyDetector", _posArea]; _triggerRestricted setTriggerArea [200, 200, 200, false]; _triggerRestricted setTriggerActivation ["ANYPLAYER", "PRESENT", TRUE]; _triggerRestricted setTriggerStatements ["thisList findIf {side _x == EAST} > -1", "[thisList] execVM 'scripts\Restricted\Restricted_Area_Enter.sqf' ", "execVM 'scripts\Restricted\Restricted_Area_Exit' "]; With a cooldown timer: private _triggerRestricted = createTrigger ["EmptyDetector", _posArea]; _triggerRestricted setTriggerArea [200, 200, 200, false]; _triggerRestricted setTriggerActivation ["ANYPLAYER", "PRESENT", TRUE]; _triggerRestricted setTriggerStatements ["thisList findIf {side _x == EAST} > -1 && isNil {thisTrigger getVariable 'trgTime'}", "[thisList] execVM 'scripts\Restricted\Restricted_Area_Enter.sqf'; thisTrigger setVariable ['trgTime',60]", "execVM 'scripts\Restricted\Restricted_Area_Exit'; thisTrigger spawn {sleep ( _this getVariable ['trgTime',0]); _this setVariable ['trgTime',nil]} "]; Here 60 seconds since the trigger is deactivated. 1 Share this post Link to post Share on other sites
Lockheed Martin 2 Posted May 3, 2021 54 minutes ago, pierremgi said: player has no sense for dedicated server. That can't work a server only trigger is easy to script... in initServer.sqf That doesn't mean a remote player (client) can't trigger it , just use "ANYPLAYER" "PRESENT" as preset condition. You can add conditions. a trigger is repeatable... or not . If repeatable, you can add a "cooldown" condition (timer). If you plan a deactivation code, that means REPEATABLE Don't remote execute (even by a correct code) an sqf. see remark here. (You don't need that anyway, creating something on server) in initServer.sqf private _triggerRestricted = createTrigger ["EmptyDetector", _posArea]; _triggerRestricted setTriggerArea [200, 200, 200, false]; _triggerRestricted setTriggerActivation ["ANYPLAYER", "PRESENT", TRUE]; _triggerRestricted setTriggerStatements ["thisList findIf {side _x == EAST} > -1", "[thisList] execVM 'scripts\Restricted\Restricted_Area_Enter.sqf' ", "execVM 'scripts\Restricted\Restricted_Area_Exit' "]; With a cooldown timer: private _triggerRestricted = createTrigger ["EmptyDetector", _posArea]; _triggerRestricted setTriggerArea [200, 200, 200, false]; _triggerRestricted setTriggerActivation ["ANYPLAYER", "PRESENT", TRUE]; _triggerRestricted setTriggerStatements ["thisList findIf {side _x == EAST} > -1 && isNil {thisTrigger getVariable 'trgTime'}", "[thisList] execVM 'scripts\Restricted\Restricted_Area_Enter.sqf'; thisTrigger setVariable ['trgTime',60]", "execVM 'scripts\Restricted\Restricted_Area_Exit'; thisTrigger spawn {sleep ( _this getVariable ['trgTime',0]); _this setVariable ['trgTime',nil]} "]; Here 60 seconds since the trigger is deactivated. So what Ive done is in my initServer.sqf I have called my random trigger script: Quote _scriptTriggers = execVM "scripts\Random\Trigger_Spawn.sqf"; waitUntil { scriptDone _scriptTriggers }; Then in Trigger_Spawn.sqf I create this trigger: Quote private _triggerRestricted = createTrigger ["EmptyDetector", _posArea]; _triggerRestricted setTriggerArea [200, 200, 200, false]; _triggerRestricted setTriggerActivation ["ANYPLAYER", "PRESENT", TRUE]; _triggerRestricted setTriggerStatements ["thisList findIf {side _x == EAST} > -1", "[thisList] execVM 'scripts\Restricted\Restricted_Area_Enter.sqf' ", "[] execVM 'scripts\Restricted\Restricted_Area_Exit'.sqf "]; Upon entering the trigger, nothing occurs. I have even tried doing: Quote _triggerRestricted setTriggerStatements ["thisList findIf {side _x == EAST} > -1", "systemChat 'Test'; _x sideChat 'Test Direct' ", "systemChat 'Test Exit'; _x sideChat 'Test Direct Exit'"]; I have also tried moving the code where I make the trigger, into initServer and still it does not execute when a player enters. If I do not call this trigger creation in initServer or do not use a isServer check, it will work. However it will then make triggers for both server and local, meaning one trigger will activate when a player enters, the other wont. Problem is when a player JIP the prior local created trigger will not work. Thus I feel using isServer keeps the trigger on the server side, thus clients are unable to activate it as the code hasnt been executed locally. Is there anyway to create a trigger, then make it global so when a JIP or player who is there from the start enters said trigger, it activates? All without having to call said trigger creation script every time they join, thus avoiding generating countless random triggers. Appreciate your help with this. Share this post Link to post Share on other sites
pierremgi 4739 Posted May 3, 2021 are you sure _posArea is defined just before you create your trigger? That doesn't seem to be OK. So your trigger is at [0,0,0] imho. Also a typo on deact code: [] execVM 'scripts\Restricted\Restricted_Area_Exit'.sqf read: [] execVM 'scripts\Restricted\Restricted_Area_Exit.sqf' Share this post Link to post Share on other sites
Lockheed Martin 2 Posted May 4, 2021 11 hours ago, pierremgi said: are you sure _posArea is defined just before you create your trigger? That doesn't seem to be OK. So your trigger is at [0,0,0] imho. Also a typo on deact code: [] execVM 'scripts\Restricted\Restricted_Area_Exit'.sqf read: [] execVM 'scripts\Restricted\Restricted_Area_Exit.sqf' Oh yeah don't worry not the issue. The _posArea is just a fake variable name to use an example in this post. The ' error was just a badcase of typing this out here, all good no syntax errors causing a malfunction in the script :) 1 Share this post Link to post Share on other sites