Home   Help Search Login Register  

Author Topic: DisableUserInput  (Read 2327 times)

0 Members and 4 Guests are viewing this topic.

DisableUserInput
« on: 13 Jan 2009, 12:24:38 »
Is there a better way to stop the player from performing actions while a script is running?

I've attached a repair script/demo mission which grants any unit the ability to repair suitable vehicles in range, but the trouble is, while you're performing the repair, you can still "Place Satchel Charge", "Get In As..." and all the other actions that normally appear.
Doing so doesn't stop the repair script from finishing, it just looks dumb if you get your Bins out or Get In the vehicle... while you're still repairing it.  :banghead:

What I'm after, is a way to stop the player from doing anything else while the script is running. I've tried locking the vehicle at the start of repairs and then returning it to whatever state it was in previously and that's fixed part of the issue (you can't get in untill repairs are complete), but it doesn't help with the "other" actions that are availble during the repair cycle.

DisableUserInput seems too extreme, and I'm not sure what the implications are using it in MP.

Any help, comments, or feedback would be appreciated.  :good:
There are 10 types of people in the world. Those who understand binary, and those who don't

Offline i0n0s

  • Former Staff
  • ****
Re: DisableUserInput
« Reply #1 on: 13 Jan 2009, 14:47:48 »
You can open a dialog. But this is the same extreme as DisableUserInput.

Offline mikey

  • Former Staff
  • ****
  • Whitespace Whore
Re: DisableUserInput
« Reply #2 on: 13 Jan 2009, 15:33:14 »
I've actually made a quite similar repair script, and in that I used the medic heal animation to freeze "some" user input for a while.

I've attached it so you can have a look at it.

edit: nevermind, I saw that you actually did the same in your script, silly me  :whistle:

« Last Edit: 13 Jan 2009, 15:38:23 by mikey »

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: DisableUserInput
« Reply #3 on: 13 Jan 2009, 15:59:07 »
You can open a dialog. But this is the same extreme as DisableUserInput.

Actually, it's not -that- extreme, and could in fact work quite well. Simply create a dialog which, for instance, shows the % of repair progress (or something), and which gives the instruction "press ESC to cancel" - pressing ESC, and thus escaping the dialogue, will also cancel the repairs then.

I don't really know of any other terribly clever ways of removing or temporarily disabling all other actions. Hm hm.  :(

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re: DisableUserInput
« Reply #4 on: 13 Jan 2009, 17:13:41 »
I'm developing a universal graph script to show like a progress indicator. It doesn't prevent user movement but i could easily add it as an option.I'll try and finish it up today and post it in the beta boards.
Xbox Rocks

Offline Deadfast

  • Members
  • *
Re: DisableUserInput
« Reply #5 on: 13 Jan 2009, 18:12:27 »
You could also use a camera to block the controls:
Code: [Select]
_cam = "camera" camCreate position player;
_cam cameraEffect ["internal", "back"];
titleText ["Repairing, wait a moment...", "PLAIN"];

waitUntil {RepairsDone};

camDestroy _cam;

Offline The-Architect

  • Former Staff
  • ****
  • Bite my shiny metal...
    • Bob's Un-official Flashpoint Page
Re: DisableUserInput
« Reply #6 on: 13 Jan 2009, 19:55:53 »
Trouble with a camera is that if he's attacked he's gonna get wasted. Wolfrug's idea to have a dialogue bar with a cancel option seems to be the way to go.
James Andrew Wilkinson 1977 - 2005 R.I.P.
"If it ain't the friggin' incoming it's the friggin' outgoing. Only difference is who gets the friggin' grease, and that ain't no friggin' difference at all."

Re: DisableUserInput
« Reply #7 on: 13 Jan 2009, 22:52:19 »
Thanks guys. I followed i0n0s' recommendation and used a dialog box. I've also modified the repair loop to abort if the dialog is closed, so it's nowhere near as "extreme" as I thought it was gonna be.

@hoz, I managed to get a fake progress bar working myself, but the only way I could update it was by repeatedly closing and opening the dialog with a new value. This made detecting the "abort" rather difficult. I gave up in the end cause I'm not too familiar with dialogs. If you know of a better way, I'd appreciate a heads up.

Thanks for all your help  :good:

(I've attached the latest version if anyone is interested)
There are 10 types of people in the world. Those who understand binary, and those who don't

Offline Deadfast

  • Members
  • *
Re: DisableUserInput
« Reply #8 on: 13 Jan 2009, 23:00:38 »
Trouble with a camera is that if he's attacked he's gonna get wasted. Wolfrug's idea to have a dialogue bar with a cancel option seems to be the way to go.

That's right, even though this could be avoided, but the overall effort is not worth it.


Dialog is definitely a way to go, mine was more of a reply towards blocking the controls in general :)

Offline i0n0s

  • Former Staff
  • ****
Re: DisableUserInput
« Reply #9 on: 14 Jan 2009, 01:14:19 »
For the dialog:
Give him an IDD. Give an IDC to the 'progressbar'. Set OnShow to:
Code: [Select]
_display = findDisplay IDD;
_ctrl = _display displayCtrl IDC;
DAM_WaitDlg_Script = _ctrl spawn {
_pos = ctrlPosition _this;
_min = 0.3;
_max = 0.4;
_pos set [2, 0];
_this ctrlSetPosition _pos;
_this ctrlCommit 0.0;
_current = 0;
while {true} do {
_current = _current + 0.025;
if (_current > _max + 0.1) then {
_current = 0;
_pos set [0, _min];
_pos set [2, 0];
_this ctrlSetPosition _pos;
_this ctrlCommit 0.0;
} else {
_left = _current - 0.1;
if (_left < 0) then {
_left = 0;
};
_width = _current - _left;
if (_left + _width > _max) then {
_width = _max - _left;
};
_pos set [0, _min + _left];
_pos set [2, _width];
_this ctrlSetPosition _pos;
_this ctrlCommit 0.125;
};
sleep 0.125;
};
};
and onClose to:
Code: [Select]
terminate DAM_WaitDlg_Script
Please note that you have to play with min and max since they are values I used for my control.

Re: DisableUserInput
« Reply #10 on: 14 Jan 2009, 13:51:53 »
Thanks i0n0s, I'll have a play with this and see if I can integrate it into the repair script.

Edit: Thanks for your help i0n0s. Using your idea with the IDC values, I've now got a working progress bar!  :good:
« Last Edit: 16 Jan 2009, 22:23:11 by DeadActionMan »
There are 10 types of people in the world. Those who understand binary, and those who don't