AgencyLoop LUA Script Documentation
This Money Lua Script gta 5 Automating the process of making money via Agency Loop is much simpler than it was before. AgencyLoop is an automated solution and is designed to provide you with as much safety as possible, while also helping to prevent the possibility of getting into conflict with other players. The following documentation provides information about how the majority of the systems in the AgencyLoop LUA script were developed, including the safeguards built-in to help reduce the potential for issues to arise.
There is information contained herein about how the script works, what safeguards are in place to protect your account(s), how they work, etc. The AgencyLoop LUA script source used in the documentation is a copy of the AgencyLoop LUA file that was submitted with the post.
In- Game Picture:
General Overview of the AgencyLoop LUA Script
The primary purpose of the AgencyLoop LUA script is to solve several fundamental problems related to GTA Agency system:
- The ability to receive passive income does not consistently occur.
- Agency safe values will not be updated when the current session is not supported.
- Transaction conflicts can result in a failed or delayed collection of funds.
- Manually tracking the status of your Agency income can waste time and potentially lead to desynchronization.
The script solves these problems using automation, heuristics, native checks, and redundant validation of the data, so that the income generated from the Agency is consistent and reliable, even if the session in which you are playing changes frequently
Video of the Script
Credits to Dev - #Imagine Nothing, L7NEG, YimNPC Sharing the Script
Download Links:
Global Variables and Constants for Configuration
The AgencyLoop LUA script has a well-defined configuration layer, which simulates Rockstar's internal global memory structure.
Agency Safe Global Variables
The Agency safe value is stored using a global index based on player ID. The calculation for determining the location of the agency safe value is as follows: BASE_GLOBAL_SAFE + (player_id × ENTRY_SIZE) + SAFE_OFFSET This method ensures:
- Multiple player safety
- Correct value reading for each session
- Compatibility between session reloads
- The safe capacity is set to a limit of $250,000, which is the same as Rockstar intended.
Once the Agency safe reaches the maximum capacity ($250,000): The script will initiate an automatic collection of funds.
Native Functions Cache
In order to enhance both the performance and the reliability of the script, it caches the native functions after natives.load_natives() executes. This reduces:
- Unwanted repeated table lookups
- Unwanted pcall overhead
- Timing irregularities due to the length of the runtime loop
Caching of the native functions includes:
- Determination of the session type
- Transaction refresh check
- Validity of the script thread
Caching of the native functions is very important for scripts that are meant to run indefinitely.
Session Support Detection Hybrid Heuristic
The AgencyLoop LUA script contains one of the most advanced features available in this category of scripting — a hybrid session support detection heuristic.
Why Session Detection Is Important
The Agency passive income payouts only operate properly when the session type is Freemode. In activity sessions (missions, contracts, instanced lobbies), the safe value may:
- Freeze
- Reset unexpectedly
- Fail to increment despite the fact that a payout trigger exists
The script solves this problem by utilizing a combination of three different methods for detecting whether a session is supported.
Method 1: Native Activity Session Check
The script utilizes Rockstar's native function: NETWORK_IS_ACTIVITY_SESSION If this native function returns TRUE, the script immediately identifies the session as unsupported and disables all safe-related logging.
Method 2: Heuristic Monitoring of the Safe Value
The script continuously monitors the difference between consecutive safe reads. If the safe value does not change over ten consecutive reads (~70-80 seconds), the script will assume that the session is unsupported. This helps prevent false positives that may be caused by:
- Delayed payouts
- Pending transactions
- Temporary sync lag
Method 3: Meaningful Change Detection
Any positive change to the safe value that exceeds $10,000 will immediately identify the session as supported. This allows seamless recovery when switching back to Freemode, without needing to restart the script.
Passive Income Forcing Mechanism
In order to expedite Agency payouts, the script alters two internal variables:
mpx_FIXER_COUNTmpx_FIXER_PASSIVE_PAY_TIME_LEFT
By forcing the expiration of the payout timer, the script ensures that the next game tick will process the payout immediately. This approach:
- Does not add money to your account
- Preserves Rockstar's internal payout logic
- Minimizes the risk associated with directly modifying the stats
Transaction Safety Layer
Transaction conflicts are among the largest causes of money-related bugs in GTA . The script includes a transaction safety subsystem that:
- Detects if there is a pending transaction refresh state
- Temporarily halts all payout and collection logic
- Waits until the transaction is complete and then resumes processing
If a transaction remains pending for longer than the designated safe timeout window, the script will log a warning message but will continue operating in a safe manner.
Safe Value Read and Verification
Each read operation performed on the safe value is protected using:
- pcall error checking
- Access validation checks
- Player ID verification
If the safe value cannot be read in a safe manner, the script will fail silently and attempt to read the safe value again at a future time, thereby preventing any potential crashes or undefined behavior.
Automatic Collection Logic
When the Agency safe reaches its maximum capacity:
- The script will wait for all pending transactions to be cleared
- The script sets the global collection flag
- The script waits for confirmation
- The script verifies the collection of funds
- The script updates cumulative statistics
This represents the exact behavior of Rockstar's internal ClaimSafeEarnings.cpp logic, which ensures compatibility and reliability.
Design of Logging System
The logging system in the AgencyLoop LUA script is designed to be aware of the current session and sensitive to the context of the current session:
- Log messages are suppressed in unsupported sessions
- Repetitive log messages are rate-limited
- Warnings related to transactions are only displayed when meaningful
This results in clean and readable log files, even in cases where the script runs for extended periods of time.
Runtime Statistics Tracking
Every five minutes, the script will output:
- Total amount of money collected
- Total number of collections
- Estimated collections per hour
The statistics are tracked using the actual game timer, and not a fixed delay, therefore providing accurate statistics regardless of the amount of lag or frame drops experienced.
Handling Single-Player Safety
The script determines whether the freemode thread is active. If the user is in single-player mode:
- The script will pause safely
- No global variables will be accessed
- Execution will resume automatically once the mode loads
This prevents crashes that are caused by premature access to the global variables.
Error Correction and Redundancy
Unlike simple timer-based scripts, this implementation verifies the outcome of each operation instead of simply relying on success. If a payout is not credited to the Agency safe within the expected timeframe:
- The script will wait
- The script will re-read the safe value
- The script will correct the timing dynamically
This makes the script resilient to server lag, frame drops, and background transaction delays.
Performance Considerations
Even though this script is complex, it is optimized for:
- Low CPU usage
- Minimal memory allocation
- Stable long-term execution
The heavy operational tasks in the script are executed at intervals using script.yield to prevent frame hitches and slow down of menus.
Intended Use Cases
This script is best suited for use in:
- Long Freemode sessions
- AFK-style Agency income generation
- Automated grinding setups
- Users that require safe, easy-to-use earnings
It is not intended for use in activity sessions, missions, or rapid session-hopping.




