How do i set a button to disable my script please?

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

How do i set a button to disable my script please?

Postby Rejectz » Mon Jul 06, 2020 12:23 pm

I've just made this and it works great, but i was wondering if there was a command that turns the full thing on/off when i press LS please

Code: Select all
//
// Mon Jul 06 2020 13:18:36
// Script generated by Visual to GPC
//----------------------------------------
 
main {
    if(get_val(XB1_A)) {
        combo_run(Tap_1);
    }
    if(get_val(XB1_LT)) {
        combo_run(Tap_2);
        combo_run(Tap_3);
    }
}
 
combo Tap_1 {
    set_val(XB1_RT, 0);
    wait(100);
    set_val(XB1_RT, 100);
    wait(40);
    set_val(XB1_RT, 100);
}
 
combo Tap_2 {
    set_val(XB1_RB, 0);
    wait(100);
    set_val(XB1_RB, 100);
    wait(40);
    set_val(XB1_RB, 100);
}
 
combo Tap_3 {
    set_val(XB1_B, 0);
    wait(100);
    set_val(XB1_B, 100);
    wait(40);
    set_val(XB1_B, 100);
}
 


i tried this but it didnt work

Code: Select all
//
// Mon Jul 06 2020 12:48:56
// Script generated by Visual to GPC
//----------------------------------------
int toggleTap = 0; //this flag will manage the AFK combo execution
 
main {
    if(event_press(XB1_LS)) {
        toggleTap = !toggleTap; // this ON/OFF the flag
    }
    if(get_val(XB1_A)) { // when flag is ON/TRUE run the combo
        combo_run(Tap_1);
    }
    if(get_val(XB1_LT)) {
        combo_run(Tap_2);
        combo_run(Tap_3);
    }
    else
        if(combo_running(Tap_1)){ //if flag is FALSE/OFF and the combo is running, stop it
            combo_stop(Tap_1);
            combo_stop(Tap_2);
            combo_stop(Tap_3);
        }
}
 
combo Tap_1 {
    set_val(XB1_RT, 0);
    wait(100);
    set_val(XB1_RT, 100);
    wait(40);
    set_val(XB1_RT, 100);
}
 
combo Tap_2 {
    set_val(XB1_RB, 0);
    wait(100);
    set_val(XB1_RB, 100);
    wait(40);
    set_val(XB1_RB, 100);
}
 
combo Tap_3 {
    set_val(XB1_B, 0);
    wait(100);
    set_val(XB1_B, 100);
    wait(40);
    set_val(XB1_B, 100);
}
 
Rejectz
Sergeant First Class
Sergeant First Class
 
Posts: 23
Joined: Fri Feb 20, 2015 10:17 am

Re: How do i set a button to disable my script please?

Postby Scachi » Mon Jul 06, 2020 12:43 pm

You need to check the state of the "toggleTap" variable you change.

Code: Select all
..your XB1_LS code..
 
if (toggleTap) {
 
all your other code here
 
}


In your code:
Code: Select all
//
// Mon Jul 06 2020 12:48:56
// Script generated by Visual to GPC
//----------------------------------------
int toggleTap = 0; //this flag will manage the AFK combo execution
 
main {
    if(event_press(XB1_LS)) {
        toggleTap = !toggleTap; // this ON/OFF the flag
    }
 
    if (toggleTap) {
        if(get_val(XB1_A)) { // when flag is ON/TRUE run the combo
            combo_run(Tap_1);
        }
        if(get_val(XB1_LT)) {
            combo_run(Tap_2);
            combo_run(Tap_3);
        }
        else
            if(combo_running(Tap_1)){ //if flag is FALSE/OFF and the combo is running, stop it
                combo_stop(Tap_1);
                combo_stop(Tap_2);
                combo_stop(Tap_3);
            }
    }
}
 
combo Tap_1 {
    set_val(XB1_RT, 0);
    wait(100);
    set_val(XB1_RT, 100);
    wait(40);
    set_val(XB1_RT, 100);
}
 
combo Tap_2 {
    set_val(XB1_RB, 0);
    wait(100);
    set_val(XB1_RB, 100);
    wait(40);
    set_val(XB1_RB, 100);
}
 
combo Tap_3 {
    set_val(XB1_B, 0);
    wait(100);
    set_val(XB1_B, 100);
    wait(40);
    set_val(XB1_B, 100);
}
 
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany


Return to GPC1 Script Programming

Who is online

Users browsing this forum: No registered users and 109 guests