Check active with KM

GPC script programming for Titan Two device. Code examples, how to, questions, requests.

Moderators: The_Rabid_Taco, pablosscripts, bonefisher

Check active with KM

Postby A1rookie » Tue Feb 12, 2019 8:01 pm

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
User avatar
A1rookie
Staff Sergeant
Staff Sergeant
 
Posts: 11
Joined: Mon Sep 10, 2018 5:26 pm

Re: Check active with KM

Postby Sillyasskid » Tue Feb 12, 2019 9:26 pm

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.
User avatar
Sillyasskid
Captain
Captain
 
Posts: 575
Joined: Sat May 14, 2016 3:07 am

Re: Check active with KM

Postby A1rookie » Thu Feb 14, 2019 7:45 pm

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
User avatar
A1rookie
Staff Sergeant
Staff Sergeant
 
Posts: 11
Joined: Mon Sep 10, 2018 5:26 pm

Re: Check active with KM

Postby Sillyasskid » Thu Feb 14, 2019 8:35 pm

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;
}
User avatar
Sillyasskid
Captain
Captain
 
Posts: 575
Joined: Sat May 14, 2016 3:07 am

Re: Check active with KM

Postby A1rookie » Sat Feb 16, 2019 4:18 pm

You are a Genius. Thank you mate, perfect :smile0517:
User avatar
A1rookie
Staff Sergeant
Staff Sergeant
 
Posts: 11
Joined: Mon Sep 10, 2018 5:26 pm


Return to GPC Script Programming (Titan Two)

Who is online

Users browsing this forum: Google [Bot] and 5 guests