A Simple Tutorial - GPC Script Guide (2024)

Load Zen Studio and click File > New > Empty File

A Simple Tutorial - GPC Script Guide (1)



Copy and paste the following code into the GPC code editor within Zen Studio.

GPC

main{ if(get_val(XB1_RT)){ combo_run(RAPID_FIRE); }} combo RAPID_FIRE{ set_val(XB1_RT, 100); wait(40); set_val(XB1_RT, 0); wait(30); set_val(XB1_RT, 0);}



Compile the code to check for errors. To do this, either press F7 on your keyboard or go to the Compiler drop-down menu in Zen Studio and select compile:

A Simple Tutorial - GPC Script Guide (2)



The Output window below the GPC editor should give you this message;

GPC

------ GPC: Build started ------1: New*Compilation completed with 0 warning(s)Total byte size: 148 bytes (0.23%)Total variables used: 3 of which 3 are dedicated to combos (0.59%)



If your Cronus Zen is connected via the PROG USB port and you have a controller connected, you can see this script in action by using the Build and Run option. This is accessed by either pressing F5 or selecting Build and Run in the Compiler drop-down menu. This function will compile the code and then send it to your Cronus Zen so you can test it.

A Simple Tutorial - GPC Script Guide (3)



What this script does is run the combo named RAPID_FIRE whenever the right trigger has a value or is pressed. If the Right Trigger is still held when the combo ends, it will be run again. To analyze how the Cronus Zen is told how to do this we must first break the script down into its two sections, the main and combo sections.

The Main Section

As explained here, the main section is run in a loop by the Cronus Zen. The Virtual Machine in the Cronus Zen runs through the code in order and when it reaches the end of the code, data is sent to the console and then the Virtual Machine starts the next loop.

GPC

if (get_val(XB1_RT))



The above code tells the Cronus Zen that if the statement is TRUE, run the nested code. In this case, if XB1_RT (Right Trigger) has a value greater than 0 (Zero) so is pressed or not at rest.

GPC

{ combo_run(RAPID_FIRE); }



Above is the code nested within the if statement. Nesting code creates a hierarchical structure. An open curly bracket {starts the nesting and a closed curly bracket } ends it. By nesting code within the if statement, we are telling the Cronus Zen that we only wish for that code to be executed only when the if statement is TRUE.

GPC

combo_run(RAPID_FIRE);



This line simply tells the Cronus Zen to run the combo named RAPID_FIRE. It is important to note that if the Cronus Zen receives this instruction and the combo is already running it will not do anything. It will only run the combo again if it has finished. This means that if you hold down the Right Trigger with this code active, the Cronus Zen start the combo and then run it again as soon as it has ended. Therefore, running the combo in an indefinite loop or until such time as the Right Trigger is released.

The Combo Section

GPC

combo RAPID_FIRE{ set_val(XB1_RT, 100); wait(40); set_val(XB1_RT, 0); wait(30); set_val(XB1_RT, 0);}



This is the combo that the Cronus Zen is instructed to run when the Right Trigger is pressed. When run, a combo runs through the code until it gets to a wait statement. The wait statement instructs combo to execute the commands above it for a set amount of time which is expressed in milliseconds.

GPC

set_val(XB1_RT, 100);wait(40);



These lines instruct the combo to set the value of the Right Trigger to 100 (or fully pressed) for 40 milliseconds.

GPC

set_val(XB1_RT, 0);wait(30);



Once the 40 milliseconds has passed, these lines instruct the combo to set the Right Trigger to 0 (Release) for 30 milliseconds. Additional detail on how a combo operates can be found here.

Now that you understand how this script works, we will make it more complex and change when the combo is run.

Look at this line in the main section:

GPC

if(get_val(XB1_RT)){



and change it to:

GPC

if(get_val(XB1_RT) && !get_val(XB1_LT)){



By introducing && !get_val(XB1_LT) into the if statement we are telling the Cronus Zen to only run the combo if the Right Trigger has a value and the Left Trigger does not. && means 'and' in GPC and ! means not. So the if statement now reads 'if Right Trigger has a value and Left Trigger does not. This means when using this code in-game the Cronus Zen will only Rapid Fire your gun when you are not aiming down the sights. You can use the build and run function to see this code in action.

A Simple Tutorial - GPC Script Guide (2024)
Top Articles
Latest Posts
Article information

Author: Errol Quitzon

Last Updated:

Views: 5416

Rating: 4.9 / 5 (79 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Errol Quitzon

Birthday: 1993-04-02

Address: 70604 Haley Lane, Port Weldonside, TN 99233-0942

Phone: +9665282866296

Job: Product Retail Agent

Hobby: Computer programming, Horseback riding, Hooping, Dance, Ice skating, Backpacking, Rafting

Introduction: My name is Errol Quitzon, I am a fair, cute, fancy, clean, attractive, sparkling, kind person who loves writing and wants to share my knowledge and understanding with you.