cruoriss 12 Posted February 2, 2015 Hey, So i'm trying to get a unit to join the player entering a trigger . Here's the part of the code i'm stuck with : _trig setTriggerStatements ["({isPlayer _x} count thisList) > 0","TE1 stop false; [TE1] join (group (thisList select 0))",""]; It works fine on singleplayer but the activation part is broken ( unit start moving but doesn't join player group ) on dedicated server . The trigger was created inside a file called with bis_fnc_mp, so everyting is server side . I guess it's due to the locality of triggers but aside from creating the trigger on each machine i'm out of idea . Thanks Share this post Link to post Share on other sites
fight9 14 Posted February 2, 2015 Triggers are global objects but the settings of it are local. You want to create the trigger on the Server ONLY. But then create the statement for it on the client. OR, set the statements on the server, but run the code from it on the client via BIS_fnc_MP. Share this post Link to post Share on other sites
jshock 513 Posted February 2, 2015 settings of it are local The arguments are global, but the effects there after are local. Share this post Link to post Share on other sites
fight9 14 Posted February 2, 2015 (edited) The arguments are global, but the effects there after are local. You can only set trigger statements locally. You can have the same trigger testing something different on every client. Per the wiki, the effects of setTriggerStatements are LOCAL, meaning those statements are only set locally. EDIT: To further prove my point, all of the trigger commands are listed under CfgRemoteExecCommands for use with BIS_fnc_MP. Edited February 2, 2015 by Fight9 Share this post Link to post Share on other sites
cruoriss 12 Posted February 2, 2015 I understood that statements can be set for each client but what i'm asking is why this specific part doesn't work on dedicated ( all the rest of the code is doing fine ) : [TE1] join (group (thisList select 0)) And if there is a workaround to it . Share this post Link to post Share on other sites
fight9 14 Posted February 2, 2015 (edited) Yeah, I was just looking at that. Join is a global command and your syntax looks correct. I'm not sure. Try the joinAs command to see if we can troubleshoot the problem with Join. Try figuring out what thisList select 0 returns on the dedicated. Maybe its not the player unit you are trying to use in group. Not sure what else it could be though... What do you have for setTriggerActivation? Edited February 2, 2015 by Fight9 Share this post Link to post Share on other sites
cruoriss 12 Posted February 2, 2015 Yeah, I was just looking at that. Join is a global command and your syntax looks correct. I'm not sure. Try the joinAs command to see if we can troubleshoot the problem with Join. Try figuring out what thisList select 0 returns on the dedicated. Maybe its not the player unit you are trying to use in group. Not sure what else it could be though... What do you have for setTriggerActivation? I tried with joinAs and got the same result : working on singleplayer, broken in dedicated . Here's the activation : _trig setTriggerActivation ["ANY","PRESENT",false]; Share this post Link to post Share on other sites
jshock 513 Posted February 2, 2015 For your trigger condition try: this && ({isPlayer _x} count thisList > 0) Share this post Link to post Share on other sites
cruoriss 12 Posted February 2, 2015 For your trigger condition try: this && ({isPlayer _x} count thisList > 0) The condition is not the problem as the "stop false" in activation works on dedicated too . Share this post Link to post Share on other sites
jshock 513 Posted February 2, 2015 Ok, well try what Fight said above, in your onAct put the following, and see what it says: hintSilent str(thisList select 0); Share this post Link to post Share on other sites
cruoriss 12 Posted February 2, 2015 (edited) In sp it returns my unit name but in dedicated that's what it returns : C Alpha 1-1:1 :confused: EDIT : I tried with another unit after jip and it returned this instead : C Alpha 1-1:3 Any idea ? Edited February 2, 2015 by Cruoriss Share this post Link to post Share on other sites
fight9 14 Posted February 2, 2015 I don't know the answer to this one. Hopefully some one else can shed some light on. One solution I can think of is setting the statements locally for each client, where player is defined, and then deleting the trigger afterwards. Share this post Link to post Share on other sites
jshock 513 Posted February 2, 2015 I'm thinking just add an action to the unit you want to join the group. Share this post Link to post Share on other sites
cruoriss 12 Posted February 2, 2015 I'm thinking just add an action to the unit you want to join the group. Forgot about that ... i'll definietly go for it then . Thanks But should i report my problem on the feedback tracker ? Or it's a locality/mp "normal" issue ? Share this post Link to post Share on other sites
jshock 513 Posted February 2, 2015 Not really sure what it could be, locality would be first guess, second guess is that "thisList" is returning more than just the player. Share this post Link to post Share on other sites
Heeeere's johnny! 51 Posted February 2, 2015 (edited) Just to point out some (more or less) obvious things here: It's recommended to create a trigger only serverside to avoid problems related to the creation. (Dunno where I read it though) Secondly, thisList contains the list of units activating the trigger which is NOT the same as units just entering the trigger area. That means if e.g. if the trigger waits for BLUFORs to be present and both the player and the unit in the trigger area are BLUFOR, it's quiet likely possible that (thisList select 0) is not the player. So maybe your solution just works "coincidently". Correct me if I'm wrong, but I see two possibilities here: 1) In the trigger condition, put an iteration over thisList and check if (group _x == group _unit) and if that is false, it's probably a player just entering the trigger area. 2) You use the following trigger (adjust the values as preferred) for properly managing whatever you want to do with any unit entering/leaving the trigger area: Be aware that in MP the condition here only works on the server due to the "isServer"! [color=#FF8040]fnc_triggerUnitsChanged [color=#8B3E2F][b]=[/b][/color] [color=#8B3E2F][b]{[/b][/color] [color=#1874CD]_thisList[/color] [color=#8B3E2F][b]=[/b][/color] [color=#000000]_this[/color] [color=#191970][b]select[/b][/color] [color=#FF0000]0[/color][color=#8B3E2F][b];[/b][/color] [color=#1874CD]_thisListPrev[/color] [color=#8B3E2F][b]=[/b][/color] [color=#000000]_this[/color] [color=#191970][b]select[/b][/color] [color=#FF0000]1[/color][color=#8B3E2F][b];[/b][/color] [color=#8B3E2F][b]{[/b][/color] [color=#006400][i]//for each entering unit[/i][/color] TE1 [color=#191970][b]stop[/b][/color] [color=#000000]false[/color][color=#8B3E2F][b];[/b][/color] [color=#8B3E2F][b][[/b][/color]TE1[color=#8B3E2F][b]][/b][/color] [color=#191970][b]join[/b][/color] [color=#000000]_x[/color][color=#8B3E2F][b];[/b][/color] [color=#8B3E2F][b]}[/b][/color] [color=#191970][b]forEach[/b][/color] [color=#8B3E2F][b]([/b][/color][color=#1874CD]_thisList[/color] [color=#8B3E2F][b]-[/b][/color] [color=#1874CD]_thisListPrev[/color][color=#8B3E2F][b])[/b][/color][color=#8B3E2F][b];[/b][/color][color=#8B3E2F][/color] [color=#8B3E2F][b]}[/b][/color][color=#8B3E2F][b];[/b][/color] [color=#1874CD]_trig[/color] [color=#8B3E2F][b]=[/b][/color] [color=#191970][b]createTrigger[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#7A7A7A]"EmptyDetector"[/color][color=#8B3E2F][b],[/b][/color] [color=#191970][b]getPosATL[/b][/color] [color=#000000]player[/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b];[/b][/color] [color=#1874CD]_trig[/color] [color=#191970][b]setTriggerArea[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#FF0000]10[/color][color=#8B3E2F][b],[/b][/color] [color=#FF0000]10[/color][color=#8B3E2F][b],[/b][/color] [color=#FF0000]0[/color][color=#8B3E2F][b],[/b][/color] [color=#000000]false[/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b];[/b][/color] [color=#1874CD]_trig[/color] [color=#191970][b]setTriggerActivation[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#7A7A7A]"ANY"[/color][color=#8B3E2F][b],[/b][/color] [color=#7A7A7A]"PRESENT"[/color][color=#8B3E2F][b],[/b][/color] [color=#000000]true[/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b];[/b][/color] [color=#1874CD]_trig[/color] [color=#191970][b]setTriggerStatements[/b][/color] [color=#8B3E2F][b][[/b][/color] [color=#7A7A7A]" isServer && { thisTrigger setVariable ['thisListPrev', +(thisTrigger getVariable ['thisList', []])]; thisTrigger setVariable ['thisList', +thisList]; if( !(thisList - (thisTrigger getVariable ['thisListPrev', []]) isEqualTo []) || !((thisTrigger getVariable ['thisListPrev', []]) - thisList isEqualTo []) ) then { thisTrigger setVariable ['toggle', !(thisTrigger getVariable ['toggle', false])]; }; true } && {thisTrigger getVariable ['toggle', true]} "[/color][color=#8B3E2F][b],[/b][/color] [color=#7A7A7A]" [thisList, thisTrigger getVariable 'thisListPrev'] call fnc_triggerUnitsChanged; hintSilent 'toggle\nactivation'; "[/color][color=#8B3E2F][b],[/b][/color] [color=#7A7A7A]" hintSilent 'toggle\ndeactivation'; "[/color] [color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b];[/b][/color] [/color] Kudos to Killzone_Kid for his SQF to BBCode Converter. Edited February 2, 2015 by Heeeere's Johnny! Share this post Link to post Share on other sites
shuko 59 Posted February 3, 2015 If the goal is to make a unit join a player group once the player is in a trigger/close enough to the unit. Then, I would approach this a little different, and not try to work with the trigger's thislist at all. Instead, I would simply check which player is the closest to the unit once the trigger fires. To ensure that the player will the correct one, make the trigger small enough. Function: [color="#FF8040"][color="#006400"][i]// SHK_closestPlayer = compile preprocessfile "SHK_closestPlayer.sqf";[/i][/color] [color="#006400"][i]// obj1 call SHK_closestPlayer;[/i][/color] [color="#006400"][i]// [obj1,side] call SHK_closestPlayer;[/i][/color] [color="#191970"][b]private[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"_o"[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"_s"[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"_p"[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"_b"[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_o[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#000000"]_this[/color][color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_b[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#000000"]false[/color][color="#8B3E2F"][b];[/b][/color] [color="#191970"][b]if[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#191970"][b]typeName[/b][/color] [color="#1874CD"]_o[/color] [color="#8B3E2F"][b]=[/b][/color][color="#8B3E2F"][b]=[/b][/color] [color="#191970"][b]typeName[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b])[/b][/color] [color="#191970"][b]then[/b][/color] [color="#8B3E2F"][b]{[/b][/color] [color="#1874CD"]_s[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#1874CD"]_o[/color] [color="#191970"][b]select[/b][/color] [color="#FF0000"]1[/color][color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_o[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#1874CD"]_o[/color] [color="#191970"][b]select[/b][/color] [color="#FF0000"]0[/color][color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_b[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#000000"]true[/color][color="#8B3E2F"][b];[/b][/color] [color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_p[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#000000"]objNull[/color][color="#8B3E2F"][b];[/b][/color] [color="#8B3E2F"][b]{[/b][/color] [color="#191970"][b]if[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#191970"][b]alive[/b][/color] [color="#000000"]_x[/color] [color="#8B3E2F"][b]&[/b][/color][color="#8B3E2F"][b]&[/b][/color] [color="#191970"][b]isPlayer[/b][/color] [color="#000000"]_x[/color][color="#8B3E2F"][b])[/b][/color] [color="#191970"][b]then[/b][/color] [color="#8B3E2F"][b]{[/b][/color] [color="#191970"][b]if[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#000000"]_x[/color] [color="#191970"][b]distance[/b][/color] [color="#1874CD"]_o[/color] [color="#8B3E2F"][b]<[/b][/color] [color="#000000"]_x[/color] [color="#191970"][b]distance[/b][/color] [color="#1874CD"]_p[/color][color="#8B3E2F"][b])[/b][/color] [color="#191970"][b]then[/b][/color] [color="#8B3E2F"][b]{[/b][/color] [color="#191970"][b]if[/b][/color] [color="#1874CD"]_b[/color] [color="#191970"][b]then[/b][/color] [color="#8B3E2F"][b]{[/b][/color] [color="#191970"][b]if[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#191970"][b]side[/b][/color] [color="#000000"]_x[/color] [color="#8B3E2F"][b]=[/b][/color][color="#8B3E2F"][b]=[/b][/color] [color="#1874CD"]_s[/color][color="#8B3E2F"][b])[/b][/color] [color="#191970"][b]then[/b][/color] [color="#8B3E2F"][b]{[/b][/color] [color="#1874CD"]_p[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#000000"]_x[/color][color="#8B3E2F"][b];[/b][/color] [color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#8B3E2F"][b]}[/b][/color] [color="#191970"][b]else[/b][/color] [color="#8B3E2F"][b]{[/b][/color] [color="#1874CD"]_p[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#000000"]_x[/color][color="#8B3E2F"][b];[/b][/color] [color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#8B3E2F"][b]}[/b][/color] [color="#191970"][b]forEach[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#191970"][b]if[/b][/color] [color="#191970"][b]isMultiplayer[/b][/color] [color="#191970"][b]then[/b][/color] [color="#8B3E2F"][b]{[/b][/color][color="#191970"][b]playableUnits[/b][/color][color="#8B3E2F"][b]}[/b][/color] [color="#191970"][b]else[/b][/color] [color="#8B3E2F"][b]{[/b][/color][color="#191970"][b]switchableUnits[/b][/color][color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b])[/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_p[/color][/color] Made with KK's SQF to BBCode Converter _trig setTriggerStatements ["({isPlayer _x} count thisList) > 0","TE1 stop false; [TE1] join (group (TE1 call SHK_closestPlayer))",""]; Share this post Link to post Share on other sites
cruoriss 12 Posted February 3, 2015 Thanks, perfect method Shuko . Jhonny i haven't tested yours but i think it will result in the same problem : _thisList used by sever doesn't return the real unit name but the default one . Share this post Link to post Share on other sites
Heeeere's johnny! 51 Posted February 3, 2015 Maybe I've overlooked something, but why do you need the "real unit name"? (What exactly do you mean by that anyways?) You want the unit to join the player group, right? So the unit is in thisList and you get it by simply selecting it using thisList select ... But if Shuko's method works, it's fine. Share this post Link to post Share on other sites
fight9 14 Posted February 3, 2015 That was the problem. The unit name that thisList returns on the server doesn't work with the group command (group needed for the join command). Share this post Link to post Share on other sites