How do I block a button for 2-3 seconds?

GPC1 script programming for Titan One. Code examples, questions, requests.

How do I block a button for 2-3 seconds?

Postby theORDOG » Sun Oct 25, 2015 4:55 pm

I use auto or easy sprint functions on some of my FPS games. The problem is when easy-sprint is enabled ( usually by holding forward on LS) it cancels my re-load cycle animation which usually takes 2-3 seconds. What I want is to know how to write a script that will block the sprint button after pushing re-load for 2-3 seconds. Can anyone help?
User avatar
theORDOG
Master Sergeant
Master Sergeant
 
Posts: 27
Joined: Tue Sep 16, 2014 8:42 pm

Re: How do I block a button for 2-3 seconds?

Postby Elvish » Sun Oct 25, 2015 7:06 pm

Never actually used the block function personally, but according to the GPC LLanguage Reference the following should work:

Code: Select all
int Reload = XB1_X;
int Sprint = XB1_LS;

main {

    if(event_press(Reload)){
        block(Sprint, 3000);
    }
}
User avatar
Elvish
Captain
Captain
 
Posts: 531
Joined: Tue Jun 09, 2015 4:57 am

Re: How do I block a button for 2-3 seconds?

Postby theORDOG » Mon Oct 26, 2015 4:51 am

Code: Select all
/ Tue Jul 21 2015 14:30:26
// Script generated by Visual to GPC
//----------------------------------------

main {
    swap(XB1_RB, XB1_RS);
    if(event_press(XB1_RS)) {
        combo_run(Tap_1);
    }
    int Reload = XB1_X;
int Sprint = XB1_LS;

main {

    if(event_press(Reload)){
        block(Sprint, 3000);
    }
}
    }
}
main {
    if((get_val(XB1_LY)) < -95) {
        combo_run(Turbo_1);
    }
}

combo Turbo_1 {
    set_val(XB1_A, 100);
    wait(40);
    set_val(XB1_A, 0);
    wait(30);
    set_val(XB1_A, 0);
}
combo Tap_1 {
    set_val(XB1_A, 0);
    wait(400);
    set_val(XB1_A, 100);
    wait(40);
    set_val(XB1_A, 100);
}




I get this error when I try to compile my script.
syntax error near unexpected token 'int'.
Build failed with 1 errors
User avatar
theORDOG
Master Sergeant
Master Sergeant
 
Posts: 27
Joined: Tue Sep 16, 2014 8:42 pm

Re: How do I block a button for 2-3 seconds?

Postby Elvish » Mon Oct 26, 2015 5:17 am

Thats because you added a second main function, you can have only one. Try this:

Code: Select all
main {
    swap(XB1_RB, XB1_RS);
    if(event_press(XB1_RS)) {
        combo_run(Tap_1);
    }

    if((get_val(XB1_LY)) < -95) {
        combo_run(Turbo_1);
    }
   
    if(event_press(XB1_X)){
        block(XB1_LY, 3000);
    }   
}

combo Turbo_1 {
    set_val(XB1_A, 100);
    wait(40);
    set_val(XB1_A, 0);
    wait(30);
    set_val(XB1_A, 0);
}
combo Tap_1 {
    set_val(XB1_A, 0);
    wait(400);
    set_val(XB1_A, 100);
    wait(40);
    set_val(XB1_A, 100);
}


Again I have never used the block function, tell me if this is not working properly and I will try to fix it. I blocked the Left stick input, and have a feeling you want the A button blocked? According to what you pasted though you want the stick blocked and not the A blocked.
User avatar
Elvish
Captain
Captain
 
Posts: 531
Joined: Tue Jun 09, 2015 4:57 am

Re: How do I block a button for 2-3 seconds?

Postby theORDOG » Mon Oct 26, 2015 9:37 am

This one does not work either, auto sprint works but when I reload it does not block the sprint for 3 seconds.


Code: Select all
int Reload = XB1_X ;
int Sprint = XB1_LS ;

main {
if (event_press(Reload)) {
    block (Sprint, 3000) ;
    }



if((get_val(XB1_LY)) < -95) {
        combo_run(Turbo_1);
    }
}

combo Turbo_1 {
    set_val(XB1_LS, 100);
    wait(40);
    set_val(XB1_LS, 0);
    wait(30);
    set_val(XB1_LS, 0);}
User avatar
theORDOG
Master Sergeant
Master Sergeant
 
Posts: 27
Joined: Tue Sep 16, 2014 8:42 pm

Re: How do I block a button for 2-3 seconds?

Postby theORDOG » Mon Oct 26, 2015 9:58 am

This one didn't work for me either:

Code: Select all
main {
    if(get_val(XB1_X)){
    set_val(XB1_LS, 0);
    block(XB1_LS, 3000);//block for 3000ms
    }
    if((get_val(XB1_LY)) < -95) {
        combo_run(Turbo_1);
    }
}

combo Turbo_1 {
    set_val(XB1_LS, 100);
    wait(40);
    set_val(XB1_LS, 0);
    wait(30);
    set_val(XB1_LS, 0);
}
User avatar
theORDOG
Master Sergeant
Master Sergeant
 
Posts: 27
Joined: Tue Sep 16, 2014 8:42 pm

Re: How do I block a button for 2-3 seconds?

Postby J2Kbr » Mon Oct 26, 2015 12:51 pm

the block function does not works conditioned to other button event. I edited your script and now it should work as you want.

Code: Select all
define SPRINT_BLOCK = 3000;

int tv = SPRINT_BLOCK;

main {
    if(event_press(XB1_X)){
        tv = 0;
    }
    if(tv < SPRINT_BLOCK) {
        tv = tv + get_rtime();
        set_val(XB1_LS, 0);
    }
    if((get_val(XB1_LY)) < -95) {
        combo_run(Turbo_1);
    }
}

combo Turbo_1 {
    set_val(XB1_LS, 100);
    wait(40);
    set_val(XB1_LS, 0);
    wait(30);
    set_val(XB1_LS, 0);
}
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

Re: How do I block a button for 2-3 seconds?

Postby theORDOG » Mon Oct 26, 2015 5:55 pm

I got it to work here is what I came up with:

Code: Select all
//
// Mon Oct 26 2015 11:27:45
// Script generated by Visual to GPC
//----------------------------------------

main {
    if((get_val(XB1_LY)) < -95) {
        combo_run(Turbo_1);
    }
    if((get_val(XB1_X)==100)){
        combo_run(Turbo_2);
       
    }
}

combo Turbo_1 {
    set_val(XB1_LS, 100);
    wait(40);
    set_val(XB1_LS, 0);
    wait(30);
    set_val(XB1_LS, 0);
}   
combo Turbo_2 {
    set_val(XB1_LS, 100);
    wait(1500);
    set_val(XB1_LS, 0);
    wait(1500);
    set_val(XB1_LS, 0);
}
User avatar
theORDOG
Master Sergeant
Master Sergeant
 
Posts: 27
Joined: Tue Sep 16, 2014 8:42 pm

Re: How do I block a button for 2-3 seconds?

Postby J2Kbr » Tue Oct 27, 2015 11:23 am

Great! :) Thanks for sharing your code!
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

Re: How do I block a button for 2-3 seconds?

Postby pablosscripts » Wed Dec 09, 2015 4:10 am

theORDOG wrote:I got it to work here is what I came up with:

Code: Select all
//
// Mon Oct 26 2015 11:27:45
// Script generated by Visual to GPC
//----------------------------------------

main {
    if((get_val(XB1_LY)) < -95) {
        combo_run(Turbo_1);
    }
    if((get_val(XB1_X)==100)){
        combo_run(Turbo_2);
       
    }
}

combo Turbo_1 {
    set_val(XB1_LS, 100);
    wait(40);
    set_val(XB1_LS, 0);
    wait(30);
    set_val(XB1_LS, 0);
}   
combo Turbo_2 {
    set_val(XB1_LS, 100);
    wait(1500);
    set_val(XB1_LS, 0);
    wait(1500);
    set_val(XB1_LS, 0);
}


This could be just what I'm looking for, thanks.
Setup: XIM Apex, T2, K780 keyboard, G Pro Wireless mouse, SteelSeries 4HD pad, DXRacer armrest, LucidSound LS30 headset, Netduma router, Ubiquiti UniFi AP LR

My R6 script: https://youtu.be/x-9NtxyySVM
User avatar
pablosscripts
Brigadier General
Brigadier General
 
Posts: 1976
Joined: Tue Nov 24, 2015 6:27 am


Return to GPC1 Script Programming

Who is online

Users browsing this forum: No registered users and 56 guests