Page 1 of 1

Check active with KM

PostPosted: Tue Feb 12, 2019 8:01 pm
by A1rookie
Hi all,
I have troubles with scripting check actives on keyboard/mouse Inputs.
I did it with binding the mouse Button to a unused Controller input, because check active on mouse directly didn't work.
What is a good way to make check actives with mouse/keyboard Keys?
Ingame Situation : I wanna create a Script for when I Hold a mouse Button, first it press right pad ps4 once, if I Continue to hold it for about 2 seconds (ingame time for switching to grenade), Script starts to hold down r2 (throw /Cook grenade) until I Release mouse Button (then Releases r2).
I could only achieve this until now by binding the mouse Button to an unused Controller Button and then srt check active to this one, but on the New Script there is no unused controller Button.
Best Regards

Re: Check active with KM

PostPosted: Tue Feb 12, 2019 9:26 pm
by Sillyasskid
Code: Select all
#include <mouse.gph>
#include <ps4.gph>
 
#define MOUSE_BUTTON    MBUTTON_3 /* Middle Mouse Button */
 
bool bGrenade;
main {
  bool mbutton_state;
 
  if(mouse_status(MOUSE_BUTTON)){
    if(!mbutton_state) mbutton_state = 1, combo_restart(cGrenade);
    if(bGrenade) set_val(PS4_R2, 100);
  } else mbutton_state = bGrenade = FALSE;
 
}
 
combo cGrenade {
  set_val(PS4_RIGHT , 100);
  wait(125);
  wait(2000);
  bGrenade = TRUE;
}

I guess this would work, Just define what mouse button your planning to use.

Its set to the Middle Mouse button in the script. You can change it to what ever mouse button you wish though.

Re: Check active with KM

PostPosted: Thu Feb 14, 2019 7:45 pm
by A1rookie
Hi sillyasskid, thank you very much, that works perfectly.
Could you please add to press triangle once, after releasing R2, to switch back to Normal weapon? I tried to Do it but it's not working very well.
Best Regards

Re: Check active with KM

PostPosted: Thu Feb 14, 2019 8:35 pm
by Sillyasskid
Code: Select all
#include <mouse.gph>
#include <ps4.gph>
 
#define MOUSE_BUTTON    MBUTTON_3 /* Middle Mouse Button */
 
bool bGrenade;
main {
  bool mbutton_state, bTriangle_state;
 
  if(mouse_status(MOUSE_BUTTON)){
    if(!mbutton_state) mbutton_state = 1, combo_restart(cGrenade);
    if(bGrenade) bTriangle_state = 1, set_val(PS4_R2, 100);
  } else mbutton_state = bGrenade = FALSE;
 
  if(!bGrenade && bTriangle_state) {
    combo_run(cTriangle);
    bTriangle_state = FALSE;
  }
}
combo cTriangle {
  wait(200);
  set_val(PS4_TRIANGLE, 100);
  wait(100);
}
combo cGrenade {
  set_val(PS4_RIGHT , 100);
  wait(125);
  wait(2000);
  bGrenade = TRUE;
}

Re: Check active with KM

PostPosted: Sat Feb 16, 2019 4:18 pm
by A1rookie
You are a Genius. Thank you mate, perfect :smile0517: