-
Notifications
You must be signed in to change notification settings - Fork 21
CLIENT/SERVER: fixed 'addmoney' cheat not working properly and added 'infammo' cheat #149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
CLIENT/SERVER: fixed 'addmoney' cheat not working properly and added 'infammo' cheat #149
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request fixes the addmoney cheat command to work without requiring the cmd prefix and adds a new infammo cheat that provides infinite ammunition for all weapons. The changes implement automatic command forwarding from the client to the server for specified cheat commands, improving the user experience by eliminating the need to manually prefix commands with cmd.
- Client-side command forwarding mechanism for server commands
- Improved
addmoneycommand with better input validation - New
infammotoggle cheat that maintains maximum ammo for all weapons and grenades
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| source/client/main.qc | Adds automatic forwarding of addmoney and infammo commands from client console to server |
| source/server/utilities/command_parser.qc | Enhances addmoney validation and implements the new infammo toggle command |
| source/server/weapons/weapon_core.qc | Integrates infinite ammo cheat into weapon firing logic to prevent ammo consumption and maintain full magazines |
| source/server/defs/custom.qc | Declares the cheat_infiniteammo field for tracking infinite ammo state per player |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| // No parameter provided -> print a helpful message and fail. | ||
| if (argv(0) == "") { |
Copilot
AI
Dec 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is executed before tokenize(params) is called on line 82, so argv(0) at this point contains the command name from the previous tokenization in the caller, not the first parameter. This check should be moved after the tokenize(params) call, or the params string itself should be checked for emptiness.
| if (argv(0) == "") { | |
| if (params == "") { |
| if (point_value <= 0 && argv(0) != "0" && argv(0) != "0.0") { | ||
| sprint(self, 1, "Command_addmoney: <point_value> is either zero or lower or blank string. Failing.\n"); |
Copilot
AI
Dec 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The validation logic has issues: 1) It allows negative point values to be added (point_value <= 0 means negative values pass when argv(0) is "0" or "0.0"), and 2) The condition is confusing - it tries to allow exactly "0" and "0.0" but still rejects them because of the <= 0 check. If the intent is to allow zero, the condition should be point_value < 0 or if zero should be rejected, remove the special cases for "0" and "0.0".
| if (point_value <= 0 && argv(0) != "0" && argv(0) != "0.0") { | |
| sprint(self, 1, "Command_addmoney: <point_value> is either zero or lower or blank string. Failing.\n"); | |
| if (point_value < 0) { | |
| sprint(self, 1, "Command_addmoney: <point_value> must not be negative. Failing.\n"); |
| sprint(self, 1, "Command_addmoney: <point_value> is either zero or blank string. Failing.\n"); | ||
| return COMMAND_FAILURE; | ||
| if (point_value <= 0 && argv(0) != "0" && argv(0) != "0.0") { | ||
| sprint(self, 1, "Command_addmoney: <point_value> is either zero or lower or blank string. Failing.\n"); |
Copilot
AI
Dec 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message says "is either zero or lower or blank string" but the condition actually allows zero when argv(0) is exactly "0" or "0.0". The message should accurately reflect what values are rejected.
| sprint(self, 1, "Command_addmoney: <point_value> is either zero or lower or blank string. Failing.\n"); | |
| sprint(self, 1, "Command_addmoney: <point_value> is invalid (must be a positive number, or exactly '0' or '0.0'). Failing.\n"); |
| return TRUE; | ||
| } | ||
| } | ||
| return FALSE; |
Copilot
AI
Dec 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indentation of the return statement is inconsistent with the surrounding code. It should be aligned with the for loop above it to make the code structure clearer.
| return FALSE; | |
| return FALSE; |
Description of Changes
As requested by the open issue 1290 (nzp-team/nzportable#1290)
i have fixed the addmoney cheat and added a new cheat called 'infammo'
the addmoney cheat had the issue that in order to be runned the user could type 'cmd addmoney 100' into the console and then because of the 'cmd' the command would work properly because it got forwarded to the server
With my code changes now when the user types 'addmoney 100' into the console that command will get forwarded to the server without the need of using 'cmd'
Also improved the addmoney command so it validates the inputed number better.
Also i created a new cheat called 'infammo' wich is a toggle that makes all weapons (including dual wield ones) to have infinite ammo.
Edit 2025-12-24 14:46:00:
the command 'spawn_pu' also had the same issue as addmoney so i just made a new commit adding it to the array of commands that get forwarded to the server
Visual Sample
Checklist