Need help with script

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

Need help with script

Postby alencroat » Sat Aug 13, 2022 11:57 pm

Hello! Can some one help me with a code where button 18 or share button toggles, 3 switches.
*So mode 1 switch does nothing- or I guess off swich
*mode 2 turns on red led light and if I press RT runs a combo( rapidfire )
*mode 3 turns off red light and turns on blue light, also hitting RT again will run new combo
User avatar
alencroat
Lieutenant
Lieutenant
 
Posts: 320
Joined: Sun Oct 15, 2017 5:58 pm

Re: Need help with script

Postby alencroat » Thu Sep 08, 2022 10:45 pm

cant find anything similar that I need, and I have been searching
User avatar
alencroat
Lieutenant
Lieutenant
 
Posts: 320
Joined: Sun Oct 15, 2017 5:58 pm

Re: Need help with script

Postby Tahsin » Sat Sep 10, 2022 6:16 pm

Hello
you can download Pubg v2 script and read it you can have an idea how it works

example coded by Scachi
Code: Select all
if (!WeaponHolstered && !bThrow ) {
 
            WeaponActive = (WeaponActive+1)%2;
        }

i'm learning and only modifying scripts but not a T2 coder
so this is just an idea :)
User avatar
Tahsin
Sergeant Major
Sergeant Major
 
Posts: 100
Joined: Wed May 15, 2019 7:57 am

Re: Need help with script

Postby alanmcgregor » Sat Sep 10, 2022 7:43 pm

alencroat wrote:Hello! Can some one help me with a code where button 18 or share button toggles, 3 switches.
*So mode 1 switch does nothing- or I guess off swich
*mode 2 turns on red led light and if I press RT runs a combo( rapidfire )
*mode 3 turns off red light and turns on blue light, also hitting RT again will run new combo

what do yo mean with a new combo?, different Rapid Fire?

You have to be more specific what do you wanted to do.

I mean pressing button 18 can change led to RED and apply rapid-fire type 1 when pressing RT.
Pressing again button 18 it change led to a SKYBLUE and apply a different rapid-fire when pressing RT.
and finally pressing button 18 again, turns led to regular blue (meaning rapid-fire off)

Is that what do you want? it can be done.

However, maybe loosing button 18 function is not advisable, you can run a combo like HOLD LT and then press XB/PS button then release LT o navigate toggles.

Enabling scripts can be a hassle, that's why I wrote mines with a numpad compatibility, so you can use a wireless numeric keypad and enabling/disabling mods by pressing a specific key on the numpad
User avatar
alanmcgregor
Major
Major
 
Posts: 981
Joined: Tue Mar 27, 2018 8:38 am

Re: Need help with script

Postby alencroat » Tue Sep 13, 2022 9:39 pm

alanmcgregor wrote:
alencroat wrote:Hello! Can some one help me with a code where button 18 or share button toggles, 3 switches.
*So mode 1 switch does nothing- or I guess off swich
*mode 2 turns on red led light and if I press RT runs a combo( rapidfire )
*mode 3 turns off red light and turns on blue light, also hitting RT again will run new combo

what do yo mean with a new combo?, different Rapid Fire?

You have to be more specific what do you wanted to do.

I mean pressing button 18 can change led to RED and apply rapid-fire type 1 when pressing RT.
Pressing again button 18 it change led to a SKYBLUE and apply a different rapid-fire when pressing RT.
and finally pressing button 18 again, turns led to regular blue (meaning rapid-fire off)

Is that what do you want? it can be done.

However, maybe loosing button 18 function is not advisable, you can run a combo like HOLD LT and then press XB/PS button then release LT o navigate toggles.

Enabling scripts can be a hassle, that's why I wrote mines with a numpad compatibility, so you can use a wireless numeric keypad and enabling/disabling mods by pressing a specific key on the numpad



yea pretty much the way I want it, I would like to have one example for future scripts if I need them again. In most cases I usually run out of buttons to use the switches on. And I like to keep it convenient when Im playing. In this case that I need this for I would need to switch between the rapid fires as its needing different rapid fires and stuff for gun. Any chance you can write me that example?
User avatar
alencroat
Lieutenant
Lieutenant
 
Posts: 320
Joined: Sun Oct 15, 2017 5:58 pm

Re: Need help with script

Postby alanmcgregor » Tue Sep 13, 2022 10:48 pm

I Wrote this should do what you want it by only toggling the Share or button_18 :smile0517:

Wrote it in a way that is self explained, hope is clear.

Code: Select all
 
#pragma METAINFO("Basic toggle Rapidfire", 1, 0, "AMG")
 
//Rapid Fire Burst timings
static uint8 HoldTime = 0;
static uint8 ReleaseTime = 0;
 
// BUTTONS
#define FIRE (BUTTON_5)
 
uint8 fireMode = 0;
 
main {
 
    if(event_release(BUTTON_18)){ //this hijacks BUTTON_18 function, so you can use it as a mod toggle. Share option won't work tho.
        set_val(BUTTON_18, 0.0);
        fireMode++;
    }
 
    if(fireMode > 2) fireMode = 0;
 
    switch(fireMode){
        case 1: HoldTime = 100//Change this values for the burst timing you need.
                ReleaseTime = 40;
                led_color('P');
                break;
        case 2: HoldTime = 40;
                ReleaseTime = 40;
                led_color('S');
                break;
        default: HoldTime = 0;
                 ReleaseTime = 0;
                 led_color('B');
    }
 
    // RAPID-FIRE
        if(is_active(FIRE) && HoldTime)    combo_run(cRapidFire); //it reads: if firing button is pressed AND HoldTime has a value, then run a Rapidfire combo.
        if(event_release(FIRE) && HoldTime)    combo_stop(cRapidFire); //and stop the rapidfiring when fire button is released
}
 
combo cRapidFire{
    set_val(FIRE, 100.0);
    wait(HoldTime);
    set_val(FIRE, 0.0);
    wait(ReleaseTime);
    set_val(FIRE, 0.0);   
}
 
 
void led_color(uint8 newLight)
{
    static uint8 prevLight;
    if(newLight == prevLight) return;
    prevLight = newLight;
    switch(newLight) {
        case 'G':    // Green LED
                    led_set(LED_1, 0.0, 0);
                    led_set(LED_2, 0.0, 0);
                    led_set(LED_3, 25.0, 0);
                    led_set(LED_4, 0.0, 0);
                    break;
 
        case 'B':    // Blue LED
                    led_set(LED_1, 25.0, 0);
                    led_set(LED_2, 0.0, 0);
                    led_set(LED_3, 0.0, 0);
                    led_set(LED_4, 0.0, 0);
                    break;
 
        case 'S':    // Sky Blue LED
                    led_set(LED_1, 50.0, 0);
                    led_set(LED_2, 0.0, 0);
                    led_set(LED_3, 50.0, 0);
                    led_set(LED_4, 0.0, 0);
                    break;   
 
        case 'P':    // Pink LED
                    led_set(LED_1, 0.0, 0);
                    led_set(LED_2, 0.0, 0);
                    led_set(LED_3, 0.0, 0);
                    led_set(LED_4, 5.0, 0);
                    break;   
    }
    return;
}
 


I haven't tested it, my MacMini doesn't work with GTuner XD, but that's the idea.
Last edited by alanmcgregor on Wed Sep 14, 2022 12:57 am, edited 1 time in total.
User avatar
alanmcgregor
Major
Major
 
Posts: 981
Joined: Tue Mar 27, 2018 8:38 am

Re: Need help with script

Postby alencroat » Tue Sep 13, 2022 11:48 pm

awesome it works. And thanks, although sometimes it wont switch to other mod. I have seen this before, I think we goto change this part : get_actual to maybe is active or release. Ill try something. And Ill edit my findings

EDIT: ok I found it in my notes and tested it, this one works best for me for switches
Code: Select all
    if(event_release(BUTTON_18)) {    //BEST WAY TO REGISTER 


many thanks for this script, I hope it will help others too :smile0202:
User avatar
alencroat
Lieutenant
Lieutenant
 
Posts: 320
Joined: Sun Oct 15, 2017 5:58 pm

Re: Need help with script

Postby alanmcgregor » Wed Sep 14, 2022 12:56 am

Well done!
User avatar
alanmcgregor
Major
Major
 
Posts: 981
Joined: Tue Mar 27, 2018 8:38 am

Re: Need help with script

Postby GPCNoob » Fri Mar 08, 2024 1:29 pm

alanmcgregor wrote: scripts can be a hassle, that's why I wrote mines with a numpad compatibility, so you can use a wireless numeric keypad and enabling/disabling mods by pressing a specific key on the numpad

do you have any examples you could share? It sounds like an amazing idea mods numbered 1-9 easily turned on and off instead of button combos, do you just link the multiply buttons to the number pad? (BUTTON_8 & BUTTON5) linked to "num8" ? If so could I see how this would look? I'm having a hard time trying to visualize it working.
User avatar
GPCNoob
Staff Sergeant
Staff Sergeant
 
Posts: 14
Joined: Wed Nov 25, 2020 2:24 am


Return to GPC2 Script Programming

Who is online

Users browsing this forum: Majestic-12 [Bot] and 118 guests