Toggle On/Off an entire Include page (.ghp) Header file?

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

Re: Toggle On/Off an entire Include page (.ghp) Header file?

Postby J2Kbr » Wed Jun 21, 2017 9:52 pm

good news .. I think my idea will work ... just move the TRUE definition to your main GPC file, it will be accessible by your gph files. ;)
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: Toggle On/Off an entire Include page (.ghp) Header file?

Postby Vendetta » Wed Jun 21, 2017 10:25 pm

J2Kbr wrote: just move the TRUE definition to your main GPC file, it will be accessible by your gph files. ;)


Okay I did that but getting a "Excessive Token sequence ";" error at the these two lines;
22. #include "rapidfiretoggle.gph";
32. #include "autosprint.gph";

Code: Select all
#pragma METAINFO("WARLOCK - STORM", 1, 0, "Vendetta")
 
 
#include <ps4.gph>
#include <keyboard.gph>
#include <ledcolor.gph>
#include <rumblenotifier.gph>
 
#include <onebutton.gph>
#include <rapidfiretoggle.gph>
#include <autosprint.gph>
 
#define TRUE                           !FALSE
 
main {
    if(!key_status(KEY_1)) { //if the foot switch 1 is activated, initiate rapidfiretoggle.gph
        goto JUMP_RAPIDFIRETOOGLE;
    }
}
 
 
#include "rapidfiretoggle.gph";
 
main {
    JUMP_RAPIDFIRETOOGLE:
    if(!key_status(KEY_2)) { //if the foot switch 2 is activated, initiate autosprint.gph
        goto JUMP_AUTOSPRINT;
    }
}
 
 
#include "autosprint.gph";
 
main {
    JUMP_AUTOSPRINT:
}
    Playstation PS4, Astro A50 Gen 3, Elgato Game Capture HD60 S
    2x Benq 27” Gaming Monitors, Netduma R1 Gaming Router
    Titan One/Two Controller Input Device, Battle Beaver PS4 Controller, SCUF Infinity4PS Controller
User avatar
Vendetta
Sergeant Major of the Army
Sergeant Major of the Army
 
Posts: 226
Joined: Fri Jul 31, 2015 8:40 pm

Re: Toggle On/Off an entire Include page (.ghp) Header file?

Postby J2Kbr » Wed Jun 21, 2017 10:56 pm

Sorry, I made a mistake, there is no ; at the end of the line in these two include lines. Just delete the ; and it should compile.
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: Toggle On/Off an entire Include page (.ghp) Header file?

Postby Vendetta » Fri Jun 23, 2017 12:57 pm

Still having an issue compiling.
    Playstation PS4, Astro A50 Gen 3, Elgato Game Capture HD60 S
    2x Benq 27” Gaming Monitors, Netduma R1 Gaming Router
    Titan One/Two Controller Input Device, Battle Beaver PS4 Controller, SCUF Infinity4PS Controller
User avatar
Vendetta
Sergeant Major of the Army
Sergeant Major of the Army
 
Posts: 226
Joined: Fri Jul 31, 2015 8:40 pm

Re: Toggle On/Off an entire Include page (.ghp) Header file?

Postby J2Kbr » Wed Jun 28, 2017 3:14 pm

Vendetta wrote:Still having an issue compiling.

Please copy-paste here the errors you are getting. Thank you.
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: Toggle On/Off an entire Include page (.ghp) Header file?

Postby Vendetta » Thu Jun 29, 2017 9:48 pm

Error: Line 36: syntax error, unexpected B_E '}'.

Code: Select all
#pragma METAINFO("Toggle", 1, 0, "Vendetta")
 
#include <keyboard.gph>
#include <rapidfiretoggle.gph>
#include <autosprint.gph>
 
#define TRUE                           !FALSE
 
main {
    if(!key_status(KEY_1)) { //if the foot switch 1 is activated, initiate rapidfiretoggle.gph
        goto JUMP_RAPIDFIRETOOGLE;
    }
}
 
 
#include "rapidfiretoggle.gph"
 
main {
    JUMP_RAPIDFIRETOOGLE:
    if(!key_status(KEY_2)) { //if the foot switch 2 is activated, initiate autosprint.gph
        goto JUMP_AUTOSPRINT;
    }
}
 
 
#include "autosprint.gph"
 
main {
    JUMP_AUTOSPRINT:
}
 


Include: Autosprint
Code: Select all
// Add to the top of script: #include <autosprint.gph>
 
// Contains code sourced from: antithesis
 
#ifndef AUTOSPRINT_GPH_
#define AUTOSPRINT_GPH_
 
 
#define shoot_wait                     300       
#define walk_wait                      4000   
 
bool    run_flag                     = FALSE;
bool    walk_flag                    = FALSE;
int     doubletap_stage_shoot        = 0;
int     doubletap_timing_shoot;
 
int reload_wait                      = 3000; // This allows you to reload weapons while sprinting.
int swap_wait                        = 950// This allows you to swap weapons while sprinting.
 
main {   
 
    if(get_val(STICK_2_Y) <= -97.00 && !get_val(BUTTON_8)) {
        run_flag = !run_flag;
    } else if(event_release(STICK_2_Y) >= -97 && !get_val(BUTTON_8)) {
        run_flag = !run_flag;
    }
    if(!walk_flag && run_flag && get_val(STICK_2_Y) <= -97.00 && !get_val(BUTTON_8)) {
        combo_run(EasySprint);
 
    } else if(!run_flag && get_val(BUTTON_17)) {
        run_flag = FALSE;
        combo_run(AllowReloading);
    } else if(!run_flag && get_val(BUTTON_5)) {
        run_flag = FALSE;
        combo_run(AllowShooting);
    } else if (!run_flag && get_val(BUTTON_14)) {
        run_flag = FALSE;
        combo_run(AllowSwapping);
    }
 
    if(doubletap_stage_shoot == 0) { // Simply double tap the Shoot button
        if(get_val(BUTTON_5)) {
            doubletap_stage_shoot = 1;
        }
    } else if(doubletap_stage_shoot == 1) {
        if(!get_val(BUTTON_5)) {
            doubletap_timing_shoot = 0;
            doubletap_stage_shoot = 2;
        }
    } else if(doubletap_stage_shoot == 2) {
        if(get_val(BUTTON_5)) {
            doubletap_stage_shoot = 1;
            combo_stop(EasySprint);
            combo_run(TimedWalk);
            walk_flag = TRUE;
        }
        doubletap_timing_shoot = doubletap_timing_shoot + elapsed_time();
        if(doubletap_timing_shoot > 150) {
            doubletap_stage_shoot = 0;
        }
    }
    if(get_val(BUTTON_5) && TimedWalk) {
        combo_run(TimedWalk);
    }
 
    if(event_active(BUTTON_15)) { // press the Crouch button to initiate a walk
        combo_stop(EasySprint);
        walk_flag = !walk_flag;
    }
}
 
// COMBOS ----------------------------------------------------------------------
 
combo EasySprint {
    set_val(BUTTON_9,100);
    wait(40);
    wait(40);
}
 
combo AllowReloading {
    set_val(BUTTON_9, 0);
    wait(reload_wait);
}
 
combo AllowShooting {
    set_val(BUTTON_9, 0);
    wait(shoot_wait);
}
 
combo AllowSwapping {
    set_val(BUTTON_9, 0);
    wait(swap_wait);
}
 
combo TimedWalk {
    set_val(BUTTON_9, 0);
    wait(walk_wait);
    walk_flag = FALSE;
}
 
#endif //AUTOSPRINT_GPH_


Include: Rapidfiretoggle
Code: Select all
// Add to the top of script: #include <rapidfiretoggle.gph>
 
#ifndef RAPIDFIRETOGGLE_GPH_
#define RAPIDFIRETOGGLE_GPH_
 
 
 
bool rapidfire_toggle = FALSE;
 
main {
 
    if(get_val(BUTTON_12) && event_active(BUTTON_5)) {  // D-Pad Left + R2
        rapidfire_toggle = !rapidfire_toggle;
        if(rapidfire_toggle) {
            combo_run(SingleRumbleNotifier);
            ColorLED('G')//green On
        } else {
            combo_run(DoubleRumbleNotifier);
            ColorLED('R')//red Off
        }
    }
    if(rapidfire_toggle && get_val(BUTTON_5)) {
        combo_run(Rapidfire);
    }
}
 
// COMBOS ----------------------------------------------------------------------
 
combo Rapidfire {
    set_val(BUTTON_5, 100);
    wait (150);
    set_val(BUTTON_5, 0);
    wait (25);
}
 
 #endif //RAPIDFIRETOGGLE_GPH_
    Playstation PS4, Astro A50 Gen 3, Elgato Game Capture HD60 S
    2x Benq 27” Gaming Monitors, Netduma R1 Gaming Router
    Titan One/Two Controller Input Device, Battle Beaver PS4 Controller, SCUF Infinity4PS Controller
User avatar
Vendetta
Sergeant Major of the Army
Sergeant Major of the Army
 
Posts: 226
Joined: Fri Jul 31, 2015 8:40 pm

Re: Toggle On/Off an entire Include page (.ghp) Header file?

Postby J2Kbr » Fri Jun 30, 2017 1:05 am

fixed couple issues, be sure to have all 3 files in the same folder.
The changes needed was only on the GPC file:
Code: Select all
#pragma METAINFO("Toggle", 1, 0, "Vendetta")
 
#include <keyboard.gph>
 
#define TRUE                           !FALSE
 
main {
    if(!key_status(KEY_1)) { //if the foot switch 1 is activated, initiate rapidfiretoggle.gph
        goto JUMP_RAPIDFIRETOOGLE;
    }
}
 
 
#include "rapidfiretoggle.gph"
 
main {
    JUMP_RAPIDFIRETOOGLE:
    if(!key_status(KEY_2)) { //if the foot switch 2 is activated, initiate autosprint.gph
        goto JUMP_AUTOSPRINT;
    }
}
 
 
#include "autosprint.gph"
 
main {
    JUMP_AUTOSPRINT:;
}
 
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

Previous

Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 127 guests