AdirB 18 Posted August 27, 2015 Hello, I've been trying to do if and else but the script is probably wrong. Please someone can help me and tell what's wrong? waituntil {!(IsNull (findDisplay 46)) _keyDown = (findDisplay 46) displayAddEventHandler [ "KeyDown", " if (_this select 1 == 199) then { if (typeOf player isEqualTo 'B_RangeMaster_F') then { _open = player execVM 'dialogs\open_tablet_dialog.sqf'; } else { _open = player execVM 'dialogs\open_teleport_dialog.sqf'; }; }; " ]; Share this post Link to post Share on other sites
Greenfist 1863 Posted August 27, 2015 You're missing a bracket and a semicolon at the end of the first line. Share this post Link to post Share on other sites
AdirB 18 Posted August 27, 2015 You're missing a bracket and a semicolon at the end of the first line. first things first, thank you for the answer. I've did what you said about the first line, and it become like this: waituntil {!(IsNull (findDisplay 46))}; But the code's still not working. :/ Share this post Link to post Share on other sites
Ranwer135 308 Posted August 28, 2015 waituntil {!(IsNull (findDisplay 46)); _keyDown = (findDisplay 46) displayAddEventHandler ["KeyDown", { if (_this select 1 == 199) then { if (typeOf player == "B_RangeMaster_F") then { _open = player execVM "dialogs\open_tablet_dialog.sqf"; } else { _open = player execVM "dialogs\open_teleport_dialog.sqf"; }; }; }; ]; You seriously need to look at my introduction at the very top of this section. -_-Rule of thumb, "" is used to define a script path, whereas {} is used for raw code to be put in. Also, if it still doesn't work, change "_this select 1" to "_this select 0". (I am unsure as I am not on PC right now, but that code I fixed up will work indefinitely) Share this post Link to post Share on other sites
jshock 513 Posted August 28, 2015 waituntil {!(IsNull (findDisplay 46)); _keyDown = (findDisplay 46) displayAddEventHandler ["KeyDown", { if (_this select 1 == 199) then { if (typeOf player == "B_RangeMaster_F") then { _open = player execVM "dialogs\open_tablet_dialog.sqf"; } else { _open = player execVM "dialogs\open_teleport_dialog.sqf"; }; }; }; ]; You seriously need to look at my introduction at the very top of this section. -_-Rule of thumb, "" is used to define a script path, whereas {} is used for raw code to be put in. Also, if it still doesn't work, change "_this select 1" to "_this select 0". (I am unsure as I am not on PC right now, but that code I fixed up will work indefinitely) " " work just as good as { }, sure { } are easier to work with, but something else isn't working here, and changing _this select 1 would break it further. What do your two scripts look like? 1 Share this post Link to post Share on other sites
SilentSpike 84 Posted August 28, 2015 Strings can be quicker than code in some cases ;) Share this post Link to post Share on other sites
dreadedentity 278 Posted August 28, 2015 not working. I'll never understand how people think saying this and providing literally no details will get them a solution faster. This works 100% perfectly fine for me: waituntil {!(isNull (findDisplay 46))}; _keyDown = (findDisplay 46) displayAddEventHandler [ "KeyDown", " systemChat str _this; if (_this select 1 == 199) then { if ((typeOf player) isEqualTo 'B_RangeMaster_F') then { _open = player execVM 'dialogs\open_tablet_dialog.sqf'; } else { _open = player execVM 'dialogs\open_teleport_dialog.sqf'; }; }; " ]; I don't think there's an issue here. Also, -showScriptErrors @Ranwer you're not wrong, but originally displayAddEventHandler did not work if using a code variable type (in fact, in OFP that data type didn't even exist), you could only input a code string. That code will work just fine when using quotation marks, as long as one keeps in their mind the rules of nesting quotation marks in sqf. Frankly, I find it appalling that you can write something so condescending without even taking that bit of history into account. Also, when working with UI event handlers (_this select 0) will always return the display or the control. As somebody working on such a dialog-heavy mod you should've known that Share this post Link to post Share on other sites
Ranwer135 308 Posted August 28, 2015 @Ranwer you're not wrong, but originally displayAddEventHandler did not work if using a code variable type (in fact, in OFP that data type didn't even exist), you could only input a code string. That code will work just fine when using quotation marks, as long as one keeps in their mind the rules of nesting quotation marks in sqf. Frankly, I find it appalling that you can write something so condescending without even taking that bit of history into account. Also, when working with UI event handlers (_this select 0) will always return the display or the control. As somebody working on such a dialog-heavy mod you should've known that Hi,Yeah, sorry if I hadn't provided that type of information, OFP wasn't my first game but Arma 2. I also did not know that you could use string as code (No wonder RscPicture's text can be used to change the colour or even define a custom ".paa" file). But again, I didn't know this could be possible as there wasn't much information on the biki at that time. With regards to "_this select 0", I was well aware about that but I had work to do. So I wasn't able to verify my answer at the time of replying. Share this post Link to post Share on other sites
AdirB 18 Posted August 28, 2015 waituntil {!(IsNull (findDisplay 46)); _keyDown = (findDisplay 46) displayAddEventHandler ["KeyDown", { if (_this select 1 == 199) then { if (typeOf player == "B_RangeMaster_F") then { _open = player execVM "dialogs\open_tablet_dialog.sqf"; } else { _open = player execVM "dialogs\open_teleport_dialog.sqf"; }; }; }; ]; You seriously need to look at my introduction at the very top of this section. -_-Rule of thumb, "" is used to define a script path, whereas {} is used for raw code to be put in. Also, if it still doesn't work, change "_this select 1" to "_this select 0". (I am unsure as I am not on PC right now, but that code I fixed up will work indefinitely) " " work just as good as { }, sure { } are easier to work with, but something else isn't working here, and changing _this select 1 would break it further. What do your two scripts look like? I'll never understand how people think saying this and providing literally no details will get them a solution faster. This works 100% perfectly fine for me: waituntil {!(isNull (findDisplay 46))}; _keyDown = (findDisplay 46) displayAddEventHandler [ "KeyDown", " systemChat str _this; if (_this select 1 == 199) then { if ((typeOf player) isEqualTo 'B_RangeMaster_F') then { _open = player execVM 'dialogs\open_tablet_dialog.sqf'; } else { _open = player execVM 'dialogs\open_teleport_dialog.sqf'; }; }; " ]; I don't think there's an issue here. Also, -showScriptErrors @Ranwer you're not wrong, but originally displayAddEventHandler did not work if using a code variable type (in fact, in OFP that data type didn't even exist), you could only input a code string. That code will work just fine when using quotation marks, as long as one keeps in their mind the rules of nesting quotation marks in sqf. Frankly, I find it appalling that you can write something so condescending without even taking that bit of history into account. Also, when working with UI event handlers (_this select 0) will always return the display or the control. As somebody working on such a dialog-heavy mod you should've known that Thank you all for the answer, you've been very helpful! Just one last thing, I want to make the condition - if B_RangeMaster_F or B_medic_F press the button then it will run one dialog but if not it will run other dialog. I tried to do this like this: if ((typeOf player) isEqualTo 'B_RangeMaster_F' || 'B_medic_F') then I believe that is the reason of the script that didn't work. Share this post Link to post Share on other sites
Greenfist 1863 Posted August 28, 2015 if ((typeOf player) in ['B_RangeMaster_F' , 'B_medic_F'] then or if ((typeOf player) isEqualTo 'B_RangeMaster_F' || (typeOf player) isEqualTo 'B_medic_F') then Share this post Link to post Share on other sites
AdirB 18 Posted August 28, 2015 if ((typeOf player) in ['B_RangeMaster_F' , 'B_medic_F'] then or if ((typeOf player) isEqualTo 'B_RangeMaster_F' || (typeOf player) isEqualTo 'B_medic_F') then Thank you! ^_^ You all have been very helpful, thank you! Share this post Link to post Share on other sites