hey Im stuck

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

hey Im stuck

Postby alencroat » Sat Feb 17, 2018 2:23 am

Im totally stuck on this script
Code: Select all
//MODE FOR NO RAPID FIRE  
    if(get_val(BUTTON_11) && get_actual(BUTTON_15))  {   //ACTIVATES ON: DOWN DPAD + B
        norapidfire = !norapidfire;        
    }
    if(norapidfire && event_active(BUTTON_5)) {
    combo_stop(rapidfire);
    combo_stop(rapidfire2);
    }
 

these are the combose that I try to cancel when I press RT
Code: Select all
 
//RAPIDFIRE 1 & 2
    if(get_val(ADS_BUTTON) && get_val(FIRE_BUTTON)) {    //BOTH TRIGERS PULLED-FAST RAPIDFIRE
        combo_run(rapidfire);
        combo_stop(rapidfire2);
    }else if(get_val(FIRE_BUTTON)) {    //RT PULL AND SLOWER RAPIDFIRE
        combo_run(rapidfire2);
    }
combo rapidfire {
    set_val(BUTTON_5, 100.0);
    wait(40);
    set_val(BUTTON_5, 0.0);
    wait(30);
}
combo rapidfire2 {
    set_val(BUTTON_5, 100.0);
    wait(100);
    set_val(BUTTON_5, 0.0);
    wait(40);
}

not sure but the code doesn't work
Basicly I need to have if I press down DPAD and B the mode activates for no rapid fire
If some one can rework my code that would work too or just the top part where I want rapid fire to stop.
Thanks in advance
User avatar
alencroat
Lieutenant
Lieutenant
 
Posts: 320
Joined: Sun Oct 15, 2017 5:58 pm

Re: hey Im stuck

Postby glitchbish » Sat Feb 17, 2018 2:34 am

alencroat wrote:Im totally stuck on this script
Code: Select all
//MODE FOR NO RAPID FIRE  
    if(get_val(BUTTON_11) && get_actual(BUTTON_15))  {   //ACTIVATES ON: DOWN DPAD + B
        norapidfire = !norapidfire;        
    }
    if(norapidfire && event_active(BUTTON_5)) {
    combo_stop(rapidfire);
    combo_stop(rapidfire2);
    }
 

these are the combose that I try to cancel when I press RT


Because main {} runs multiple, multiple times a second, you may be toggling norapidfire on and off very fast, making it inconsistent. One thing I would try is putting the actual toggle in a combo with a delay. That's a cheap/quick fix.

Code: Select all
 
main {
    if(get_val(BUTTON_11) && get_actual(BUTTON_15))  {   //ACTIVATES ON: DOWN DPAD + B
        combo_run(togglerapidfire);   
    }
}
 
combo togglerapidfire {
    norapidfire = !norapidfire;
    wait(0); // This is important, makes sure the previous line only runs once.
    wait(250);
 
}
 
User avatar
glitchbish
First Sergeant
First Sergeant
 
Posts: 45
Joined: Sat Feb 10, 2018 3:11 am

Re: hey Im stuck

Postby alencroat » Sat Feb 17, 2018 2:37 am

awsome thanks for reply gona try
User avatar
alencroat
Lieutenant
Lieutenant
 
Posts: 320
Joined: Sun Oct 15, 2017 5:58 pm

Re: hey Im stuck

Postby alencroat » Sat Feb 17, 2018 2:40 am

eeh in other hand could you write the whole fix for me :)
I understand what you are saying but I dont know how to fix it
User avatar
alencroat
Lieutenant
Lieutenant
 
Posts: 320
Joined: Sun Oct 15, 2017 5:58 pm

Re: hey Im stuck

Postby Sillyasskid » Sat Feb 17, 2018 2:56 am

Code: Select all
bool norapidfire;
main {
   if(get_actual(BUTTON_11) && event_active(BUTTON_15))  {   //ACTIVATES ON: DOWN DPAD + B
         norapidfire = !norapidfire;
      }
    if(norapidfire || event_active(BUTTON_5)) {
    combo_stop(rapidfire);
    combo_stop(rapidfire2);
    }
User avatar
Sillyasskid
Captain
Captain
 
Posts: 574
Joined: Sat May 14, 2016 3:07 am

Re: hey Im stuck

Postby alencroat » Sat Feb 17, 2018 3:04 am

Awsome silly works like a charm I may have messed up a bool! so thanks allot guys I really appreciate it!
User avatar
alencroat
Lieutenant
Lieutenant
 
Posts: 320
Joined: Sun Oct 15, 2017 5:58 pm

Re: hey Im stuck

Postby alencroat » Sat Feb 24, 2018 2:02 am

Hey I got a question to change the condition of turning off the rapidfire, I would like to: If I press and hold BUTTON_2 for more then 500ms then it will turn off rapid fire and also while im pressing down on BUTTON_2 to hit again after those 500ms, basicly Im using it on fortnite, when i click map it will come up when I see map gone I know the rapid fire is ON/OFF.

this is what i got so far

Code: Select all
    if(get_val(BUTTON_2) && time_active(BUTTON_2) >= 500) {    //ACTIVATES ON: VIEW 500MS hold
         norapidfire = !norapidfire;
        combo_run(exitmap);
      }
    if(norapidfire || event_active(BUTTON_5)) {
    combo_stop(rapidfire);
    combo_stop(rapidfire2);
    }
combo exitmap {
    wait(50);
    set_val(BUTTON_2, 0.00);
    wait(50);
    set_val(BUTTON_2, 100.00);    //view
    wait(50);
    set_val(BUTTON_2, 0.00);
    wait(50);
}
 
 
Last edited by alencroat on Sat Feb 24, 2018 4:45 pm, edited 2 times in total.
User avatar
alencroat
Lieutenant
Lieutenant
 
Posts: 320
Joined: Sun Oct 15, 2017 5:58 pm

Re: hey Im stuck

Postby alencroat » Sat Feb 24, 2018 4:21 am

actually it doesn't work coding needs work again lol. Problem is that half of time it works and half of times when I try to activate the switch it doesn't work.
I tried all kind of ways but I cant get it to work good
EDIT: I think i found the problem. is if I press and hold VIEW button longer then say 600 it starts the combo again and thats where it messes with the switch
I also found that holding a button has a problem to activate a switch properly for example,
Code: Select all
    if(get_val(BUTTON_2) && time_active(BUTTON_2) >= 500) {
        switch = !switch ;
    }
 
User avatar
alencroat
Lieutenant
Lieutenant
 
Posts: 320
Joined: Sun Oct 15, 2017 5:58 pm

Re: hey Im stuck

Postby J2Kbr » Sat Feb 24, 2018 8:36 pm

A extra variable is needed to make this code work properly, example:
Code: Select all
bool toggle;
bool event_flag;
 
main {
    if(get_val(BUTTON_2) && time_active(BUTTON_2) >= 500) {
        if(event_flag == FALSE) {
            event_flag = TRUE;
            toggle = !toggle ;
        }
    } else event_flag = FALSE;
}
 
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: hey Im stuck

Postby alencroat » Sat Feb 24, 2018 8:55 pm

Oh sorry but how do I connect that with the above script with rapid fire to stop it from firing?

Code: Select all
#pragma METAINFO("<alen>", 1, 0, "fort")
 
bool toggle;
bool event_flag;
bool norapidfire;
 
 
main {
//   if(???   //ACTIVATES ON: view for 500ms
         norapidfire = !norapidfire;
      }
    if(norapidfire || event_active(BUTTON_5)) {
    combo_stop(rapidfire);
    combo_stop(rapidfire2);
    }   
 
 
    if(get_val(BUTTON_2) && time_active(BUTTON_2) >= 500) {
        if(event_flag == FALSE) {
            event_flag = TRUE;
            toggle = !toggle ;
        }
    } else event_flag = FALSE;
}
 
 
combo rapidfire {
    set_val(BUTTON_5, 100.0);
    wait(40);
    set_val(BUTTON_5, 0.0);
    wait(30);
}
combo rapidfire2 {
    set_val(BUTTON_5, 100.0);
    wait(100);
    set_val(BUTTON_5, 0.0);
    wait(40);
}
//adding combo to the script to cancel out the map
combo exitmap {
    wait(50);
    set_val(BUTTON_2, 0.00);
    wait(50);
    set_val(BUTTON_2, 100.00);    //view
    wait(50);
    set_val(BUTTON_2, 0.00);
    wait(350);
}


How do I combine it all :joia:
User avatar
alencroat
Lieutenant
Lieutenant
 
Posts: 320
Joined: Sun Oct 15, 2017 5:58 pm

Next

Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 73 guests