2k20 Shot timer for xbox one

GPC2 script programming for Titan Two. Code examples, questions, requests.

2k20 Shot timer for xbox one

Postby jimrawson7 » Thu Jun 04, 2020 9:20 pm

I was wondering if anyone would be able to help me out here. On 2k20 you hold X (for Xbox) to time your jumpshot. There are a couple types of jumpshots so I was hoping someone could write a script to help time these. I know that the timing is in milliseconds, like around 500ms or so depending on the jumpshot you have, if that helps. For example, a standing jumpshot is timed a bit differently than a jumpshot off of a hesitation or other move. Ideally, there would be a shortcut to time the hesitation jumpshot by just tapping x. For the other jumpshots, maybe pressing up on the d-pad, or the other directions on the d-pad, since it is not used in the game. This would be great and hopefully this is possible. Thanks in advance to whoever helps!!!
User avatar
jimrawson7
Corporal
Corporal
 
Posts: 4
Joined: Thu Jun 04, 2020 9:03 pm

Re: 2k20 Shot timer for xbox one

Postby Scachi » Thu Jun 04, 2020 9:59 pm

Do you need this script three times ? :innocent_smile_1:

Try this simple version, adjust the times in the first line to your needs:
Code: Select all
uint16 jShotTimes[4] = { 500, 550, 600, 650}; // all times, dpad direction order: up, down, left right
 
 
uint16 jShotTime; // currently used time
 
main {
    if (event_active(BUTTON_10)) jShot(0); // dpad up
    if (event_active(BUTTON_11)) jShot(1); // dpad down
    if (event_active(BUTTON_12)) jShot(2); // dpad left
    if (event_active(BUTTON_13)) jShot(3); // dpad right
}
 
void jShot(uint8 idx) {
    if (cjShot) return;
    jShotTime = jShotTimes[idx];
    printf("Milliseconds: %d", jShotTimes[idx]);
    combo_run(cjShot);
}
 
combo cjShot {
    set_val(BUTTON_17,100); // x button press
    wait(jShotTime);
    set_val(BUTTON_17,0); // x button release
    wait(40);
}
 


For how to run custom scripts and install them read:
https://www.consoletuner.com/wiki/index ... _scripting
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: 2k20 Shot timer for xbox one

Postby jimrawson7 » Thu Jun 04, 2020 10:41 pm

Yes, ideally it would work like this: I can choose the different timings of the jumpshots for the different buttons. For example, when I tap the x-button, it will simulate holding the x-button down for 500ms. Then when I tap down on the d-pad it would simulate holding the x-button for 550ms. When I tap right on the d-pad it would simulate holding the x-button for 600ms. Continued with the other directions on the d-pad. Thanks again for all the help so far!!!
User avatar
jimrawson7
Corporal
Corporal
 
Posts: 4
Joined: Thu Jun 04, 2020 9:03 pm

Re: 2k20 Shot timer for xbox one

Postby Scachi » Fri Jun 05, 2020 6:53 am

Here it is with the X button itself added.
Adjust the times in the first line to change the hold time of X button for the different buttons/directions. No need to change any other line.
Read the comments, the text behind the // , to understand which entry is for which button/direction
Code: Select all
uint16 jShotTimes[5] = { 500, 550, 600, 700, 650}; // all times, X button, dpad up, dpad down, dpad left, dpad right
 
 
uint16 jShotTime; // currently used time
 
main {
    if (event_active(BUTTON_17)) jShot(0); // XB1:X button, first time in first line
    if (event_active(BUTTON_10)) jShot(1); // dpad up, second time in first line
    if (event_active(BUTTON_11)) jShot(2); // dpad down, third time in first line
    if (event_active(BUTTON_12)) jShot(3); // dpad left, fourth time in first line
    if (event_active(BUTTON_13)) jShot(4); // dpad right, fifth time in first line
}
 
void jShot(uint8 idx) {
    if (cjShot) return;
    jShotTime = jShotTimes[idx];
    printf("Milliseconds: %d", jShotTimes[idx]);
    combo_run(cjShot);
}
 
combo cjShot {
    set_val(BUTTON_17,100); // XB1:X button press
    wait(jShotTime);
    set_val(BUTTON_17,0); // XB1:X button release
    wait(40);
}
 
// hit the F1 key in Gtuner IV to see the button_nr to button name list
 
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: 2k20 Shot timer for xbox one

Postby jimrawson7 » Sun Jun 07, 2020 8:34 pm

Great, this works perfect for the x-button, but for some reason the d-pad is not working. When I run the script the output panel shows that it recognizes the d-pad being pressed, and shows the time that I set for it, but in the game it does nothing. Not sure if this is able to be fixed or if there is something I could do. Thanks again!
User avatar
jimrawson7
Corporal
Corporal
 
Posts: 4
Joined: Thu Jun 04, 2020 9:03 pm

Re: 2k20 Shot timer for xbox one

Postby Scachi » Mon Jun 08, 2020 7:51 am

Perhaps the game is blocking the jumpshot button input when the press of the dpad buttons is recognized.
Give this version a try.
This script version blocks the dpad inputs for 500ms on each press so it won't be recognized by the game/console anymore.
Hold down a dpad direction longer than 500ms and that direction gets send to the console then.
Code: Select all
uint16 jShotTimes[5] = { 500, 550, 600, 700, 650}; // all times, X button, dpad up, dpad down, dpad left, dpad right
 
 
uint16 jShotTime; // currently used time
 
main {
    if (event_active(BUTTON_17)) jShot(0); // XB1:X button, first time in first line
    if (event_active(BUTTON_10)) jShot(1); // dpad up, second time in first line
    if (event_active(BUTTON_11)) jShot(2); // dpad down, third time in first line
    if (event_active(BUTTON_12)) jShot(3); // dpad left, fourth time in first line
    if (event_active(BUTTON_13)) jShot(4); // dpad right, fifth time in first line
 
    // only pdad presses longer than 500ms will be recognized by the game
    inhibit(BUTTON_10,500);
    inhibit(BUTTON_11,500);
    inhibit(BUTTON_12,500);
    inhibit(BUTTON_13,500);
}
 
 
void jShot(uint8 idx) {
    if (cjShot) return;
    jShotTime = jShotTimes[idx];
    printf("Milliseconds: %d", jShotTimes[idx]);
    combo_run(cjShot);
}
 
combo cjShot {
    set_val(BUTTON_17,100); // XB1:X button press
    wait(jShotTime);
    set_val(BUTTON_17,0); // XB1:X button release
    wait(40);
}
 
// hit the F1 key in Gtuner IV to see the button_nr to button name list
 
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: 2k20 Shot timer for xbox one

Postby jimrawson7 » Tue Jun 09, 2020 8:47 am

Yes this worked perfectly. Thanks again!
User avatar
jimrawson7
Corporal
Corporal
 
Posts: 4
Joined: Thu Jun 04, 2020 9:03 pm

Re: 2k20 Shot timer for xbox one

Postby nba2k20geek » Mon Feb 01, 2021 11:23 pm

hey guys im kinda late on the chat but I need for my device conole.

i got this script ,

But its not working properly, sometimes I green sometimes early sometimes late . i don't get it what am I doing wrong?

Code: Select all
// GPC Online Library
// jumpshot_script_nba2k20.gpc
 
main {
    if((get_val(PS4_UP)) && (get_ptime(PS4_UP)) < 20 ) {
        combo_run(Catchandshoot);
    }
 
    if((get_val(PS4_LEFT)) && (get_ptime(PS4_LEFT)) < 20 ) {
        combo_run(standingandpullup);
    }
 
 
}
 
combo Catchandshoot {
    set_val(PS4_SQUARE, 0);
    wait(015);
    set_val(PS4_SQUARE, 100);
    wait(540);
    set_val(PS4_SQUARE, 100);
}
 
combo standingandpullup {
    set_val(PS4_SQUARE, 0);
    wait(015);
    set_val(PS4_SQUARE, 100);
    wait(550);
    set_val(PS4_SQUARE, 100);
}
User avatar
nba2k20geek
Private
Private
 
Posts: 1
Joined: Mon Feb 01, 2021 11:18 pm


Return to GPC2 Script Programming

Who is online

Users browsing this forum: A pile of bricks and 125 guests