i need help in script Rapidfire

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

i need help in script Rapidfire

Postby TheOne » Sun May 26, 2019 11:07 pm

hi,i need help in script Rapidfire

1/ (.) in keyboard on/off for grren LED_3 if on >>> i done that


2/ add button BUTTON_14 for on / off > i need only work when i press fast(grren LED_3 if on),but when i hold the button like 0.3sce dose not turn on/ off

-------------------------------------------------------
mean i want (.) in keyboard on/off the script + then i press triangle to swep the weapon it stop (rapidfire for 1st weapon and 2nd no rapidfire ) only work when i press triangle fast , and do not work when i hold triangle )
-------------------------------------------------------

Code: Select all
#pragma METAINFO("<author_name>", 1, 0, "")
 
 
#include <display.gph>
#include <keyboard.gph>
#include "xkeys.gph"
 
uint8 KEYPERIOD;
 
int Enabled = FALSE;
init {
KEYPERIOD=xkeys_add(KEY_PADPERIOD); /// .
    }
 
 
main {
  if (xkeys_event_active(KEYPERIOD)){    ///////// ON/OFF (.)
        if(Enabled) {
            Enabled = FALSE;
            led_reset();
            display_overlay(_X_, 2000);   
        }  else if(!Enabled) {
            led_reset();
            Enabled = TRUE;
            led_set(LED_3, -1.0, 0);   // green On
            display_overlay(_R_, 2000);
 
        }
    }
        if (Enabled) {
 
        if(get_val(BUTTON_5)) {
            combo_run(Rapidfire);
        }
    }
}
 
combo Rapidfire {
    set_val(BUTTON_5, 100.0);
    wait(59);
    set_val(BUTTON_5, 0.0);
    wait(37);
}
Last edited by TheOne on Mon May 27, 2019 1:51 am, edited 2 times in total.
User avatar
TheOne
Sergeant First Class
Sergeant First Class
 
Posts: 21
Joined: Mon Aug 13, 2018 7:43 pm

Re: i need help in script Rapidfire

Postby Mad » Sun May 26, 2019 11:27 pm

Code: Select all
#pragma METAINFO("<author_name>", 1, 0, "")
 
#include <display.gph>
#include <keyboard.gph>
#include "xkeys.gph"
 
uint8 KEYPERIOD;
bool rapidfire;
 
init {
  KEYPERIOD=xkeys_add(KEY_PADPERIOD);
}
 
main {
    key_passthru();
 
    if(xkeys_event_release(KEYPERIOD)) { // On release
        rapidfire = !rapidfire;   
 
        if(rapidfire) { // Enabled
            led_reset();
            led_set(LED_3, -1.0, 0);
            display_overlay(_R_, 2000);           
        } 
        else { // Disabled
            led_reset();
            display_overlay(_X_, 2000);
        }
    }
 
    if(get_val(BUTTON_5) && rapidfire) { combo_run(RapidFire); }
}
 
combo RapidFire {
    set_val(BUTTON_5, 100.0);
    wait(59);
    set_val(BUTTON_5, 0.0);
    wait(37);
}
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord (2K / FPS)
Mad
Major General
Major General
 
Posts: 4533
Joined: Wed May 22, 2019 5:39 am

Re: i need help in script Rapidfire

Postby TheOne » Mon May 27, 2019 1:44 am

still the same
User avatar
TheOne
Sergeant First Class
Sergeant First Class
 
Posts: 21
Joined: Mon Aug 13, 2018 7:43 pm

Re: i need help in script Rapidfire

Postby Mad » Mon May 27, 2019 2:32 am

Sorry I didn't understand correctly here you go.

Code: Select all
#pragma METAINFO("<author_name>", 1, 0, "")
 
#include <display.gph>
#include <keyboard.gph>
#include "xkeys.gph"
 
uint8 KEYPERIOD;
bool rapidfire;
 
init {
  KEYPERIOD=xkeys_add(KEY_PADPERIOD);
}
 
main {
    key_passthru();
 
    if(xkeys_event_release(KEYPERIOD)) { // On release
        rapidfire = !rapidfire;   
 
        if(rapidfire) { // Enabled
            led_reset();
            led_set(LED_3, -1.0, 0);
            display_overlay(_R_, 2000);           
        } 
        else { // Disabled
            led_reset();
            display_overlay(_X_, 2000);
        }
    }
 
    if(event_release(BUTTON_14) && time_active(BUTTON_14) < 300) {
        if(rapidfire) {
            rapidfire = !rapidfire;   
 
            led_reset();
            display_overlay(_X_, 2000);
        }
    }   
 
 
    if(get_val(BUTTON_5) && rapidfire) { combo_run(RapidFire); }
}
 
combo RapidFire {
    set_val(BUTTON_5, 100.0);
    wait(59);
    set_val(BUTTON_5, 0.0);
    wait(37);
}
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord (2K / FPS)
Mad
Major General
Major General
 
Posts: 4533
Joined: Wed May 22, 2019 5:39 am

Re: i need help in script Rapidfire

Postby TheOne » Mon May 27, 2019 9:24 pm

Thanks
User avatar
TheOne
Sergeant First Class
Sergeant First Class
 
Posts: 21
Joined: Mon Aug 13, 2018 7:43 pm

Re: i need help in script Rapidfire

Postby TheOne » Mon May 27, 2019 9:40 pm

Mad wrote:Sorry I didn't understand correctly here you go.

Code: Select all
#pragma METAINFO("<author_name>", 1, 0, "")
 
#include <display.gph>
#include <keyboard.gph>
#include "xkeys.gph"
 
uint8 KEYPERIOD;
bool rapidfire;
 
init {
  KEYPERIOD=xkeys_add(KEY_PADPERIOD);
}
 
main {
    key_passthru();
 
    if(xkeys_event_release(KEYPERIOD)) { // On release
        rapidfire = !rapidfire;   
 
        if(rapidfire) { // Enabled
            led_reset();
            led_set(LED_3, -1.0, 0);
            display_overlay(_R_, 2000);           
        } 
        else { // Disabled
            led_reset();
            display_overlay(_X_, 2000);
        }
    }
 
    if(event_release(BUTTON_14) && time_active(BUTTON_14) < 300) {
        if(rapidfire) {
            rapidfire = !rapidfire;   
 
            led_reset();
            display_overlay(_X_, 2000);
        }
    }   
 
 
    if(get_val(BUTTON_5) && rapidfire) { combo_run(RapidFire); }
}
 
combo RapidFire {
    set_val(BUTTON_5, 100.0);
    wait(59);
    set_val(BUTTON_5, 0.0);
    wait(37);
}


when i press triangle to swep the weapon it stop , but when i press triangle agine dose not turn on ?
User avatar
TheOne
Sergeant First Class
Sergeant First Class
 
Posts: 21
Joined: Mon Aug 13, 2018 7:43 pm

Re: i need help in script Rapidfire

Postby Mad » Mon May 27, 2019 10:57 pm

Code: Select all
#pragma METAINFO("<author_name>", 1, 0, "")
 
#include <display.gph>
#include <keyboard.gph>
#include "xkeys.gph"
 
uint8 KEYPERIOD;
bool rapidfire;
 
init {
  KEYPERIOD=xkeys_add(KEY_PADPERIOD);
}
 
main {
    key_passthru();
 
    if(xkeys_event_release(KEYPERIOD)) { // On release
        rapidfire = !rapidfire;   
 
        if(rapidfire) { // Enabled
            led_reset();
            led_set(LED_3, -1.0, 0);
            display_overlay(_R_, 2000);           
        } 
        else { // Disabled
            led_reset();
            display_overlay(_X_, 2000);
        }
    }
 
    if(event_release(BUTTON_14) && time_active(BUTTON_14) < 300) {
        rapidfire = !rapidfire;
 
        if(rapidfire) { // Enabled
            led_reset();
            led_set(LED_3, -1.0, 0);
            display_overlay(_R_, 2000);           
        } 
        else { // Disabled
            led_reset();
            display_overlay(_X_, 2000);
        }
    }   
 
    if(get_val(BUTTON_5) && rapidfire) { combo_run(RapidFire); }
}
 
combo RapidFire {
    set_val(BUTTON_5, 100.0);
    wait(59);
    set_val(BUTTON_5, 0.0);
    wait(37);
}
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord (2K / FPS)
Mad
Major General
Major General
 
Posts: 4533
Joined: Wed May 22, 2019 5:39 am

Re: i need help in script Rapidfire

Postby TheOne » Wed May 29, 2019 7:56 am

Mad wrote:
Code: Select all
#pragma METAINFO("<author_name>", 1, 0, "")
 
#include <display.gph>
#include <keyboard.gph>
#include "xkeys.gph"
 
uint8 KEYPERIOD;
bool rapidfire;
 
init {
  KEYPERIOD=xkeys_add(KEY_PADPERIOD);
}
 
main {
    key_passthru();
 
    if(xkeys_event_release(KEYPERIOD)) { // On release
        rapidfire = !rapidfire;   
 
        if(rapidfire) { // Enabled
            led_reset();
            led_set(LED_3, -1.0, 0);
            display_overlay(_R_, 2000);           
        } 
        else { // Disabled
            led_reset();
            display_overlay(_X_, 2000);
        }
    }
 
    if(event_release(BUTTON_14) && time_active(BUTTON_14) < 300) {
        rapidfire = !rapidfire;
 
        if(rapidfire) { // Enabled
            led_reset();
            led_set(LED_3, -1.0, 0);
            display_overlay(_R_, 2000);           
        } 
        else { // Disabled
            led_reset();
            display_overlay(_X_, 2000);
        }
    }   
 
    if(get_val(BUTTON_5) && rapidfire) { combo_run(RapidFire); }
}
 
combo RapidFire {
    set_val(BUTTON_5, 100.0);
    wait(59);
    set_val(BUTTON_5, 0.0);
    wait(37);
}


there is somthing wrong ...

can u make BUTTON_14 only work when i activate (.) in keyboard

( soo when i press (.) to trun in off the BUTTON_14 no more work >> when i press (.) to trun in on the BUTTON_14 work
User avatar
TheOne
Sergeant First Class
Sergeant First Class
 
Posts: 21
Joined: Mon Aug 13, 2018 7:43 pm

Re: i need help in script Rapidfire

Postby TheOne » Wed Jun 05, 2019 5:26 am

up
User avatar
TheOne
Sergeant First Class
Sergeant First Class
 
Posts: 21
Joined: Mon Aug 13, 2018 7:43 pm

Re: i need help in script Rapidfire

Postby Scachi » Wed Jun 05, 2019 8:42 am

So you want to en/disable the script with a key press and toggle rapid fire with a fast press of triangle ?

You may want to change one of the color-letter combination to indicate the script on/off and rapid fire on/off states differently.
Code: Select all
#pragma METAINFO("Script_Name", 1, 0, "<author_name>")
 
#include <display.gph>
#include <keyboard.gph>
#include "xkeys.gph"
 
uint8 KEYPERIOD;
bool rapidfire;
bool script;
 
init {
  KEYPERIOD=xkeys_add(KEY_PADPERIOD);
}
 
main {
    key_passthru();
 
    if(xkeys_event_release(KEYPERIOD)) { // On release
        script = !script;   
 
        if(script) { // Enabled
            led_reset();
            led_set(LED_3, -1.0, 0);
            display_overlay(_R_, 2000);           
        } 
        else { // Disabled
            led_reset();
            display_overlay(_X_, 2000);
        }
    }
 
        if (script) { // script enabled
            if(event_release(BUTTON_14) && time_active(BUTTON_14) < 300) {
                    rapidfire = !rapidfire;
 
                    if(rapidfire) { // Enabled
                            led_reset();
                            led_set(LED_3, -1.0, 0);
                            display_overlay(_R_, 2000);           
                    } 
                    else { // Disabled
                            led_reset();
                            display_overlay(_X_, 2000);
                    }
            }   
 
            if(get_val(BUTTON_5) && rapidfire) { combo_run(RapidFire); }
        }
}
 
combo RapidFire {
    set_val(BUTTON_5, 100.0);
    wait(59);
    set_val(BUTTON_5, 0.0);
    wait(37);
}
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Next

Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 116 guests