wendaf 21 Posted February 23, 2019 Hi, I am currently trying to find a way to check if local player is function caller in sqf file. I have civilian with addAction, which calls this script: _caller = _this select 2; if (local player == _caller) then { _handle = createdialog "Interaction"; } I need to show the GUI only to player using the action. Sorry if it's somewhere on these forums, but I was unable to find it. Thanks for your answers 🙂 WendAF Share this post Link to post Share on other sites
Mr H. 402 Posted February 23, 2019 If the function is called locally (via the add action it's the case by default) you don't need to worry about it, the rest will only show locally too. 1 Share this post Link to post Share on other sites
wendaf 21 Posted February 23, 2019 That's not my case. I have NPC with this addAction .... that launches small GUI. Unfortunately, the GUI is shown to all players, not the one who called it. I'm trying to solve that problem but having issues. Either the Interact action doesn't show up on dedicated server or GUI shows to all players. I have a suspicion that it shows it to everyone because GUI command is launched on server for everyone. (I'm beginner in scripting, so that assumption might be entirely wrong) Share this post Link to post Share on other sites
Mr H. 402 Posted February 23, 2019 That's possible yes, you should paste the whole code here if you want more help. 1 Share this post Link to post Share on other sites
wendaf 21 Posted February 23, 2019 This is in init of the NPC _entityName = "Alexander"; this setName _entityName; _actionID = this addAction ["Interact", "script.sqf", _entityName, 5, true, true, "", "player distance this < 2"]; This is script.sqf DialogOwner = _this select 3; DialogOption = 1; if (local player == _this select 2) then { _handle = createdialog "Interakce"; } This is dialogManager.sqf _DialogText = [DialogOwner, DialogOption] call compile preprocessFileLineNumbers "getText.sqf"; [ [DialogOwner, _DialogText ,0] ] spawn BIS_fnc_EXP_camp_playSubtitles; getText.sqf is just a simple switch variables DialogOwner and DialogOption are storled at initPlayerLocal.sqf Share this post Link to post Share on other sites
Mr H. 402 Posted February 23, 2019 " Local player " does not make sense. "variables DialogOwner and DialogOption are storled at initPlayerLocal.sqf" does not make sense either since they are defined in your script.sqf Nothing here explains the remote execution, can you also provide the getText.sqf ? Share this post Link to post Share on other sites
wendaf 21 Posted February 23, 2019 I know now that local player returns boolean. The DialogOwner and DialogOption are in intiPlayerLocal.sqf but are given new values in that script. getText is just a simple switch: params ["_speaker", "_option"]; _outputText = ""; switch (_speaker) do { case "Journalist": { switch (_option) do { case 1: { _outputText = "I am standing here"; }; case 2: { _outputText = "Noting happened here"; }; case 3: { _outputText = "I don't need help"; }; default { _outputText = "Que?"; }; }; }; case "Alexander": { switch (_option) do { case 1: { _outputText = "I am curing that guy"; }; case 2: { _outputText = "He got hit by shrapnel"; }; case 3: { _outputText = "If you have some bandages to spare, that would be lovely"; }; default { _outputText = "Que?"; }; }; }; case "Rebel": { switch (_option) do { case 1: { _outputText = "Fighting for the motherland"; }; case 2: { _outputText = "Nothing"; }; case 3: { _outputText = "Come help fight with us"; }; default { _outputText = "Que?"; }; }; }; default { _outputText = "... Silence ..."; }; }; I can upload the mission somewhere, if you want to check the whole thing. There's also framework, but that shouldn't influence the script in any way. Share this post Link to post Share on other sites
Mr H. 402 Posted February 23, 2019 Maybe in the event handlers of the ui itself? I don't see anything here that would explain the global MP execution. Share this post Link to post Share on other sites
wendaf 21 Posted February 23, 2019 Here is the mission: https://drive.google.com/file/d/14OXVOLvl6jqO7wydEmY0R794bLxnn0PQ/view?usp=sharing It's just a simple VR setup to test all the things. It will throw zeus-related error when tested on local server, but that's ok. Everythins's there and it's easier to see it 🙂 Share this post Link to post Share on other sites
Dedmen 2696 Posted February 26, 2019 On 2/23/2019 at 5:55 PM, wendaf said: I am currently trying to find a way to check if local player is function caller in sqf file. Easy. Answer is: "true". Scripts are always executed locally, and if there is a player, then it's executed on that players machine. On 2/23/2019 at 6:44 PM, wendaf said: Unfortunately, the GUI is shown to all players Then you are remoteExecuting something somewhere. On 2/23/2019 at 6:44 PM, wendaf said: I have a suspicion that it shows it to everyone because GUI command is launched on server for everyone. no. On 2/23/2019 at 9:12 PM, wendaf said: if (local player == _this select 2) then { Doesn't make sense, player is always local, meaning local will return true. And you cannot compare a boolean using == so this is a script error. On 2/23/2019 at 9:12 PM, wendaf said: "player distance this < 2" What? Why not just use the radius parameter of addAction? Can't find any cause for remoteExecution in your mission. But considering your script that shows the dialog is broken and shouldn't work at all, I wonder why it even opens a dialog. 2 Share this post Link to post Share on other sites
wendaf 21 Posted February 26, 2019 I have absolutely no clue, what is wrong and what is causing the execution Share this post Link to post Share on other sites
Mr H. 402 Posted February 26, 2019 _actionID = this addAction ["Interact", "script.sqf", [_entityName,player], 5, true, true, "", "player distance this < 2"]; and in your script.sqf params ["_dialogowner","_caller"]; if (player != _caller) exitWith {}; DialogOwner = _dialogowner; DialogOption = 1; _handle = createdialog "Interakce"; should solve your issue, but is messy and unnecessary, you should rework your script from the start. Share this post Link to post Share on other sites
HazJ 1289 Posted February 26, 2019 https://community.bistudio.com/wiki/local This returns BOOL so why check it against an OBJECT? As Dedmen said. player addAction ["Open Interaction Menu", { createDialog "Interaction"; }]; No need for local as explained by Dedmen above. This should create dialog for only the person not everyone. Share this post Link to post Share on other sites
wendaf 21 Posted March 8, 2019 None of it works but thanks anyway Share this post Link to post Share on other sites