AdirB 18 Posted August 25, 2015 Hello guys, I made a script and I want to make it only a specific unit can run that script. The script is: waituntil {!(IsNull (findDisplay 46))}; _keyDown = (findDisplay 46) displayAddEventHandler ["KeyDown", "if (_this select 1 == 199) then {_open = player execVM 'dialogs\open_tablet_dialog.sqf'}"]; I've tried to do this but without success. Please can you help me to do that? Share this post Link to post Share on other sites
jshock 513 Posted August 25, 2015 Expand on "specific" unit. Share this post Link to post Share on other sites
AdirB 18 Posted August 25, 2015 Expand on "specific" unit. Sorry my English is not so good. for exmaple: while soldier1 is pressing the key he will run the open_tablet_dialog.sqf. but if soldier2 is pressing the same key he will run another sqf. Share this post Link to post Share on other sites
jshock 513 Posted August 25, 2015 How exactly to you have the unit's separated, as in do you have them named in the editor, are you looking for a specific player ID, etc. If the unit's are named in the editor: if (player isEqualTo solider1) then { waituntil {!(IsNull (findDisplay 46))}; _keyDown = (findDisplay 46) displayAddEventHandler ["KeyDown", "if (_this select 1 == 199) then {_open = player execVM 'dialogs\open_tablet_dialog.sqf'}"]; }; Share this post Link to post Share on other sites
davidoss 552 Posted August 25, 2015 Using classname instead of name if ((typeOf player) == "B_medic_F") then { waituntil {!(IsNull (findDisplay 46))}; _keyDown = (findDisplay 46) displayAddEventHandler ["KeyDown", "if (_this select 1 == 199) then {_open = player execVM 'dialogs\open_tablet_dialog.sqf'}"]; }; Share this post Link to post Share on other sites
AdirB 18 Posted August 26, 2015 Using classname instead of name if ((typeOf player) == "B_medic_F") then { waituntil {!(IsNull (findDisplay 46))}; _keyDown = (findDisplay 46) displayAddEventHandler ["KeyDown", "if (_this select 1 == 199) then {_open = player execVM 'dialogs\open_tablet_dialog.sqf'}"]; }; If I want to run it with "Else", is that the right way? if ((typeOf player) == "B_RangeMaster_F") then { waituntil {!(IsNull (findDisplay 46)) }; _keyDown = (findDisplay 46) displayAddEventHandler ["KeyDown", "if (_this select 1 == 199) 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
jshock 513 Posted August 26, 2015 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 { //execute some other script }; }; " ]; Something more like this is I believe what you want. Share this post Link to post Share on other sites
AdirB 18 Posted August 26, 2015 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 { //execute some other script }; }; " ]; Something more like this is I believe what you want. Thank you, and sorry for desturbing you so much, but the code isn't working. I've tried to do some OR operator and it's failed and then I tried you're original code but it didn't work. I don't know what's wrong. :unsure: Share this post Link to post Share on other sites
Joe98 92 Posted August 27, 2015 If you have 6 soldiers on the map then place 6 triggers on the map. Each trigger covers the whole map. Each of the 6 soldiers are named Blue1 through to Blue 6 Each of the triggers have a requirement the "Blue1 is present" or Blue2 is present or what ever it might be Then by firing a trigger, each of the 6 will be able to run each of 6 individual scripts. . Share this post Link to post Share on other sites
AdirB 18 Posted August 27, 2015 If you have 6 soldiers on the map then place 6 triggers on the map. Each trigger covers the whole map. Each of the 6 soldiers are named Blue1 through to Blue 6 Each of the triggers have a requirement the "Blue1 is present" or Blue2 is present or what ever it might be Then by firing a trigger, each of the 6 will be able to run each of 6 individual scripts. . I prefer to do this with a script without triggers like you said. There's no way to do that this way? Share this post Link to post Share on other sites
jshock 513 Posted August 27, 2015 Thank you, and sorry for desturbing you so much, but the code isn't working. I've tried to do some OR operator and it's failed and then I tried you're original code but it didn't work. I don't know what's wrong. :unsure: Sorry for not being on to answer back soon enough, but seeing how you already started another thread and got the answer: https://forums.bistudio.com/topic/184371-if-else/ That was a copy/paste error on me, but for future reference, turn on the "showScriptErrors" startup parameters. Share this post Link to post Share on other sites
AdirB 18 Posted August 27, 2015 Sorry for not being on to answer back soon enough, but seeing how you already started another thread and got the answer: https://forums.bistudio.com/topic/184371-if-else/ That was a copy/paste error on me, but for future reference, turn on the "showScriptErrors" startup parameters. Thank you for the answer. I've tried the solution he suggested me on the other thread, but it didn't work. Thank you for the tool of checking the script errors! I'll leave this thread because I don't want to use two threads for the same subject. I would be happy if you may try to help me there. Share this post Link to post Share on other sites